mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2025-05-10 01:43:45 +02:00
Add testdata to simplify integration testing
This commit is contained in:
parent
2dbb38512f
commit
2a6d88bc39
63
test/testdata/README.md
vendored
Normal file
63
test/testdata/README.md
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# Example Data for Testing
|
||||
|
||||
Example calls:
|
||||
|
||||
```bash
|
||||
python check_http_json.py -H localhost:8080 -p data0.json -q "age,20"
|
||||
UNKNOWN: Status UNKNOWN. Could not find JSON in HTTP body.
|
||||
```
|
||||
|
||||
```bash
|
||||
python check_http_json.py -H localhost:8080 -p data1.json -e date
|
||||
WARNING: Status WARNING. Key date did not exist.
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data1.json -E age
|
||||
OK: Status OK.
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data1.json -w "age,30"
|
||||
OK: Status OK.
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data1.json -w "age,20"
|
||||
WARNING: Status WARNING. Value (30) for key age was outside the range 0:20.
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data1.json -q "age,20"
|
||||
WARNING: Status WARNING. Key age mismatch. 20 != 30
|
||||
```
|
||||
|
||||
```bash
|
||||
python check_http_json.py -H localhost:8080 -p data2.json -q "(1).id,123"
|
||||
WARNING: Status WARNING. Key (1).id mismatch. 123 != 2
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data2.json -Y "(1).id,2"
|
||||
CRITICAL: Status CRITICAL. Key (1).id match found. 2 == 2
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data2.json -E "(1).author"
|
||||
OK: Status OK.
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data2.json -E "(1).pages"
|
||||
CRITICAL: Status CRITICAL. Key (1).pages did not exist.
|
||||
```
|
||||
|
||||
```bash
|
||||
python check_http_json.py -H localhost:8080 -p data3.json -q "company.employees.(0).role,Developer"
|
||||
OK: Status OK.
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data3.json -q "company.employees.(0).role,Dev"
|
||||
WARNING: Status WARNING. Key company.employees.(0).role mismatch. Dev != Developer
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data3.json -q "company.employees.(0).role,Developer" "company.employees.(1).role,Designer"
|
||||
OK: Status OK.
|
||||
```
|
||||
|
||||
```bash
|
||||
python check_http_json.py -H localhost:8080 -p data4.json -u "ratings(0),4.5"
|
||||
OK: Status OK.
|
||||
|
||||
python check_http_json.py -H localhost:8080 -p data4.json -u "ratings(0),4.1"
|
||||
UNKNOWN: Status UNKNOWN. Key ratings(0) mismatch. 4.1 != 4.5
|
||||
```
|
||||
|
||||
```bash
|
||||
python check_http_json.py -H localhost:8080 -p data5.json -q service1.status,True service2.status,True service3.status,True
|
||||
OK: Status OK.
|
||||
```
|
1
test/testdata/data0-invalid.json
vendored
Normal file
1
test/testdata/data0-invalid.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
No JSON
|
5
test/testdata/data1.json
vendored
Normal file
5
test/testdata/data1.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "John Doe",
|
||||
"age": 30,
|
||||
"city": "New York"
|
||||
}
|
17
test/testdata/data2.json
vendored
Normal file
17
test/testdata/data2.json
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Book One",
|
||||
"author": "Author One"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Book Two",
|
||||
"author": "Author Two"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Book Three",
|
||||
"author": "Author Three"
|
||||
}
|
||||
]
|
18
test/testdata/data3.json
vendored
Normal file
18
test/testdata/data3.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"company": {
|
||||
"name": "Tech Corp",
|
||||
"location": "San Francisco",
|
||||
"employees": [
|
||||
{
|
||||
"name": "Alice",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Bob",
|
||||
"role": "Designer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"founded": 2010,
|
||||
"industry": "Technology"
|
||||
}
|
13
test/testdata/data4.json
vendored
Normal file
13
test/testdata/data4.json
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"id": 123,
|
||||
"active": true,
|
||||
"tags": ["tech", "startup", "innovation"],
|
||||
"details": {
|
||||
"website": "https://example.com",
|
||||
"contact": {
|
||||
"email": "info@example.com",
|
||||
"phone": "+1-234-567-890"
|
||||
}
|
||||
},
|
||||
"ratings": [4.5, 4.7, 4.8]
|
||||
}
|
38
test/testdata/data5.json
vendored
Normal file
38
test/testdata/data5.json
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"service1": {
|
||||
"status": true
|
||||
},
|
||||
"service2": {
|
||||
"status": true,
|
||||
"meta": {
|
||||
"res": "PONG"
|
||||
}
|
||||
},
|
||||
"service3": {
|
||||
"status": true,
|
||||
"meta": {
|
||||
"took": 9,
|
||||
"timed_out": false,
|
||||
"_shards": {
|
||||
"total": 0,
|
||||
"successful": 0,
|
||||
"skipped": 0,
|
||||
"failed": 0
|
||||
},
|
||||
"hits": {
|
||||
"total": {
|
||||
"value": 10000,
|
||||
"relation": "gte"
|
||||
},
|
||||
"max_score": null,
|
||||
"hits": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"service4": {
|
||||
"status": true,
|
||||
"meta": {
|
||||
"status": "ok"
|
||||
}
|
||||
}
|
||||
}
|
7
test/testdata/docker-compose.yml
vendored
Normal file
7
test/testdata/docker-compose.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:1-alpine
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- ./:/usr/share/nginx/html
|
Loading…
Reference in New Issue
Block a user