summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2022-06-21 13:26:39 +0200
committerBenjamin Berg <bberg@redhat.com>2022-07-12 16:51:24 +0200
commit246acd27f3cbc58462d05382744688905f0bf9ed (patch)
tree7a7dcfdcc9debeb4e29d24bed9623b4192ee5464
parentc6cd9beff30588be711c3dd22d30f0496b210e1f (diff)
test: Fix flaky battery aggregation test
It seems that the test was still flaky, the reason for that would be that we did not explicitly wait for the log line saying that the aggregate state was calculated. The only reason that it did not consistently fail appears to be that searching for the state conflict caused messages to be skipped. That is wrong, we should account for every "Calculating percentage" message to ensure that upowerd and the test is in sync.
-rwxr-xr-xsrc/linux/integration-test.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/linux/integration-test.py b/src/linux/integration-test.py
index 3b231b4..d9fc593 100755
--- a/src/linux/integration-test.py
+++ b/src/linux/integration-test.py
@@ -25,6 +25,7 @@ import shutil
import subprocess
import unittest
import time
+import re
from output_checker import OutputChecker
from packaging.version import parse as parse_version
@@ -683,13 +684,17 @@ class Tests(dbusmock.DBusTestCase):
self.daemon_log.check_line('Calculating percentage', timeout=2.0)
self.testbed.uevent(bat1, 'change')
+ # TODO: Make this more elegant somehow
+ lines = self.daemon_log.check_line('Calculating percentage', timeout=2.0)
+ for l in lines:
+ found = bool(re.match(b".*Conflicting.*state.*", l))
+ if found:
+ break
+
if display_device_state[i][j] == CONFLICT:
- self.daemon_log.check_line_re("Conflicting.*state", timeout=2.0)
+ self.assertTrue(found)
else:
- # TODO: Add a helper in OutputChecker to do this
- lines = self.daemon_log.check_line('Calculating percentage', timeout=2.0)
- for l in lines:
- self.assertNotRegex(l, b"Conflicting.*state")
+ self.assertFalse(found)
if display_device_state[i][j] >= 0:
self.assertEqual(self.get_dbus_display_property('State'), display_device_state[i][j],