mirror of
https://github.com/nicolargo/glances.git
synced 2026-06-19 19:18:39 -04:00
Add test for JSON export
This commit is contained in:
5
Makefile
5
Makefile
@@ -117,13 +117,16 @@ test-min-with-upgrade: venv-min-upgrade ## Upgrade deps and run unit tests in mi
|
||||
test-export-csv: ## Run interface tests with CSV
|
||||
/bin/bash ./tests/test_export_csv.sh
|
||||
|
||||
test-export-json: ## Run interface tests with JSON
|
||||
/bin/bash ./tests/test_export_json.sh
|
||||
|
||||
test-export-influxdb-v1: ## Run interface tests with InfluxDB version 1 (Legacy)
|
||||
/bin/bash ./tests/test_export_influxdb_v1.sh
|
||||
|
||||
test-export-influxdb-v3: ## Run interface tests with InfluxDB version 3 (Core)
|
||||
/bin/bash ./tests/test_export_influxdb_v3.sh
|
||||
|
||||
test-export: test-export-csv test-export-influxdb-v1 test-export-influxdb-v3 ## Tests all exports
|
||||
test-export: test-export-csv test-export-json test-export-influxdb-v1 test-export-influxdb-v3 ## Tests all exports
|
||||
|
||||
# ===================================================================
|
||||
# Linters, profilers and cyber security
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
#!/bin/bash
|
||||
# Pre-requisites:
|
||||
# - jq
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
||||
# Run glances with export to InfluxDB, stopping after 10 writes
|
||||
# Run glances with export to CSV file, stopping after 10 writes
|
||||
# This will run synchronously now since we're using --stop-after
|
||||
echo "Glances starts to export system stats to CSV file /tmp/glances.csv (duration: ~ 20 seconds)"
|
||||
rm -f /tmp/glances.csv
|
||||
./venv/bin/python -m glances --export csv --export-csv-file /tmp/glances.csv --stop-after 10 --quiet
|
||||
|
||||
echo "Checking CSV file..."
|
||||
./venv/bin/python ./tests-data/tools/csvcheck.py -i /tmp/glances2.csv -l 9
|
||||
./venv/bin/python ./tests-data/tools/csvcheck.py -i /tmp/glances.csv -l 9
|
||||
|
||||
19
tests/test_export_json.sh
Executable file
19
tests/test_export_json.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
||||
# Run glances with export to JSON file, stopping after 3 writes (to be sure rates are included)
|
||||
# This will run synchronously now since we're using --stop-after
|
||||
echo "Glances starts to export system stats to JSON file /tmp/glances.json (duration: ~ 10 seconds)"
|
||||
rm -f /tmp/glances.json
|
||||
./venv/bin/python -m glances --export json --export-json-file /tmp/glances.json --stop-after 3 --quiet
|
||||
|
||||
echo "Checking JSON file..."
|
||||
jq . /tmp/glances.json
|
||||
jq .cpu /tmp/glances.json
|
||||
jq .cpu.total /tmp/glances.json
|
||||
jq .mem /tmp/glances.json
|
||||
jq .mem.total /tmp/glances.json
|
||||
jq .processcount /tmp/glances.json
|
||||
jq .processcount.total /tmp/glances.json
|
||||
Reference in New Issue
Block a user