diff options
author | Daniel Watkins <oddbloke@ubuntu.com> | 2020-12-03 12:46:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 10:46:24 -0700 |
commit | ed9bd19ca88e4c6458c95d26151c734112615e9a (patch) | |
tree | 2049f369460a56b97f02f311a0a4d3fd64b0b1f6 /tests | |
parent | bd76d5cfbde9c0801cefa851db82887e0bab34c1 (diff) | |
download | vyos-cloud-init-ed9bd19ca88e4c6458c95d26151c734112615e9a.tar.gz vyos-cloud-init-ed9bd19ca88e4c6458c95d26151c734112615e9a.zip |
integration_tests: introduce IntegrationInstance.restart (#708)
This wraps pycloudlib's `BaseInstance.restart` and `BaseInstance.wait`
to pass the same parameters as on launch, to avoid cloud-init failures
on the _reboot_ raising an exception.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration_tests/bugs/test_lp1900837.py | 2 | ||||
-rw-r--r-- | tests/integration_tests/instances.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/integration_tests/bugs/test_lp1900837.py b/tests/integration_tests/bugs/test_lp1900837.py index 3fe7d0d0..18b00475 100644 --- a/tests/integration_tests/bugs/test_lp1900837.py +++ b/tests/integration_tests/bugs/test_lp1900837.py @@ -22,7 +22,7 @@ class TestLogPermissionsNotResetOnReboot: assert "600" == _get_log_perms(client) # Reboot - client.instance.restart() + client.restart() # Check that permissions are not reset on reboot assert "600" == _get_log_perms(client) diff --git a/tests/integration_tests/instances.py b/tests/integration_tests/instances.py index 8f6573cd..c68ee753 100644 --- a/tests/integration_tests/instances.py +++ b/tests/integration_tests/instances.py @@ -35,6 +35,17 @@ class IntegrationInstance: def destroy(self): self.instance.delete() + def restart(self): + """Restart this instance (via cloud mechanism) and wait for boot. + + This wraps pycloudlib's `BaseInstance.restart` to pass + `raise_on_cloudinit_failure=False` to `BaseInstance.wait`, mirroring + our launch behaviour. + """ + self.instance.restart(wait=False) + log.info("Instance restarted; waiting for boot") + self.instance.wait(raise_on_cloudinit_failure=False) + def execute(self, command, *, use_sudo=True) -> Result: if self.instance.username == 'root' and use_sudo is False: raise Exception('Root user cannot run unprivileged') |