Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/integration_tests/bugs/test_lp1900837.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_permissions_unchanged(self, client):
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)
11 changes: 11 additions & 0 deletions tests/integration_tests/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ def __init__(self, cloud: 'IntegrationCloud', instance: BaseInstance,
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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh nice in uaclient we just added

instance.stop(wait=True)
instance.start(wait=False)
instance.wait(raise_on_cloudinit_failure=False).

I think your approach here is a little more succinct simpler and I think more correct.

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')
Expand Down