launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25303
[Merge] ~cjwatson/lpbuildbot-worker:simplify-test into lpbuildbot-worker:main
Colin Watson has proposed merging ~cjwatson/lpbuildbot-worker:simplify-test into lpbuildbot-worker:main.
Commit message:
Simplify create_ephemeral_container using _exec
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/lpbuildbot-worker/+git/lpbuildbot-worker/+merge/390852
Now that _exec uses "lxc exec", we can rephrase create_ephemeral_container using it, which makes it much simpler.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/lpbuildbot-worker:simplify-test into lpbuildbot-worker:main.
diff --git a/lp-setup-lxd-test b/lp-setup-lxd-test
index 8444810..27236f9 100755
--- a/lp-setup-lxd-test
+++ b/lp-setup-lxd-test
@@ -62,25 +62,14 @@ def create_ephemeral_container(
print("Waiting for successful cloud-init", flush=True)
_exec(test_container, ["cloud-init", "status", "--wait"])
- # ideally this should use pylxd, but getting streaming output from that
- # is hard, so lets just shell
+ command = [
+ "./utilities/run-as", "buildbot", "./bin/with-xvfb",
+ "./bin/test", "-vvv", "--shuffle", "--subunit-v2",
+ ]
if list_tests:
- command = (
- "cd {} && ./utilities/run-as buildbot ./bin/with-xvfb "
- "./bin/test -vvv --shuffle --subunit-v2 --list".format(work_dir)
- )
+ command.append("--list")
elif load_list:
- command = (
- "cd {} && ./utilities/run-as buildbot ./bin/with-xvfb "
- "./bin/test -vvv --shuffle --subunit-v2 --load-list {}".format(
- work_dir, load_list
- )
- )
- else:
- command = (
- "cd {} && ./utilities/run-as buildbot ./bin/with-xvfb "
- "./bin/test -vvv --shuffle --subunit-v2".format(work_dir)
- )
+ command.extend(["--load-list", load_list])
container_ip = None
for address in test_container.state().network["eth0"]["addresses"]:
if address["family"] == "inet":
@@ -108,8 +97,8 @@ def create_ephemeral_container(
"root@{}:{}".format(container_ip, str(work_dir) + "/temp/"),
]
)
- return_code = subprocess.call(
- ["lxc", "exec", test_container_name, "--", "bash", "-c", command]
+ return_code, _ = _exec(
+ test_container, command, cwd=work_dir, exit_on_error=False,
)
if list_tests:
print("rsync temp dir out of container {}".format(test_container_name))