Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/scripts/pelican-complete-rounds.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export async function completeScheduledRounds(c) {
const tables = { account: 'scheduled_test_plans', group: 'pelican_group_test_plans' }

async function accountHistory(label, expected) {
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.goto(`${origin}/admin/accounts`)
const projections = []
for (const account of accounts) {
Expand Down Expand Up @@ -94,6 +96,8 @@ export async function completeScheduledRounds(c) {
async function groupHistory(label, expected) {
const listed = page.waitForResponse(response => new URL(response.url()).pathname === '/api/v1/admin/pelican-group-test-results'
&& response.request().method() === 'GET' && response.status() === 200)
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.goto(`${origin}/admin/pelican-tests`)
const response = await listed
const list = unwrap(await response.json())
Expand Down Expand Up @@ -271,6 +275,8 @@ export async function completeScheduledRounds(c) {

async function editAccount(mode) {
state.active_gate = `ui-edit-account-${mode}`
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.goto(`${origin}/admin/accounts`)
await openAccount(accounts[0])
await dialog().getByRole('button', { name: 'Scheduled tests', exact: true }).click()
Expand All @@ -297,6 +303,8 @@ export async function completeScheduledRounds(c) {
assert.deepEqual(stored.pelican_config, body.pelican_config)
await form.waitFor({ state: 'hidden' })
await dialog().getByRole('button', { name: 'Close modal', exact: true }).click()
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.reload()
await openAccount(accounts[0])
const listRead = page.waitForResponse(response => new URL(response.url()).pathname === `/api/v1/admin/accounts/${accounts[0].id}/scheduled-test-plans`
Expand All @@ -322,6 +330,8 @@ export async function completeScheduledRounds(c) {

async function editGroup(mode) {
state.active_gate = `ui-edit-group-${mode}`
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.goto(`${origin}/admin/pelican-tests`)
await page.getByTestId(`pelican-plan-edit-${groupPlanId}`).click()
const form = page.getByTestId('pelican-test-editor')
Expand All @@ -347,6 +357,8 @@ export async function completeScheduledRounds(c) {
await page.waitForLoadState('networkidle')
const listRead = page.waitForResponse(response => new URL(response.url()).pathname === '/api/v1/admin/pelican-group-tests'
&& response.request().method() === 'GET')
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.reload()
const listResponse = await listRead
assert.equal(listResponse.status(), 200)
Expand Down
12 changes: 12 additions & 0 deletions .github/scripts/pelican-question-e2e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ async function browser() {
prompt_mode: input.prompt_mode, pelican_question: input.pelican_question })
}
})
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.goto(`${origin}/login?redirect=/admin/accounts`)
await page.locator('#email').fill('reviewer@example.invalid')
await page.locator('#password').fill('Fixture-Only-795-Password!')
Expand Down Expand Up @@ -256,6 +258,8 @@ async function browser() {
assert.equal(state.requestFailures.length, 0, 'bootstrap transport must complete')
state.pageErrors = []
state.consoleErrors = []
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.reload()
await page.getByRole('row').filter({ hasText: accounts[0].name }).waitFor()
assert.ok(await page.locator('link[rel=stylesheet]').count(), 'real application CSS loaded')
Expand Down Expand Up @@ -374,6 +378,8 @@ async function browser() {
state.scenarios.push({ name: stage, status: 'passed', question_repetition_permitted: true })

stage = 'manual-localstorage-reload-history-dom'
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.reload()
assert.deepEqual((await readRecords(accounts[0]))[0], aRecord)
assert.deepEqual((await readRecords(accounts[1]))[0], bRecord)
Expand All @@ -394,6 +400,8 @@ async function browser() {
await detail.getByRole('button', { name: 'Close', exact: true }).click()
await panel.getByRole('button', { name: 'Close', exact: true }).click()
await dialog().getByRole('button', { name: 'Close modal', exact: true }).click()
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.goto(`${origin}/admin/pelican-tests`)
await page.getByTestId('pelican-tests-create').click()
const editor = page.getByTestId('pelican-test-editor')
Expand Down Expand Up @@ -424,6 +432,8 @@ async function browser() {
boundary: 'disabled creation only; no scheduled RunDue, /run or result acceptance claimed' })

stage = 'account-scheduled-ui-create-a-b'
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.goto(`${origin}/admin/accounts`)
const plans = []
const planProjection = plan => ({ id: String(plan.id), account_id: String(plan.account_id),
Expand Down Expand Up @@ -702,6 +712,8 @@ async function browser() {
}

stage = 'group-scheduled-ui-enable'
// Finish background metrics before deliberate document navigation; keep request failures strict.
await page.waitForLoadState('networkidle')
await page.goto(`${origin}/admin/pelican-tests`)
const groupPlanId = String(created.id)
const groupId = groups[0].id
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/issue817-manual-fencing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Issue817 manual request fencing

on:
push:
branches: [fix/issue817-ack-fencing-20261114]
pull_request:
paths:
- 'backend/internal/repository/account_quality.go'
- 'backend/internal/repository/scheduled_test_repo.go'
- 'backend/internal/repository/quality_manual_fencing_integration_test.go'
- 'backend/internal/service/scheduled_test_port.go'
- '.github/workflows/issue817-manual-fencing.yml'

permissions:
contents: read

concurrency:
group: issue817-manual-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
manual-fencing:
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
behavior: [red, green]
services:
postgres:
image: postgres:18.1-alpine3.23
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: sub2api_test
ports: ['5432:5432']
options: >-
--health-cmd "pg_isready -U postgres -d sub2api_test"
--health-interval 5s --health-timeout 5s --health-retries 12
redis:
image: redis:8.4-alpine
ports: ['6379:6379']
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s --health-timeout 5s --health-retries 12
env:
SUB2API_TEST_POSTGRES_DSN: 'host=127.0.0.1 port=5432 dbname=sub2api_test user=postgres password=postgres sslmode=disable TimeZone=UTC'
SUB2API_TEST_REDIS_URL: 'redis://127.0.0.1:6379/0'
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
path: ${{ matrix.behavior }}
- name: Record exact head and isolate baseline sources
working-directory: ${{ matrix.behavior }}
env:
EXPECTED_HEAD: ${{ github.event.pull_request.head.sha || github.sha }}
BEHAVIOR: ${{ matrix.behavior }}
shell: bash
run: |
set -euo pipefail
mkdir -p evidence
git rev-parse HEAD | tee evidence/head.txt
test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD"
if [ "$BEHAVIOR" = red ]; then
original=4189ed821d6e4308b2f5fc3791b73d2eb53cda8a
git fetch --no-tags --depth=1 origin "$original"
for source in backend/internal/repository/account_quality.go backend/internal/repository/scheduled_test_repo.go; do
git rev-parse "$original:$source" >> evidence/original-blobs.txt
git show "$original:$source" > "$source"
done
git diff --stat > evidence/red-source-diff.txt
else
git diff --exit-code
fi
- uses: actions/setup-go@v6
with:
go-version-file: ${{ matrix.behavior }}/backend/go.mod
cache-dependency-path: ${{ matrix.behavior }}/backend/go.sum
- name: Real worker and persisted manual requests with race detection
working-directory: ${{ matrix.behavior }}
env:
CI: 'true'
BEHAVIOR: ${{ matrix.behavior }}
shell: bash
run: |
set -euo pipefail
pattern='^(TestIssue817ManualWorkerInterleaving|TestIssue817ManualUpdateInterleaving)$'
required=(TestIssue817ManualWorkerInterleaving TestIssue817ManualUpdateInterleaving)
if [ "$BEHAVIOR" = green ]; then
required+=(TestIssue817ManualGenerationAndLeaseFencing TestIssue817QuotaSkipPreservesPending5xxExecution TestIssue817QuotaSkipPreserves401AndOwnership TestIssue817QuotaSkipRetainsActualIsolationOwnership TestIssue817ManualTriggerIsOneShotAndLeaseFenced TestQuality5xxClaimKeepsCronAndCoalescesScheduledRun TestQuality5xxFinishConsumesCrossedCronWithoutOverwritingEdits TestQualityRetestRestBlocksEveryClaimUntilDeadline)
pattern='^(TestIssue817|TestQuality5xxClaimKeepsCronAndCoalescesScheduledRun|TestQuality5xxFinishConsumesCrossedCronWithoutOverwritingEdits|TestQualityRetestRestBlocksEveryClaimUntilDeadline)'
fi
set +e
bash .github/scripts/issue817-race-gate.sh "$BEHAVIOR" "$PWD" "$pattern" > evidence/manual-fencing.log 2>&1
result=$?
set -e
cat evidence/manual-fencing.log
test "$(cat evidence/binary-identity-ok.txt)" = passed
if grep -Eiq 'no tests to run|--- SKIP:|panic:|WARNING: DATA RACE|race detected during execution|segmentation fault|SIGSEGV|\[build failed\]' evidence/manual-fencing.log; then
exit 1
fi
if [ "$BEHAVIOR" = red ]; then
test "$result" -eq 1
for name in "${required[@]}"; do
grep -F -- "--- FAIL: $name (" evidence/manual-fencing.log
done
grep -F '5xx worker must not consume a pending manual request with substituted configuration' evidence/manual-fencing.log
grep -F 'configuration save must preserve the newer pending manual request' evidence/manual-fencing.log
else
test "$result" -eq 0
for name in "${required[@]}"; do
grep -F -- "--- PASS: $name (" evidence/manual-fencing.log
done
for child in never_run previous_completed_run; do
grep -F -- "--- PASS: TestIssue817QuotaSkipPreservesPending5xxExecution/$child (" evidence/manual-fencing.log
done
fi
- uses: actions/upload-artifact@v7
if: always()
with:
name: issue817-manual-${{ matrix.behavior }}-${{ github.event_name }}-${{ github.run_id }}
path: ${{ matrix.behavior }}/evidence/
if-no-files-found: error
2 changes: 1 addition & 1 deletion backend/internal/repository/account_quality.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (r *scheduledTestPlanRepository) ListQualityPlans(ctx context.Context) ([]*
}
func (r *scheduledTestPlanRepository) TriggerQuality(ctx context.Context, id int64) error {
result, err := r.db.ExecContext(ctx, `UPDATE scheduled_test_plans SET next_run_at=NOW(), updated_at=NOW(),
pelican_config=jsonb_set(pelican_config, '{_manual_quality_run}', 'true'::jsonb)
pelican_config=pelican_config || jsonb_build_object('_manual_quality_run',true,'_manual_quality_run_id',gen_random_uuid()::text)
WHERE id=$1 AND enabled AND pelican_config->'quality' IS NOT NULL AND (running_until IS NULL OR running_until<NOW())
AND NOT EXISTS (SELECT 1 FROM account_quality_states rest WHERE rest.plan_id=scheduled_test_plans.id
AND COALESCE((pelican_config->'quality'->>'retest_rest_minutes')::int,0)>0
Expand Down
4 changes: 2 additions & 2 deletions backend/internal/repository/pelican_scheduled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ func TestPelicanClaimUsesDatabaseLeaseAndSavedVersion(t *testing.T) {
query := `(?s)UPDATE scheduled_test_plans.*enabled = true.*running_until IS NULL.*updated_at = \$5.*deleted_at IS NULL`
mock.ExpectBegin()
mock.ExpectQuery("SELECT pg_try_advisory_xact_lock").WithArgs(plan.AccountID).WillReturnRows(sqlmock.NewRows([]string{"locked"}).AddRow(true))
mock.ExpectExec(query).WithArgs(plan.ID, now, until, next, plan.UpdatedAt, nil, false, nil).WillReturnResult(sqlmock.NewResult(0, 1))
mock.ExpectQuery(query).WithArgs(plan.ID, now, until, next, plan.UpdatedAt, nil, false, nil, false, "").WillReturnRows(sqlmock.NewRows([]string{"manual_quality_run", "manual_quality_run_id"}).AddRow(false, ""))
mock.ExpectCommit()
ok, err := repo.ClaimPelican(context.Background(), plan, now, until, next)
require.NoError(t, err)
require.True(t, ok)
mock.ExpectBegin()
mock.ExpectQuery("SELECT pg_try_advisory_xact_lock").WithArgs(plan.AccountID).WillReturnRows(sqlmock.NewRows([]string{"locked"}).AddRow(true))
mock.ExpectExec(query).WithArgs(plan.ID, now, until, next, plan.UpdatedAt, nil, false, nil).WillReturnResult(sqlmock.NewResult(0, 0))
mock.ExpectQuery(query).WithArgs(plan.ID, now, until, next, plan.UpdatedAt, nil, false, nil, false, "").WillReturnRows(sqlmock.NewRows([]string{"manual_quality_run", "manual_quality_run_id"}))
mock.ExpectCommit()
ok, err = repo.ClaimPelican(context.Background(), plan, now, until, next)
require.NoError(t, err)
Expand Down
Loading
Loading