Source commit: 6d1a121b0a8a636aac95998fe5d15c24c78eb7d0 Public tree identity: sha256:2bc22807f5b838286678b65d3f550b8ae4714ae673622041d4c2516a7c5b7926
86 lines
2.5 KiB
JavaScript
Executable file
86 lines
2.5 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
const assert = require("assert");
|
|
const cp = require("child_process");
|
|
const path = require("path");
|
|
const { configurePodmanTestEnvironment } = require("./podman-test-env");
|
|
|
|
const repo = path.resolve(__dirname, "..");
|
|
const baseImage = "docker.io/library/alpine:3.20";
|
|
|
|
// Nix's standalone Podman package may not install the distribution-level
|
|
// containers/image policy normally found under /etc. Use an isolated test HOME
|
|
// without replacing a policy supplied by the host.
|
|
configurePodmanTestEnvironment(repo);
|
|
|
|
function run(command, args, options = {}) {
|
|
return cp.execFileSync(command, args, {
|
|
cwd: repo,
|
|
encoding: "utf8",
|
|
stdio: options.stdio || ["ignore", "pipe", "pipe"],
|
|
});
|
|
}
|
|
|
|
function incomplete(reason) {
|
|
const error = new Error(`Linux Podman backend incomplete: ${reason}`);
|
|
error.code = "CLUSTERFLUX_PODMAN_INCOMPLETE";
|
|
throw error;
|
|
}
|
|
|
|
function ensurePodmanBaseImage() {
|
|
try {
|
|
run("podman", ["--version"]);
|
|
} catch (error) {
|
|
incomplete(`podman command is unavailable (${error.message})`);
|
|
}
|
|
|
|
let rootless;
|
|
try {
|
|
rootless = run("podman", ["info", "--format", "{{.Host.Security.Rootless}}"]).trim();
|
|
} catch (error) {
|
|
incomplete(`podman info did not report rootless status (${error.message})`);
|
|
}
|
|
if (rootless !== "true") {
|
|
incomplete(`podman is not running in rootless mode (reported ${JSON.stringify(rootless)})`);
|
|
}
|
|
|
|
try {
|
|
run("podman", ["image", "exists", baseImage]);
|
|
} catch (_) {
|
|
try {
|
|
run("podman", ["pull", baseImage], { stdio: "inherit" });
|
|
} catch (error) {
|
|
incomplete(`unable to make ${baseImage} available (${error.message})`);
|
|
}
|
|
}
|
|
}
|
|
|
|
try {
|
|
ensurePodmanBaseImage();
|
|
|
|
const stdout = run("cargo", [
|
|
"run",
|
|
"-q",
|
|
"-p",
|
|
"clusterflux-node",
|
|
"--bin",
|
|
"clusterflux-podman-smoke"
|
|
]);
|
|
const report = JSON.parse(stdout.trim().split("\n").at(-1));
|
|
|
|
assert.strictEqual(report.podman_status, "completed");
|
|
assert.strictEqual(report.status_code, 0);
|
|
assert.strictEqual(report.stdout, "podman-ok:node-local source\n");
|
|
assert.strictEqual(report.large_bytes_uploaded, false);
|
|
assert.strictEqual(report.uses_full_repo_tarball, false);
|
|
assert.strictEqual(report.coordinator_routed_file_reads, false);
|
|
assert.strictEqual(report.staged_artifact.path, "/vfs/artifacts/podman-smoke.txt");
|
|
|
|
console.log("Podman backend smoke passed");
|
|
} catch (error) {
|
|
if (error.code === "CLUSTERFLUX_PODMAN_INCOMPLETE") {
|
|
console.error(error.message);
|
|
process.exit(2);
|
|
}
|
|
throw error;
|
|
}
|