| … | … | @@ -41,7 +41,7 @@ test('reconcileBootstrapArtifacts tars bootstrap apps, symlinks install.sh, skip |
| 41 | 41 | mkAppTree(store.appsDir, 'hyper-tps', { bootstrap: false, treeHash: 'ccc' }) |
| 42 | 42 | |
| 43 | 43 | const calls = [] |
| 44 | | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar(calls), log: () => {} }) |
| 44 | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar(calls), log: () => {}, serveAllArches: true }) |
| 45 | 45 | |
| 46 | 46 | const dir = bootstrapDir(store) |
| 47 | 47 | t.is(res.tarred.length, 2, 'tarred the 2 bootstrap apps') |
| … | … | @@ -115,7 +115,7 @@ test('reconcileBootstrapArtifacts guards a malformed pghBootstrap.label (no doub |
| 115 | 115 | // a tree whose label is corrupted (baked-in stage name) |
| 116 | 116 | mkAppTree(store.appsDir, 'pgh-sidecar', { label: 'bootstrap-bare-linux-x64', treeHash: 'h1' }) |
| 117 | 117 | |
| 118 | | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 118 | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 119 | 119 | t.alike(res.tarred, ['pgh-sidecar-bootstrap-bare-linux-x64.tar.gz'], 'falls back to host label — no double infix') |
| 120 | 120 | }) |
| 121 | 121 | |
| … | … | @@ -172,7 +172,7 @@ test('reconcileBootstrapArtifacts promotes a vendored cross-arch tarball into th |
| 172 | 172 | const appDir = mkAppTree(store.appsDir, 'pgh', { label: 'linux-x64', treeHash: 'h1', installSh: true }) |
| 173 | 173 | const src = mkVendored(appDir, 'pgh', 'pgh-bootstrap-bare-linux-arm64.tar.gz', 'ARM64BYTES') |
| 174 | 174 | |
| 175 | | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 175 | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 176 | 176 | |
| 177 | 177 | const dir = bootstrapDir(store) |
| 178 | 178 | const arm = join(dir, 'pgh-bootstrap-bare-linux-arm64.tar.gz') |
| … | … | @@ -191,11 +191,11 @@ test('a promoted cross-arch tarball survives the prune pass', async (t) => { |
| 191 | 191 | mkVendored(appDir, 'pgh', 'pgh-bootstrap-bare-linux-arm64.tar.gz') |
| 192 | 192 | |
| 193 | 193 | const dir = bootstrapDir(store) |
| 194 | | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 194 | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 195 | 195 | t.ok(existsSync(join(dir, 'pgh-bootstrap-bare-linux-arm64.tar.gz')), 'present after first reconcile') |
| 196 | 196 | |
| 197 | 197 | // Second pass is where a non-wanted artifact would get pruned. |
| 198 | | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 198 | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 199 | 199 | t.absent(res.pruned.includes('pgh-bootstrap-bare-linux-arm64.tar.gz'), 'not pruned') |
| 200 | 200 | t.ok(existsSync(join(dir, 'pgh-bootstrap-bare-linux-arm64.tar.gz')), 'still served after re-reconcile') |
| 201 | 201 | }) |
| … | … | @@ -207,7 +207,7 @@ test('local tar wins for the host arch — a vendored same-label tarball never o |
| 207 | 207 | // a stale vendored tarball for OUR arch — must not shadow the fresh local tar |
| 208 | 208 | mkVendored(appDir, 'pgh', 'pgh-bootstrap-bare-linux-x64.tar.gz', 'STALE') |
| 209 | 209 | |
| 210 | | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 210 | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 211 | 211 | |
| 212 | 212 | const hostTb = join(bootstrapDir(store), 'pgh-bootstrap-bare-linux-x64.tar.gz') |
| 213 | 213 | t.not(readFileSync(hostTb, 'utf8'), 'STALE', 'host-arch tarball came from local tar, not the vendored copy') |
| … | … | @@ -225,7 +225,7 @@ test('promotes a vendored tarball carried by a NON-bootstrap app tree', async (t |
| 225 | 225 | const pgv3 = mkAppTree(store.appsDir, 'pear-git-v3', { bootstrap: false, treeHash: 'h2' }) |
| 226 | 226 | mkVendored(pgv3, 'pgh-sidecar', 'pgh-sidecar-bootstrap-bare-linux-arm64.tar.gz', 'SIDECAR-ARM64') |
| 227 | 227 | |
| 228 | | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 228 | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 229 | 229 | |
| 230 | 230 | const sc = join(bootstrapDir(store), 'pgh-sidecar-bootstrap-bare-linux-arm64.tar.gz') |
| 231 | 231 | t.ok(existsSync(sc), 'sidecar arm64 tarball served despite carrier not being a bootstrap app') |
| … | … | @@ -242,12 +242,12 @@ test('re-promotes when the vendored artifact is replaced underneath us', async ( |
| 242 | 242 | mkVendored(appDir, 'pgh', 'pgh-bootstrap-bare-linux-arm64.tar.gz', 'V1') |
| 243 | 243 | |
| 244 | 244 | const dir = bootstrapDir(store) |
| 245 | | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 245 | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 246 | 246 | t.is(readFileSync(join(dir, 'pgh-bootstrap-bare-linux-arm64.tar.gz'), 'utf8'), 'V1', 'v1 served') |
| 247 | 247 | |
| 248 | 248 | // new upstream version replaces the vendored file (new inode) |
| 249 | 249 | mkVendored(appDir, 'pgh', 'pgh-bootstrap-bare-linux-arm64.tar.gz', 'V2') |
| 250 | | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 250 | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 251 | 251 | t.is(readFileSync(join(dir, 'pgh-bootstrap-bare-linux-arm64.tar.gz'), 'utf8'), 'V2', 're-promoted, not stale') |
| 252 | 252 | }) |
| 253 | 253 | |
| … | … | @@ -260,7 +260,7 @@ test('promotes from the app\'s OWN dist/, which is where these artifacts really |
| 260 | 260 | writeFileSync(join(appDir, 'dist', 'pgh-bootstrap-bare-linux-arm64.tar.gz'), 'OWN-DIST') |
| 261 | 261 | writeFileSync(join(appDir, 'dist', 'pgh-bootstrap-bare-linux-arm64.tar.gz.sha256'), 'deadbeef') |
| 262 | 262 | |
| 263 | | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 263 | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 264 | 264 | |
| 265 | 265 | const dir = bootstrapDir(store) |
| 266 | 266 | t.is(readFileSync(join(dir, 'pgh-bootstrap-bare-linux-arm64.tar.gz'), 'utf8'), 'OWN-DIST', 'promoted from own dist/') |
| … | … | @@ -275,7 +275,7 @@ test('own dist/ wins over a vendored copy of the same tarball', async (t) => { |
| 275 | 275 | writeFileSync(join(appDir, 'dist', 'pgh-bootstrap-bare-linux-arm64.tar.gz'), 'CANONICAL') |
| 276 | 276 | mkVendored(appDir, 'somedep', 'pgh-bootstrap-bare-linux-arm64.tar.gz', 'STALE-VENDORED') |
| 277 | 277 | |
| 278 | | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 278 | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 279 | 279 | |
| 280 | 280 | const served = readFileSync(join(bootstrapDir(store), 'pgh-bootstrap-bare-linux-arm64.tar.gz'), 'utf8') |
| 281 | 281 | t.is(served, 'CANONICAL', 'own dist/ took precedence, not the vendored copy') |
| … | … | @@ -284,3 +284,38 @@ test('own dist/ wins over a vendored copy of the same tarball', async (t) => { |
| 284 | 284 | test('hostLabel returns os-arch', (t) => { |
| 285 | 285 | t.ok(/^[a-z0-9]+-[a-z0-9]+$/.test(hostLabel()), 'looks like <os>-<arch>') |
| 286 | 286 | }) |
| 287 | |
| 288 | // The opt-in itself. Promotion is a hardlink (no bytes), but SERVING a foreign |
| 289 | // arch is only useful on a machine that answers cold-start HTTPS /bootstrap |
| 290 | // fetches — a forge backend. Everyone else installs over hyper-deploy/overlay. |
| 291 | test('cross-arch promotion is OFF by default', async (t) => { |
| 292 | const root = mkdtempSync(join(tmpdir(), 'pgh-ba-optout-')) |
| 293 | const store = fakeStore(root); store.init() |
| 294 | const appDir = mkAppTree(store.appsDir, 'pgh', { label: 'linux-x64', treeHash: 'h1', installSh: true }) |
| 295 | mkVendored(appDir, 'pgh', 'pgh-bootstrap-bare-linux-arm64.tar.gz', 'ARM64') |
| 296 | |
| 297 | // no serveAllArches |
| 298 | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 299 | |
| 300 | const dir = bootstrapDir(store) |
| 301 | t.absent(existsSync(join(dir, 'pgh-bootstrap-bare-linux-arm64.tar.gz')), 'arm64 NOT promoted without opt-in') |
| 302 | t.ok(existsSync(join(dir, 'pgh-bootstrap-bare-linux-x64.tar.gz')), 'own arch still built') |
| 303 | t.absent(res.tarred.includes('pgh-bootstrap-bare-linux-arm64.tar.gz'), 'not reported as produced') |
| 304 | }) |
| 305 | |
| 306 | test('opting in promotes, and opting back out prunes what it promoted', async (t) => { |
| 307 | const root = mkdtempSync(join(tmpdir(), 'pgh-ba-toggle-')) |
| 308 | const store = fakeStore(root); store.init() |
| 309 | const appDir = mkAppTree(store.appsDir, 'pgh', { label: 'linux-x64', treeHash: 'h1', installSh: true }) |
| 310 | mkVendored(appDir, 'pgh', 'pgh-bootstrap-bare-linux-arm64.tar.gz', 'ARM64') |
| 311 | const arm = join(bootstrapDir(store), 'pgh-bootstrap-bare-linux-arm64.tar.gz') |
| 312 | |
| 313 | await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64', serveAllArches: true }) |
| 314 | t.ok(existsSync(arm), 'promoted while opted in') |
| 315 | |
| 316 | // Turning it off must actually stop serving it — the prune pass drops any |
| 317 | // tarball no longer in wantTarballs, which is what makes the toggle real. |
| 318 | const res = await reconcileBootstrapArtifacts(store, { tarTree: fakeTar([]), label: 'linux-x64' }) |
| 319 | t.ok(res.pruned.includes('pgh-bootstrap-bare-linux-arm64.tar.gz'), 'pruned on opt-out') |
| 320 | t.absent(existsSync(arm), 'no longer served') |
| 321 | }) |