Skip to content

Commit

Permalink
Fix flakiness.
Browse files Browse the repository at this point in the history
The opened-ports call should always be first, but after that it depends on the order of items returned from set operations, and we don't care which order they happen in, so compare the sorted items.
  • Loading branch information
tonyandrewmeyer committed Sep 20, 2023
1 parent 1e35640 commit f86cf07
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3411,10 +3411,13 @@ def test_set_ports(self):
fake_script(self, 'close-port', 'exit 0')
fake_script(self, 'opened-ports', 'exit 0')
self.unit.set_ports(8000, 8025)
self.assertEqual(fake_script_calls(self, clear=True), [
['opened-ports', ''],
['open-port', '8025/tcp'],
calls = fake_script_calls(self, clear=True)
self.assertEqual(calls.pop(0), ['opened-ports', ''])
# We make no guarantee on the order the ports are opened.
calls.sort()
self.assertEqual(calls, [
['open-port', '8000/tcp'],
['open-port', '8025/tcp'],
])
fake_script(self, 'opened-ports', 'echo 8025/tcp')
self.unit.set_ports(ops.Port('udp', 8022))
Expand Down

0 comments on commit f86cf07

Please sign in to comment.