|
1 | 1 | """cmlxc -- Manage local chatmail relay containers via Incus. |
2 | 2 |
|
3 | 3 | Standard workflow: |
4 | | -init -> deploy-cmdeploy/deploy-madmail -> test-cmdeploy/test-madmail/test-mini. |
| 4 | +init -> deploy-cmdeploy/deploy-madmail/docker deploy -> test-*/test-mini. |
5 | 5 | """ |
6 | 6 |
|
7 | 7 | import argparse |
|
22 | 22 | ) |
23 | 23 | from cmlxc.driver_base import __version__ |
24 | 24 | from cmlxc.driver_cmdeploy import CmdeployDriver |
| 25 | +from cmlxc.driver_docker import DockerDriver |
25 | 26 | from cmlxc.driver_madmail import MadmailDriver, print_admin_info |
26 | 27 | from cmlxc.incus import Incus, _is_ip_address, check_cgroup_compat |
27 | 28 | from cmlxc.output import Out |
@@ -259,13 +260,25 @@ def _add_test_relay_args(parser): |
259 | 260 |
|
260 | 261 | def test_cmdeploy_cmd_options(parser): |
261 | 262 | _add_test_relay_args(parser) |
| 263 | + parser.add_argument( |
| 264 | + "--relay-ref", |
| 265 | + default=None, |
| 266 | + help="Override relay git ref for tests (default: SHA from deployed image label).", |
| 267 | + ) |
262 | 268 |
|
263 | 269 |
|
264 | 270 | def test_cmdeploy_cmd(args, out): |
265 | 271 | """Run cmdeploy integration tests inside the builder container.""" |
266 | 272 | ix = Incus(out) |
267 | 273 | ct = ix.get_running_relay(args.relay) |
268 | | - driver = CmdeployDriver(ct, out) |
| 274 | + drv_cls = DRIVER_BY_NAME.get(ct.driver_name) |
| 275 | + if drv_cls is None: |
| 276 | + out.red( |
| 277 | + f"Warning: unknown driver {ct.driver_name!r} for" |
| 278 | + f" {ct.shortname}, falling back to cmdeploy." |
| 279 | + ) |
| 280 | + drv_cls = CmdeployDriver |
| 281 | + driver = drv_cls(ct, out) |
269 | 282 | if not driver.check_init(): |
270 | 283 | return 1 |
271 | 284 |
|
@@ -295,6 +308,8 @@ def test_cmdeploy_cmd(args, out): |
295 | 308 | drv2 = DRIVER_BY_NAME[ct2.driver_name](ct2, out) |
296 | 309 | second_domain = drv2.get_test_domain_or_ip() |
297 | 310 |
|
| 311 | + if args.relay_ref is not None: |
| 312 | + os.environ["RELAY_REF"] = args.relay_ref |
298 | 313 | return driver.run_tests(second_domain=second_domain) |
299 | 314 |
|
300 | 315 |
|
@@ -520,11 +535,16 @@ def _print_container_status(out, c, ix): |
520 | 535 |
|
521 | 536 | def _print_builder_repos(out, ct): |
522 | 537 | try: |
523 | | - for name in DRIVER_BY_NAME: |
524 | | - path = f"/root/{name}-git-main" |
| 538 | + seen = set() |
| 539 | + for name, drv_cls in DRIVER_BY_NAME.items(): |
| 540 | + repo = drv_cls.REPO_NAME |
| 541 | + if repo in seen: |
| 542 | + continue |
| 543 | + seen.add(repo) |
| 544 | + path = f"/root/{repo}-git-main" |
525 | 545 | status = ct.get_repo_status(path) |
526 | 546 | if status: |
527 | | - out.print(f"{name}: {status}") |
| 547 | + out.print(f"{repo}: {status}") |
528 | 548 | except Exception: |
529 | 549 | out.print("repos: (unavailable)") |
530 | 550 |
|
@@ -605,7 +625,11 @@ def _print_dns_forwarding_status(out, dns_ip, *, host=False): |
605 | 625 | ("destroy", destroy_cmd, destroy_cmd_options), |
606 | 626 | ] |
607 | 627 |
|
608 | | -DRIVER_BY_NAME = {"cmdeploy": CmdeployDriver, "madmail": MadmailDriver} |
| 628 | +DRIVER_BY_NAME = { |
| 629 | + "cmdeploy": CmdeployDriver, |
| 630 | + "docker": DockerDriver, |
| 631 | + "madmail": MadmailDriver, |
| 632 | +} |
609 | 633 |
|
610 | 634 |
|
611 | 635 | def _add_subcommand(subparsers, name, func, addopts, shared): |
|
0 commit comments