-
Notifications
You must be signed in to change notification settings - Fork 481
test(runtime-host): bound owned-Host lifecycle tests to kernel contracts #4814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bc509b7
test(runtime-host): bound owned-Host lifecycle tests to kernel contracts
ggbdpq e778e0e
Merge branch 'main' into fix/host-lifecycle-test-bounds
ggbdpq 0a2dad0
Merge remote-tracking branch 'upstream/main' into fix/host-lifecycle-…
ggbdpq b57ba2f
Merge remote-tracking branch 'upstream/main' into fix/host-lifecycle-…
ggbdpq a60a2df
test(runtime-host): pin the owner-loss recovery window and surface re…
ggbdpq 2ee447b
style(cli): collapse the recovery-wait call to one line
ggbdpq f6f239b
test(runtime-host): gate the owner-loss kill behind an explicit stall…
ggbdpq 1120762
style(runtime-host): collapse the stall assertion to Biome's single-l…
ggbdpq a0c4dba
Merge branch 'main' into fix/host-lifecycle-test-bounds
ggbdpq c10d35c
test(runtime-host): start the owner-loss exit budget at the guard-bin…
ggbdpq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/runtime-host/src/test-only/owned-candidate-gated-recovery-main.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/usr/bin/env node | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| /** | ||
| * Test-only Candidate entry for the owner-loss lifecycle tests. A | ||
| * launch-owner Client is admitted while the Host is still recovering, and | ||
| * the guard that closes the Host on owner loss binds only after startup | ||
| * returns — so whether the test's kill lands before or after the bind is a | ||
| * scheduling race a fixed sleep cannot decide. This entry instead gates | ||
| * composition creation behind a release file: writing the stall marker | ||
| * proves the Candidate is parked before the bind, the test kills the | ||
| * launcher at that point, and releasing the gate afterwards lets startup | ||
| * return promptly so the recorded loss closes the Host under the kernel's | ||
| * `shutdownGraceMs`. The run still goes through the real Runtime Host | ||
| * composition — only its start is held at the gate. The `onWon` hook adds | ||
| * the second boundary the test needs: a marker written right after the | ||
| * guard binds, so the exit budget starts at the bind rather than at the | ||
| * release, which only unblocks startup. | ||
| */ | ||
| import { existsSync, writeFileSync } from 'node:fs'; | ||
| import { dirname, join } from 'node:path'; | ||
| import { runExecutionCandidateEntry } from '../candidate-entry.js'; | ||
| import { createExecutionRuntimeHostComposition } from '../server/execution-composition.js'; | ||
|
|
||
| const rootArgumentIndex = process.argv.indexOf('--root') + 1; | ||
| const rootPath = process.argv[rootArgumentIndex]; | ||
| if (!rootPath) throw new Error('gated-recovery entry requires --root'); | ||
| const stallMarker = join(dirname(rootPath), 'authority-lease-probe.stalled'); | ||
| const releaseMarker = join(dirname(rootPath), 'authority-lease-probe.release'); | ||
| const boundMarker = join(dirname(rootPath), 'authority-lease-probe.bound'); | ||
|
|
||
| await runExecutionCandidateEntry(process.argv.slice(2), import.meta.url, { | ||
| // `onWon` fires right after the launch-owner guard binds (candidate-entry | ||
| // binds before invoking it), so this marker is the test's explicit | ||
| // guard-bound boundary: the pre-bind recorded loss starts acting only past | ||
| // it, which is where the exit budget under test actually begins. | ||
| onWon: () => { | ||
| writeFileSync(boundMarker, String(Date.now())); | ||
| return () => undefined; | ||
| }, | ||
| dependencies: { | ||
| createComposition: async (context, compositionOptions) => { | ||
| writeFileSync(stallMarker, String(Date.now())); | ||
| while (!existsSync(releaseMarker)) { | ||
| await new Promise((resolve) => setTimeout(resolve, 20)); | ||
| } | ||
| return createExecutionRuntimeHostComposition(context, compositionOptions); | ||
| }, | ||
| }, | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.