Skip to content

Commit 0a363fc

Browse files
Alexandra Iordachealxiord
Alexandra Iordache
authored andcommitted
tests: fix dirty page logging test
Assert that the first time the dirty page metric is logged, the value is 0, but the next time (triggered with the FlushMetrics command) it is a positive number. Fixes #845 Signed-off-by: Alexandra Iordache <[email protected]>
1 parent bfcf33d commit 0a363fc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/integration_tests/functional/test_logging.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import json
99
import os
1010
import re
11-
from time import strptime
11+
from time import sleep, strptime
1212

1313
import host_tools.logging as log_tools
1414

@@ -140,11 +140,13 @@ def test_dirty_page_metrics(test_microvm_with_api):
140140

141141
microvm.start()
142142

143-
lines = metrics_fifo.sequential_reader(3)
144-
for line in lines:
145-
assert int(json.loads(line)['memory']['dirty_pages']) >= 0
146-
# TODO force metrics flushing and get real data without waiting for
147-
# Firecracker to flush periodically.
143+
sleep(0.3)
144+
response = microvm.actions.put(action_type='FlushMetrics')
145+
assert microvm.api_session.is_good_response(response.status_code)
146+
147+
lines = metrics_fifo.sequential_reader(2)
148+
assert int(json.loads(lines[0])['memory']['dirty_pages']) == 0
149+
assert int(json.loads(lines[1])['memory']['dirty_pages']) > 0
148150

149151

150152
def log_file_contains_strings(log_fifo, string_list):

0 commit comments

Comments
 (0)