Merge ~adam-collard/maas-ci/+git/system-tests:lxd-vm-bug into ~maas-committers/maas-ci/+git/system-tests:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: 7c3389aa4295f4c391b555f4efefa576c9687bb8
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas-ci/+git/system-tests:lxd-vm-bug
Merge into: ~maas-committers/maas-ci/+git/system-tests:master
Diff against target: 137 lines (+18/-21)
5 files modified
systemtests/env_builder/test_basic.py (+12/-10)
systemtests/lxd.py (+2/-2)
systemtests/tests_per_machine/test_hardware_sync.py (+1/-5)
systemtests/tests_per_machine/test_machine.py (+1/-2)
systemtests/utils.py (+2/-2)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Diego Mascialino (community) Approve
Review via email: mp+426185@code.launchpad.net

Commit message

Always start from scratch with VMs

Remove old-debug

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lxd-vm-bug lp:~adam-collard/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: 5f69027dcb64c75850ff047122ad4f0df374f5cf

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lxd-vm-bug lp:~adam-collard/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: 96e7fa963cb34e90a751a012553da080a62ac00e

review: Approve
Revision history for this message
Diego Mascialino (dmascialino) :
review: Needs Information
7c3389a... by Adam Collard

Launch the VM with a fixed MAC address (diego's feedback)

Revision history for this message
Adam Collard (adam-collard) :
Revision history for this message
Diego Mascialino (dmascialino) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lxd-vm-bug lp:~adam-collard/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: 7c3389aa4295f4c391b555f4efefa576c9687bb8

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/systemtests/env_builder/test_basic.py b/systemtests/env_builder/test_basic.py
2index 20da521..43ac2cf 100644
3--- a/systemtests/env_builder/test_basic.py
4+++ b/systemtests/env_builder/test_basic.py
5@@ -10,7 +10,6 @@ import pytest
6 from retry import retry
7
8 from systemtests.lxd import get_lxd
9-from systemtests.subprocess import run_with_logging
10 from systemtests.utils import (
11 randomstring,
12 retries,
13@@ -120,9 +119,16 @@ class TestSetup:
14 lxd = get_lxd(logger=testlog)
15 instances = lxd.list_instances()
16 vm_name = instance_config.name
17- # VM doesn't exist, let's create it
18- if vm_name not in instances:
19- lxd.create_vm(vm_name, profile=instance_config.lxd_profile)
20+ # Force delete the VM so we know we're starting clean
21+ if vm_name in instances:
22+ lxd.delete(vm_name)
23+
24+ # Need to create a network device with a hwaddr
25+ kwargs = {
26+ "profile": instance_config.lxd_profile,
27+ "volatile.eth0.hwaddr": instance_config.mac_address,
28+ }
29+ lxd.create_vm(vm_name, **kwargs)
30
31 mac_address = instance_config.mac_address
32
33@@ -143,11 +149,6 @@ class TestSetup:
34 lxd.start(vm_name)
35 except CalledProcessError:
36 lxd._run(["lxc", "info", "--show-log", vm_name])
37- process = run_with_logging(["ps", "aux"], logger=testlog)
38- for pid in process.stdout.splitlines():
39- run_with_logging(
40- ["cat", f"/proc/{pid}/cmdline"], logger=testlog
41- )
42 raise
43 else:
44 assert (
45@@ -169,10 +170,11 @@ class TestSetup:
46 if machine["status_name"] == "New":
47 maas_api_client.commission_machine(machine)
48
49- wait_for_machine(
50+ machine = wait_for_machine(
51 maas_api_client,
52 machine,
53 status="Ready",
54 abort_status="Failed commissioning",
55 timeout=20 * 60,
56 )
57+ assert machine["status_name"] == "Ready"
58diff --git a/systemtests/lxd.py b/systemtests/lxd.py
59index 7fcdc78..b17ac0e 100644
60--- a/systemtests/lxd.py
61+++ b/systemtests/lxd.py
62@@ -193,8 +193,8 @@ class CLILXD:
63
64 return _retry_bad_handshake()
65
66- def delete(self, container: str) -> None:
67- self._run(["lxc", "delete", "--force", container])
68+ def delete(self, instance: str) -> None:
69+ self._run(["lxc", "delete", "--force", instance])
70
71 def get_ip_address(self, container: str) -> str:
72 @retry(
73diff --git a/systemtests/tests_per_machine/test_hardware_sync.py b/systemtests/tests_per_machine/test_hardware_sync.py
74index 6d71cf3..40d4346 100644
75--- a/systemtests/tests_per_machine/test_hardware_sync.py
76+++ b/systemtests/tests_per_machine/test_hardware_sync.py
77@@ -111,7 +111,7 @@ def test_hardware_sync(
78 enable_hw_sync="true",
79 )
80
81- wait_for_machine(
82+ hardware_sync_machine.machine = wait_for_machine(
83 maas_api_client,
84 hardware_sync_machine.machine,
85 status="Deployed",
86@@ -120,10 +120,6 @@ def test_hardware_sync(
87 timeout=40 * 60,
88 )
89
90- # if machine_config.osystem == "ubuntu":
91- hardware_sync_machine.machine = maas_api_client.read_machine(
92- hardware_sync_machine.machine
93- ) # IP could change after deploy
94 stdout = ssh_execute_command(
95 hardware_sync_machine.machine, "ubuntu", ssh_key, "cat /etc/cloud/build.info"
96 )
97diff --git a/systemtests/tests_per_machine/test_machine.py b/systemtests/tests_per_machine/test_machine.py
98index 2eacf19..049a176 100644
99--- a/systemtests/tests_per_machine/test_machine.py
100+++ b/systemtests/tests_per_machine/test_machine.py
101@@ -92,7 +92,7 @@ def test_full_circle(
102 machine, osystem=machine_config.osystem, distro_series=machine_config.osystem
103 )
104
105- wait_for_machine(
106+ machine = wait_for_machine(
107 maas_api_client,
108 machine,
109 status="Deployed",
110@@ -101,7 +101,6 @@ def test_full_circle(
111 )
112
113 if machine_config.osystem == "ubuntu":
114- machine = maas_api_client.read_machine(machine) # IP could change after deploy
115 stdout = ssh_execute_command(
116 machine, "ubuntu", ssh_key, "cat /etc/cloud/build.info"
117 )
118diff --git a/systemtests/utils.py b/systemtests/utils.py
119index bc389ce..ad4c33b 100644
120--- a/systemtests/utils.py
121+++ b/systemtests/utils.py
122@@ -157,13 +157,13 @@ def wait_for_machine(
123 abort_status: Optional[str] = None,
124 timeout: float = 10 * 60,
125 delay: float = 30,
126-) -> None:
127+) -> api.Machine:
128 """Blocks execution until machine reaches given status."""
129 for retry_info in retries(timeout, delay):
130 tmp_machine = api_client.read_machine(machine)
131 current_status = tmp_machine["status_name"]
132 if current_status == status:
133- return
134+ return tmp_machine
135 else:
136 # Deliberately overwrite this variable so the last one is kept
137 events = debug_last_events(api_client, machine["system_id"])

Subscribers

People subscribed via source and target branches

to all changes: