Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix(test): rebuild integration images from the qualifying checkout

pulse-triage[bot]69a129e39cfe
diff --git a/tests/integration/scripts/run-tests-images.test.mjs b/tests/integration/scripts/run-tests-images.test.mjs
new file mode 100644
index 0000000000..c8895f5b7e
--- /dev/null
+++ b/tests/integration/scripts/run-tests-images.test.mjs
@@ -0,0 +1,54 @@
+import assert from 'node:assert/strict';
+import { mkdtempSync, writeFileSync, readFileSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { spawnSync } from 'node:child_process';
+import { fileURLToPath } from 'node:url';
+import test from 'node:test';
+
+const runner = fileURLToPath(new URL('./run-tests.sh', import.meta.url));
+const repo = path.resolve(path.dirname(runner), '../../..');
+
+function run(failImage = '') {
+ const dir = mkdtempSync(path.join(tmpdir(), 'pulse-image-test-'));
+ const log = path.join(dir, 'calls');
+ try {
+ writeFileSync(path.join(dir, 'docker'), `#!/bin/bash
+printf '%s\\n' "$*" >> "$CALL_LOG"
+if [ "$1 $2" = 'compose version' ]; then exit 0; fi
+if [ "$1 $2" = 'image inspect' ]; then exit 0; fi
+if [ "$1" = build ]; then
+ [ "$3" != "$FAIL_IMAGE" ]
+ exit $?
+fi
+exit 91
+`, { mode: 0o755 });
+ const result = spawnSync('bash', [runner, failImage ? 'multi-tenant' : 'invalid-test-suite'], {
+ env: { ...process.env, PATH: `${dir}:${process.env.PATH}`, CALL_LOG: log, FAIL_IMAGE: failImage },
+ encoding: 'utf8',
+ });
+ return { ...result, calls: readFileSync(log, 'utf8').trim().split('\n') };
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+}
+
+test('rebuilds both test images from this checkout even when local tags exist', () => {
+ const result = run();
+ assert.equal(result.status, 1); // Deliberately unknown suite: never starts services.
+ assert.ok(result.stdout.includes('Unknown suite: invalid-test-suite'));
+ assert.deepEqual(result.calls.filter(call => call.startsWith('build ')), [
+ `build -t pulse-mock-github:test ${repo}/tests/integration/mock-github-server`,
+ `build -t pulse:test --build-arg GO_BUILD_TAGS= -f ${repo}/Dockerfile ${repo}`,
+ ]);
+});
+
+for (const image of ['pulse-mock-github:test', 'pulse:test']) {
+ test(`failed ${image} build cannot fall through to a cached image`, () => {
+ const result = run(image);
+ assert.equal(result.status, 1);
+ assert.ok(result.calls.some(call => call.startsWith(`build -t ${image} `)));
+ assert.ok(!result.calls.some(call => call.includes(' up ')));
+ assert.ok(!result.stdout.includes('Starting test environment'));
+ });
+}
diff --git a/tests/integration/scripts/run-tests.sh b/tests/integration/scripts/run-tests.sh
index 8519d45578..11bfa4cb04 100755
--- a/tests/integration/scripts/run-tests.sh
+++ b/tests/integration/scripts/run-tests.sh
@@ -37,17 +37,16 @@ compose() {
}
ensure_test_images() {
- if ! docker image inspect pulse-mock-github:test >/dev/null 2>&1; then
- echo "Building missing image: pulse-mock-github:test"
- docker build -t pulse-mock-github:test "$TEST_ROOT/mock-github-server"
- fi
-
- if ! docker image inspect pulse:test >/dev/null 2>&1; then
- echo "Building missing image: pulse:test"
- # Test image drops the release build tag so the suite can enable mock
- # fixtures without a demo entitlement.
- docker build -t pulse:test --build-arg GO_BUILD_TAGS="" -f "$REPO_ROOT/Dockerfile" "$REPO_ROOT"
- fi
+ # A local tag may belong to another checkout. Always build from these
+ # sources; Docker can reuse unchanged layers, but tag existence is not
+ # evidence that the image includes the code we are qualifying.
+ echo "Building test images from: $REPO_ROOT"
+ docker build -t pulse-mock-github:test "$TEST_ROOT/mock-github-server"
+
+ # Test image drops the release build tag so the suite can enable mock
+ # fixtures without a demo entitlement. A build failure must stop the run,
+ # never fall back to a previously tagged image.
+ docker build -t pulse:test --build-arg GO_BUILD_TAGS="" -f "$REPO_ROOT/Dockerfile" "$REPO_ROOT"
}
# Function to run suite with specific mock config