Skip to content

Commit

Permalink
Fix flaky test_recover_from_resource_too_old exception (#28475)
Browse files Browse the repository at this point in the history
After #28047 the test_recover_from_resource_too_old started to
fail in a flaky way. Turned out that - depend on some other test
run the Singleton ResourceVersion could containt not one but
two namespaces (including default namespace).

Also while fixing the tests it's been noticed that the test
missed an assert - it did not assert that the Exception was in fact
thrown, so the test could have succeeded even if the exception was
not really thrown (there was assert in "except" clause but if the
exception was not thrown, it would not have been called at all).
  • Loading branch information
potiuk authored Dec 19, 2022
1 parent 290fc46 commit 0311ac9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/executors/test_kubernetes_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,12 +1249,13 @@ def effect():
try:
# self.watcher._run() is mocked and return "500" as last resource_version
self.watcher.run()
assert False, "Should have raised Exception"
except Exception as e:
assert e.args == ("sentinel",)

# both resource_version should be 0 after _run raises an exception
assert self.watcher.resource_version == "0"
assert ResourceVersion().resource_version == {self.test_namespace: "0"}
assert ResourceVersion().resource_version[self.test_namespace] == "0"

# check that in the next run, _run is invoked with resource_version = 0
mock_underscore_run.reset_mock()
Expand Down

0 comments on commit 0311ac9

Please sign in to comment.