tests: add some assertions to metrics case
Compare the jsoned content reading from metrics FIFO with the excepted
group values, to check if the metrics FIFO reading process is as
expected.
"""Tests the metrics system."""
import os
+import json
import host_tools.logging as log_tools
@@ -23,4 +24,28 @@ def test_flush_metrics(test_microvm_with_api):
microvm.start()
+ res = metrics_fifo.sequential_reader(1)
+ metrics = json.loads(res[0])
+
+ exp_keys = [
+ 'utc_timestamp_ms',
+ 'api_server',
+ 'block',
+ 'get_api_requests',
+ 'i8042',
+ 'logger',
+ 'mmds',
+ 'net',
+ 'patch_api_requests',
+ 'put_api_requests',
+ 'rtc',
+ 'seccomp',
+ 'vcpu',
+ 'vmm',
+ 'uart',
+ 'signals',
+ ]
+
+ assert set(metrics.keys()) == set(exp_keys)
+
microvm.flush_metrics(metrics_fifo)
