mirror of
https://github.com/Warky-Devs/nvr-notify-api.git
synced 2025-05-19 07:47:31 +00:00
3.4 KiB
3.4 KiB
Vivotek NVR API Test Client
This repository contains two test clients for the Vivotek NVR Event Handler API:
- Single Event Test Client (
vivotek-test-client.go
) - For sending individual test events with customizable parameters - Batch Test Client (
vivotek-test-batch.go
) - For running complex test scenarios defined in JSON
Prerequisites
- Go 1.18 or higher
- Network access to your Vivotek NVR API server
Single Event Test Client
Building
go build -o vivotek-test vivotek-test-client.go
Usage
./vivotek-test [options]
Options
Flag | Description | Default |
---|---|---|
-url |
API server URL | http://localhost:8080/event |
-type |
Event type | MotionDetection |
-device |
Device ID | NVR12345 |
-channel |
Channel ID | Camera01 |
-zone |
Detection zone (for motion events) | Zone1 |
-user |
Basic auth username | "" |
-pass |
Basic auth password | "" |
-insecure |
Skip TLS verification | false |
-repeat |
Number of events to send | 1 |
-interval |
Interval between events in seconds | 5 |
Examples
Test a motion detection event:
./vivotek-test -type=MotionDetection -device=NVR001 -channel=Camera01 -zone=FrontDoor
Test video loss with authentication:
./vivotek-test -type=VideoLoss -device=NVR001 -channel=Camera02 -user=admin -pass=password
Generate multiple events:
./vivotek-test -type=DeviceConnection -device=NVR002 -repeat=5 -interval=10
Batch Test Client
The batch test client allows you to define complex test scenarios in a JSON file and execute them with a single command.
Building
go build -o vivotek-batch vivotek-test-batch.go
Usage
./vivotek-batch [options]
Options
Flag | Description | Default |
---|---|---|
-url |
API server URL | http://localhost:8080/event |
-user |
Basic auth username | "" |
-pass |
Basic auth password | "" |
-concurrency |
Number of concurrent requests | 1 |
-scenario |
JSON file with test scenarios | test_scenario.json |
-output |
Output results to results.json | false |
Test Scenario Format
The test scenario file uses the following format:
{
"name": "Test Scenario Name",
"description": "Description of the test scenario",
"events": [
{
"eventType": "MotionDetection",
"deviceId": "NVR001",
"channelId": "Camera01",
"delaySeconds": 0,
"eventDetails": {
"zoneId": "Zone1",
"confidence": 95
}
},
...
]
}
Examples
Run the default test scenario:
./vivotek-batch
Run a custom scenario with authentication:
./vivotek-batch -scenario=my_scenario.json -user=admin -pass=password
Run with multiple concurrent requests:
./vivotek-batch -concurrency=5 -output
Tips for Testing
- Start with Single Events: Use the single event client first to verify basic connectivity
- Check Server Logs: Monitor the server logs while running tests to see how events are being processed
- Verify Telegram: If you've configured Telegram notifications, check that they're being sent
- Increase Load Gradually: When testing performance, start with low concurrency and gradually increase
- Custom Scenarios: Create different scenarios for different testing purposes (basic functionality, stress testing, etc.)