Skip to content

Commit b963602

Browse files
committed
Assert distro-specific probes in integration matrix tests
1 parent 28883c0 commit b963602

3 files changed

Lines changed: 57 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,29 @@ jobs:
4040
include:
4141
- distro: alpine
4242
image: alpine:3.20
43+
probe_path: /etc/alpine-release
44+
probe_command: cat /etc/alpine-release
45+
probe_expect: "3.20"
4346
- distro: debian
4447
image: debian:bookworm-slim
48+
probe_path: /etc/debian_version
49+
probe_command: cat /etc/debian_version
50+
probe_expect: "12"
4551
- distro: ubuntu
4652
image: ubuntu:24.04
53+
probe_path: /etc/os-release
54+
probe_command: . /etc/os-release; echo "$ID:$VERSION_ID"
55+
probe_expect: ubuntu:24.04
4756
- distro: fedora
4857
image: fedora:41
58+
probe_path: /etc/fedora-release
59+
probe_command: cat /etc/fedora-release
60+
probe_expect: "Fedora release 41"
4961
- distro: archlinux
5062
image: archlinux:latest
63+
probe_path: /etc/os-release
64+
probe_command: . /etc/os-release; echo "$ID"
65+
probe_expect: arch
5166
name: integration-tests (${{ matrix.distro }})
5267

5368
steps:
@@ -71,9 +86,9 @@ jobs:
7186
env:
7287
INTEGRATION_PLATFORM: linux/amd64
7388
INTEGRATION_IMAGE: ${{ matrix.image }}
74-
INTEGRATION_ROOTFS_CHECK_PATH: /bin/sh
75-
INTEGRATION_VM_CHECK_COMMAND: echo integration-vm-ok
76-
INTEGRATION_VM_CHECK_EXPECT: integration-vm-ok
89+
INTEGRATION_ROOTFS_CHECK_PATH: ${{ matrix.probe_path }}
90+
INTEGRATION_VM_CHECK_COMMAND: ${{ matrix.probe_command }}
91+
INTEGRATION_VM_CHECK_EXPECT: ${{ matrix.probe_expect }}
7792
run: bun run test:integration
7893

7994
e2e-smoke:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ The CI integration matrix currently validates:
8888
- `fedora:41`
8989
- `archlinux:latest`
9090

91+
For each distro row, tests run a distro-specific probe command (for example `/etc/debian_version`, `/etc/fedora-release`, etc.) and also assert that probe does **not** match on the base Gondolin guest image.
92+
9193
### Choosing the build platform (`--platform`)
9294

9395
`--platform` selects which OCI image variant to convert, and should match the architecture you plan to run in Gondolin.

test/integration/oci2gondolin.integration.test.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ type CommandOptions = {
2020
};
2121

2222
const REPO_ROOT = process.cwd();
23-
const IMAGE = process.env.INTEGRATION_IMAGE ?? "busybox:latest";
23+
const IMAGE = process.env.INTEGRATION_IMAGE ?? "debian:bookworm-slim";
2424
const PLATFORM = resolveIntegrationPlatform(process.env.INTEGRATION_PLATFORM ?? process.arch);
25-
const ROOTFS_CHECK_PATH = process.env.INTEGRATION_ROOTFS_CHECK_PATH ?? "/bin/sh";
26-
const VM_CHECK_COMMAND = process.env.INTEGRATION_VM_CHECK_COMMAND ?? "echo integration-vm-ok";
27-
const VM_CHECK_EXPECT = process.env.INTEGRATION_VM_CHECK_EXPECT ?? "integration-vm-ok";
25+
const ROOTFS_CHECK_PATH = process.env.INTEGRATION_ROOTFS_CHECK_PATH ?? "/etc/debian_version";
26+
const VM_CHECK_COMMAND = process.env.INTEGRATION_VM_CHECK_COMMAND ?? "cat /etc/debian_version";
27+
const VM_CHECK_EXPECT = process.env.INTEGRATION_VM_CHECK_EXPECT ?? "12";
2828

2929
const imageSlug = IMAGE.replace(/[^a-z0-9._-]+/gi, "-").toLowerCase();
3030
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), `docker2vm-integration-${imageSlug}-`));
@@ -140,6 +140,8 @@ describe("oci2gondolin integration", () => {
140140
const originalGuestDir = process.env.GONDOLIN_GUEST_DIR;
141141
const vmSandbox = resolveVmSandboxOptions();
142142

143+
await assertProbeMissingFromBaseImage(vmSandbox, originalGuestDir);
144+
143145
let vm: VM | null = null;
144146
try {
145147
process.env.GONDOLIN_GUEST_DIR = assetsOutDir;
@@ -194,6 +196,37 @@ function resolveVmSandboxOptions(): { accel?: "tcg"; cpu?: "max" } | undefined {
194196
}
195197
}
196198

199+
async function assertProbeMissingFromBaseImage(
200+
vmSandbox: { accel?: "tcg"; cpu?: "max" } | undefined,
201+
originalGuestDir: string | undefined,
202+
): Promise<void> {
203+
let vm: VM | null = null;
204+
205+
try {
206+
if (originalGuestDir === undefined) {
207+
delete process.env.GONDOLIN_GUEST_DIR;
208+
} else {
209+
process.env.GONDOLIN_GUEST_DIR = originalGuestDir;
210+
}
211+
212+
vm = await VM.create({ sandbox: vmSandbox });
213+
const baseResult = await vm.exec(["/bin/sh", "-lc", VM_CHECK_COMMAND]);
214+
215+
expect(baseResult.stdout).not.toContain(VM_CHECK_EXPECT);
216+
expect(baseResult.stderr).not.toContain(VM_CHECK_EXPECT);
217+
} finally {
218+
await vm?.close().catch(() => {
219+
// ignore close errors in test teardown
220+
});
221+
222+
if (originalGuestDir === undefined) {
223+
delete process.env.GONDOLIN_GUEST_DIR;
224+
} else {
225+
process.env.GONDOLIN_GUEST_DIR = originalGuestDir;
226+
}
227+
}
228+
}
229+
197230
function requireBinary(binary: string, fallbacks: string[] = []): string {
198231
const candidates = [binary, ...fallbacks];
199232

0 commit comments

Comments
 (0)