Skip to content

Commit

Permalink
test: Fix test_failing_userdata_modules_exit_codes (#5279)
Browse files Browse the repository at this point in the history
In f24ecef, we persist error state across mode invocations during
the same boot. Fix the integration testing accordingly.
  • Loading branch information
TheRealFalcon committed May 10, 2024
1 parent 63a0fcd commit 33f5018
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/integration_tests/modules/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,18 @@ def test_invalid_userdata_schema(client: IntegrationInstance):

@pytest.mark.user_data(FAILING_USER_DATA)
def test_failing_userdata_modules_exit_codes(client: IntegrationInstance):
"""Test failing in modules representd in exit status"""
"""Test failing in modules representd in exit status.
To ensure we don't miss any errors or warnings if a service happens
to be restarted, any further module invocations will exit with error
on the same boot if a previous invocation exited with error.
In this test, both bootcmd and runcmd will exit with error the first time.
The second time, runcmd will run cleanly, but still exit with error.
Since bootcmd runs in init timeframe, and runcmd runs in final timeframe,
expect error from those two modes.
"""
for mode in ("init", "config", "final"):
result = client.execute(f"cloud-init modules --mode {mode}")
assert result.failed if mode == "init" else result.ok
assert result.ok if mode == "config" else result.failed
assert f"'modules:{mode}'" in result.stdout.strip()

0 comments on commit 33f5018

Please sign in to comment.