Skip to content

feat(cli): implement test subcommand for autopkgtests - #26

Merged
mikonse merged 4 commits into
mainfrom
milo/debmagic-test-subcommand
Aug 26, 2026
Merged

feat(cli): implement test subcommand for autopkgtests#26
mikonse merged 4 commits into
mainfrom
milo/debmagic-test-subcommand

Conversation

@mikonse

@mikonse mikonse commented Aug 11, 2026

Copy link
Copy Markdown
Member

No description provided.

@mikonse
mikonse requested a review from TheJJ August 11, 2026 21:28

@TheJJ TheJJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wooh! well done :)

some ideas for improvements:

  • why is test part of build/ and test_intent is not? maybe have a test/ subdirectory for both.
  • i think we should factor out a containerconfig, and the container drivers to a container/ module outside of build, they are used by build and test (and soon lint, maybe more). the buildconfig and testconfig can then use the containerconfig.

Comment thread docs/usage/test.md Outdated
Comment thread docs/usage/test.md Outdated
Comment thread docs/usage/test.md Outdated
Comment thread packages/debmagic/src/build/driver_lxd.rs Outdated
Comment thread packages/debmagic/src/build/driver_lxd.rs Outdated
Comment thread packages/debmagic/src/build/test.rs Outdated
Comment thread packages/debmagic/src/test/run.rs Outdated
Comment thread packages/debmagic/src/test/run.rs Outdated
Comment thread packages/debmagic/src/test/run.rs
Comment thread packages/debmagic/src/build/test.rs Outdated
@mikonse
mikonse force-pushed the milo/debmagic-test-subcommand branch 2 times, most recently from 74c1df5 to 546d340 Compare August 20, 2026 20:23
@mikonse
mikonse force-pushed the milo/debmagic-test-subcommand branch from 546d340 to e065763 Compare August 22, 2026 10:34
Cleanly separates out environment and driver specific functionality and configs
which can be reused in both build and test modules.
This is already done by the environment drivers.

The only exception is the bare driver where we assume the host
environment to provide an up-to-date apt update
@mikonse
mikonse force-pushed the milo/debmagic-test-subcommand branch from e065763 to 35e242e Compare August 22, 2026 10:36

@TheJJ TheJJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

great restructure and generalization of the drivers! just a few nits and ideas left, but would be ready to ship now.

Comment thread docs/usage/build.md
Comment thread docs/usage/test.md
| `docker` | Container (`isolation-container`) |
| `bare` | None — tests run as root on the host; requires `--allow-host-test` |

The driver *is* the testbed, so autopkgtest is told to run tests whose isolation restrictions the environment actually satisfies (`--ignore-restrictions`, only for those rungs). Tests that declare `Restrictions: isolation-container` therefore run on Docker/LXD/Incus instead of skipping. `isolation-machine` is not provided by any current driver (none is a VM); those tests still skip. Bare provides nothing, even with `--allow-host-test`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lxd can be a vm - for convenience the best thing would be that the test env is upgraded to be a vm when a test requires isolation machine

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think we always should have our driver selection and behavior deterministic and not automagic.

I.e. if we try running a test which requires vm isolation hint that you can use the lxd driver.
But that one would also need virtualization available on the host which might not necessarily be possible out of the box so automagicness is probably not that desirable here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yea, and the lxd should get a --vm flag or something

);
} else {
eprintln!("Build failed: {error}");
eprintln!("Re-run with --shell-on-failure to inspect the build environment");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

or if its persistent, use debmagic shell? (which could if not given a "target" prompt interacively for the build/test env (whichever failed last by default)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm, I think the debmagic shell command now needs a rework anyways, I think we need to remove that as an explicit command and make it subcommands of the debmagic build / test commands. Otherwise it might be too confusing

Ok(())
}

pub fn resource_name(prefix: &str, label: &str, identifier: &str) -> String {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

max len could be a parameter, since only lxd has this length limit i think

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think having it restricted in general does not hurt much and keeps variance in our code low

@mikonse
mikonse merged commit a6b140b into main Aug 26, 2026
10 checks passed
@mikonse
mikonse deleted the milo/debmagic-test-subcommand branch August 26, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants