-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47416d8
commit c4a38dc
Showing
23 changed files
with
438 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
ubuntu-advantage-tools (1:1+devel) UNRELEASED; urgency=medium | ||
ubuntu-advantage-tools (35~lxd-auto-attach-test) noble; urgency=medium | ||
|
||
* wip | ||
* testing pro lxd auto attach | ||
|
||
-- Grant Orndorff <[email protected]> Fri, 16 Aug 2024 12:10:33 -0500 | ||
-- Grant Orndorff <[email protected]> Tue, 13 Aug 2024 16:28:22 -0500 | ||
|
||
ubuntu-advantage-tools (33.2) oracular; urgency=medium | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Feature: LXD Pro features | ||
|
||
Scenario Outline: LXD guest auto-attach | ||
Given a `<release>` `<machine_type>` machine with ubuntu-advantage-tools installed | ||
# When I run `snap install lxd --channel latest/edge` with sudo | ||
When I run `lxd init --minimal` with sudo | ||
When I start `lxd-download` command `lxc image copy ubuntu-daily:noble local:` in the background | ||
When I run `pro config show` with sudo | ||
Then stdout matches regexp: | ||
""" | ||
lxd_guest_attach +off | ||
""" | ||
Then I verify that running `pro config set lxd_guest_attach=available` `with sudo` exits `1` | ||
Then I will see the following on stderr: | ||
""" | ||
This machine is not attached to an Ubuntu Pro subscription. | ||
See https://ubuntu.com/pro | ||
""" | ||
When I attach `contract_token` with sudo and options `--no-auto-enable` | ||
When I run `pro config show` with sudo | ||
Then stdout matches regexp: | ||
""" | ||
lxd_guest_attach +off | ||
""" | ||
# latest/edge needed for early testing for now | ||
When I wait for the `lxd-download` command to complete | ||
When I run `lxc launch ubuntu-daily:<guest_release> guest` with sudo | ||
When I install ubuntu-advantage-tools on the `guest` lxd guest | ||
Then I verify that running `lxc exec guest -- pro auto-attach` `with sudo` exits `1` | ||
Then I will see the following on stderr: | ||
""" | ||
The LXD host does not allow guest auto attach | ||
""" | ||
When I run `pro config set lxd_guest_attach=available` with sudo | ||
When I run `lxc exec guest -- pro auto-attach` with sudo | ||
When I run `lxc exec guest -- pro api u.pro.status.is_attached.v1` with sudo | ||
Then I will see the following on stdout: | ||
""" | ||
jq it to see its attached | ||
""" | ||
When I run `lxc exec guest -- pro detach --assume-yes` with sudo | ||
When I run `pro config set lxd_guest_attach=off` with sudo | ||
Then I verify that running `lxc exec guest -- pro auto-attach` `with sudo` exits `1` | ||
Then I will see the following on stdout: | ||
""" | ||
The LXD host does not allow guest auto attach | ||
""" | ||
When I run `lxc delete --force guest` with sudo | ||
When I run `pro config set lxd_guest_attach=on` with sudo | ||
When I run `lxc restart guest` with sudo | ||
When I run `lxc exec guest -- pro status --wait` with sudo | ||
When I run `lxc exec guest -- pro api u.pro.status.is_attached.v1` with sudo | ||
Then I will see the following on stdout: | ||
""" | ||
jq it to see its attached | ||
""" | ||
When I run `lxc exec guest -- pro detach --assume-yes` with sudo | ||
When I run `pro config unset lxd_guest_attach` with sudo | ||
Then I verify that running `lxc exec guest -- pro auto-attach` `with sudo` exits `1` | ||
Then I will see the following on stdout: | ||
""" | ||
The LXD host does not allow guest auto attach | ||
""" | ||
|
||
Examples: | ||
| release | machine_type | guest_release | | ||
| jammy | lxd-vm | noble | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import time | ||
|
||
from behave import step | ||
|
||
from features.steps.shell import when_i_run_command | ||
|
||
|
||
@step("I start `{task}` command `{command}` in the background") | ||
def start_task(context, task, command): | ||
when_i_run_command( | ||
context, | ||
f"systemd-run --no-block --unit={task} --property=Type=oneshot --property=RemainAfterExit=yes {command}", # noqa: E501 | ||
"with sudo", | ||
) | ||
|
||
|
||
@step("I wait for the `{task}` command to complete") | ||
def wait_for_task(context, task): | ||
while True: | ||
try: | ||
when_i_run_command( | ||
context, f"systemctl is-active {task}", "with sudo" | ||
) | ||
break | ||
except AssertionError: | ||
time.sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.