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.

Make managed hot-dev verification deterministic

rcourtman91d7102a2743
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index d1842365c7..eabb9e3575 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -177,6 +177,11 @@ server-side update execution surfaces.
deterministic token authentication after setup, and may use the server setup
API as a fallback only when the UI wizard fails to complete cleanly under the
managed hot-dev runtime.
+ Managed browser verification must also restart an existing hot-dev session
+ when a verification lock is active or the runtime auth file no longer matches
+ the deterministic dev user/hash. `tests/integration/scripts/run-playwright.mjs`
+ owns the run-scoped `HOT_DEV_VERIFY_LOCK_FILE` handoff so overlapping browser
+ proof cannot reuse stale first-run credentials.
6. Add or change governed release-promotion workflow inputs, operator-facing promotion metadata, the canonical version file, prerelease feedback intake prompts, artifact publication lineage enforcement, release note or changelog packet composition, or stable-promotion rehearsal summaries through `.github/workflows/create-release.yml`, `.github/workflows/helm-pages.yml`, `.github/workflows/publish-docker.yml`, `.github/workflows/publish-helm-chart.yml`, `.github/workflows/promote-floating-tags.yml`, `.github/workflows/release-dry-run.yml`, `.github/workflows/update-demo-server.yml`, `.github/ISSUE_TEMPLATE/v6_rc_feedback.yml`, `docs/RELEASE_NOTES.md`, `docs/releases/`, `docs/release-control/v6/internal/RELEASE_PROMOTION_POLICY.md`, `docs/release-control/v6/internal/PRE_RELEASE_CHECKLIST.md`, `docs/release-control/v6/internal/RC_TO_GA_REHEARSAL_TEMPLATE.md`, `scripts/check-workflow-dispatch-inputs.py`, `scripts/release_control/render_release_body.py`, `scripts/release_control/record_rc_to_ga_rehearsal.py`, `scripts/release_control/internal/record_rc_to_ga_rehearsal.py`, `scripts/release_control/release_promotion_policy_support.py`, `scripts/trigger-release.sh`, and `scripts/trigger-release-dry-run.sh`
That release-promotion boundary also owns prerelease note packet lineage:
shipped RC notes must remain historically accurate, the top-level
diff --git a/tests/integration/scripts/managed-dev-runtime.mjs b/tests/integration/scripts/managed-dev-runtime.mjs
index d389ce594d..c4158cff85 100644
--- a/tests/integration/scripts/managed-dev-runtime.mjs
+++ b/tests/integration/scripts/managed-dev-runtime.mjs
@@ -9,6 +9,8 @@ const truthy = (value) =>
['1', 'true', 'yes', 'on'].includes(String(value || '').trim().toLowerCase());
const trim = (value) => String(value || '').trim();
+const HOT_DEV_DEFAULT_AUTH_USER = 'admin';
+const HOT_DEV_DEFAULT_AUTH_HASH = '$2a$12$J/Vu6FlBUJDTK.VAkysjB.AnvFOcijDbETyumhCB.nJVes5gvpiI6';
function repoRootFromEnv(env = process.env) {
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
@@ -35,6 +37,63 @@ function hotDevBackendURL(env = process.env) {
return `http://${host}:${port}`;
}
+function hotDevRuntimeEnvPath(env = process.env) {
+ return path.join(repoRootFromEnv(env), 'tmp', 'dev-config', '.env');
+}
+
+function unquoteDotEnvValue(value) {
+ const trimmed = trim(value);
+ if (
+ (trimmed.startsWith("'") && trimmed.endsWith("'")) ||
+ (trimmed.startsWith('"') && trimmed.endsWith('"'))
+ ) {
+ return trimmed.slice(1, -1);
+ }
+ return trimmed;
+}
+
+function readHotDevRuntimeAuth(env = process.env) {
+ try {
+ const contents = fs.readFileSync(hotDevRuntimeEnvPath(env), 'utf8');
+ const auth = {};
+ for (const line of contents.split(/\r?\n/)) {
+ const trimmed = line.trim();
+ if (!trimmed || trimmed.startsWith('#')) {
+ continue;
+ }
+ const separator = trimmed.indexOf('=');
+ if (separator === -1) {
+ continue;
+ }
+ auth[trimmed.slice(0, separator).trim()] = unquoteDotEnvValue(
+ trimmed.slice(separator + 1),
+ );
+ }
+ return {
+ user: trim(auth.PULSE_AUTH_USER),
+ pass: trim(auth.PULSE_AUTH_PASS),
+ };
+ } catch {
+ return null;
+ }
+}
+
+function hotDevDesiredRuntimeAuth(env = process.env) {
+ return {
+ user: trim(env.HOT_DEV_AUTH_USER) || HOT_DEV_DEFAULT_AUTH_USER,
+ pass: trim(env.HOT_DEV_AUTH_PASS) || HOT_DEV_DEFAULT_AUTH_HASH,
+ };
+}
+
+function managedRuntimeAuthMatchesDesired(env = process.env) {
+ const currentAuth = readHotDevRuntimeAuth(env);
+ if (!currentAuth) {
+ return false;
+ }
+ const desiredAuth = hotDevDesiredRuntimeAuth(env);
+ return currentAuth.user === desiredAuth.user && currentAuth.pass === desiredAuth.pass;
+}
+
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
@@ -91,7 +150,10 @@ export function shouldRestartManagedDevRuntimeForVerification({
env = process.env,
wasRunning,
}) {
- return Boolean(wasRunning) && managedVerifyLockActive(env);
+ if (!wasRunning) {
+ return false;
+ }
+ return managedVerifyLockActive(env) || !managedRuntimeAuthMatchesDesired(env);
}
async function managedRuntimeStatusOutput(env = process.env) {
@@ -184,7 +246,7 @@ async function ensureHealthyStatus(env = process.env) {
async function waitForStableManagedRuntime({
env = process.env,
- timeoutMs = 60_000,
+ timeoutMs = 180_000,
sampleIntervalMs = 2_000,
requiredStableSamples = 2,
} = {}) {
diff --git a/tests/integration/scripts/managed-dev-runtime.test.mjs b/tests/integration/scripts/managed-dev-runtime.test.mjs
index 70ade3ce55..4669b2f4e7 100644
--- a/tests/integration/scripts/managed-dev-runtime.test.mjs
+++ b/tests/integration/scripts/managed-dev-runtime.test.mjs
@@ -25,7 +25,7 @@ test('managedVerifyLockActive clears false when the verify lock owner is stale',
assert.equal(managedVerifyLockActive({ HOT_DEV_VERIFY_LOCK_FILE: lockPath }), false);
});
-test('shouldRestartManagedDevRuntimeForVerification only restarts existing sessions under verify lock', async () => {
+test('shouldRestartManagedDevRuntimeForVerification restarts existing sessions under verify lock', async () => {
const rootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'pulse-managed-dev-runtime-'));
const lockPath = path.join(rootDir, 'hot-dev.verify.lock');
await fs.writeFile(lockPath, `pid=${process.pid}\ncreated_at=2026-03-28T23:00:00Z\n`, 'utf8');
@@ -45,3 +45,55 @@ test('shouldRestartManagedDevRuntimeForVerification only restarts existing sessi
false,
);
});
+
+test('shouldRestartManagedDevRuntimeForVerification restarts existing sessions with non-deterministic auth', async () => {
+ const rootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'pulse-managed-dev-runtime-'));
+ const envPath = path.join(rootDir, 'tmp', 'dev-config', '.env');
+ await fs.mkdir(path.dirname(envPath), { recursive: true });
+
+ const env = { PULSE_E2E_REPO_ROOT: rootDir };
+
+ assert.equal(
+ shouldRestartManagedDevRuntimeForVerification({
+ env,
+ wasRunning: true,
+ }),
+ true,
+ );
+
+ await fs.writeFile(
+ envPath,
+ [
+ '# Managed by hot-dev.sh for deterministic dev auth',
+ "PULSE_AUTH_USER='admin'",
+ "PULSE_AUTH_PASS='$2a$12$J/Vu6FlBUJDTK.VAkysjB.AnvFOcijDbETyumhCB.nJVes5gvpiI6'",
+ '',
+ ].join('\n'),
+ 'utf8',
+ );
+ assert.equal(
+ shouldRestartManagedDevRuntimeForVerification({
+ env,
+ wasRunning: true,
+ }),
+ false,
+ );
+
+ await fs.writeFile(
+ envPath,
+ [
+ '# Auto-generated by Pulse Quick Security Setup',
+ "PULSE_AUTH_USER='setup-user'",
+ "PULSE_AUTH_PASS='$2a$12$setupgeneratedauthhashvalue'",
+ '',
+ ].join('\n'),
+ 'utf8',
+ );
+ assert.equal(
+ shouldRestartManagedDevRuntimeForVerification({
+ env,
+ wasRunning: true,
+ }),
+ true,
+ );
+});
diff --git a/tests/integration/scripts/run-playwright.mjs b/tests/integration/scripts/run-playwright.mjs
index dfe735e6c3..d53a57b7e0 100644
--- a/tests/integration/scripts/run-playwright.mjs
+++ b/tests/integration/scripts/run-playwright.mjs
@@ -14,11 +14,14 @@ const repoRoot = path.resolve(__dirname, '..', '..');
function buildRunScopedEnv(env = process.env) {
const configuredRuntimeStatePath = String(env.PULSE_E2E_RUNTIME_STATE_PATH || '').trim();
const configuredRunId = String(env.PULSE_E2E_RUN_ID || '').trim();
+ const configuredVerifyLockPath = String(env.HOT_DEV_VERIFY_LOCK_FILE || '').trim();
if (configuredRuntimeStatePath !== '') {
return {
...env,
PULSE_E2E_RUN_ID:
configuredRunId || path.basename(configuredRuntimeStatePath).replace(/\.[^.]+$/, ''),
+ HOT_DEV_VERIFY_LOCK_FILE:
+ configuredVerifyLockPath || path.join(repoRoot, 'tmp', 'hot-dev.verify.lock'),
};
}
@@ -27,6 +30,8 @@ function buildRunScopedEnv(env = process.env) {
...env,
PULSE_E2E_RUN_ID: String(env.PULSE_E2E_RUN_ID || runId).trim(),
PULSE_E2E_RUNTIME_STATE_PATH: path.join(repoRoot, 'tmp', `${runId}.runtime-state.json`),
+ HOT_DEV_VERIFY_LOCK_FILE:
+ configuredVerifyLockPath || path.join(repoRoot, 'tmp', 'hot-dev.verify.lock'),
};
}
diff --git a/tests/integration/tests/16-dev-runtime-recovery.spec.ts b/tests/integration/tests/16-dev-runtime-recovery.spec.ts
index 2cb2351c91..b889b69683 100644
--- a/tests/integration/tests/16-dev-runtime-recovery.spec.ts
+++ b/tests/integration/tests/16-dev-runtime-recovery.spec.ts
@@ -59,7 +59,9 @@ test.describe.serial('Managed dev runtime recovery', () => {
await expect(page).toHaveURL(/\/settings\/infrastructure\?add=pick$/);
await expect(page.getByRole('dialog', { name: 'Add infrastructure' })).toBeVisible();
- const setupToken = String(readRuntimeState()?.primaryAPIToken || '').trim();
+ const runtimeState = readRuntimeState();
+ const setupToken = String(runtimeState?.primaryAPIToken || '').trim();
+ expect(String(runtimeState?.baseURL || '').trim().length).toBeGreaterThan(0);
expect(
setupToken.length,
'expected first-session helper to persist the handoff API token to runtime state',
diff --git a/tests/integration/tests/runtime-defaults.ts b/tests/integration/tests/runtime-defaults.ts
index db3117d193..4874371d19 100644
--- a/tests/integration/tests/runtime-defaults.ts
+++ b/tests/integration/tests/runtime-defaults.ts
@@ -13,7 +13,7 @@ const trim = (value: unknown): string => String(value ?? '').trim();
const firstNonEmpty = (...values: readonly unknown[]): string =>
values.map(trim).find((value) => value !== '') || '';
-const repoRootFromEnv = (env: NodeJS.ProcessEnv = process.env): string =>
+export const repoRootFromEnv = (env: NodeJS.ProcessEnv = process.env): string =>
trim(env.PULSE_E2E_REPO_ROOT) || path.resolve(__dirname, '..', '..', '..');
const managedHotDevPidPath = (env: NodeJS.ProcessEnv = process.env): string =>