noise: repeat concurrent SSH verdict waiters test

Nothing signals that both waiters parked before FinishAuth, so one
pass mostly checks them one after the other.
This commit is contained in:
Kristoffer Dalby
2026-09-30 16:48:49 +00:00
committed by Kristoffer Dalby
parent c9992efaca
commit 97c4bf264e
+33 -26
View File
@@ -953,47 +953,54 @@ func TestSSHActionFollowUp_ConsumedVerdictNotReplayed(t *testing.T) {
// TestSSHActionFollowUp_ConcurrentWaiters parks two follow-ups on one // TestSSHActionFollowUp_ConcurrentWaiters parks two follow-ups on one
// session: exactly one may consume the verdict, the other re-decides. // session: exactly one may consume the verdict, the other re-decides.
// FinishAuth can land before either waiter parks and nothing signals the
// park, so the body repeats to exercise the both-parked order.
func TestSSHActionFollowUp_ConcurrentWaiters(t *testing.T) { func TestSSHActionFollowUp_ConcurrentWaiters(t *testing.T) {
t.Parallel() t.Parallel()
const iterations = 200
for _, tc := range sshVerdictCases { for _, tc := range sshVerdictCases {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
f := newSSHVerdictFixture(t) f := newSSHVerdictFixture(t)
authID, auth := f.mint(t)
var ( for range iterations {
wg sync.WaitGroup authID, auth := f.mint(t)
recs [2]*httptest.ResponseRecorder
)
for i := range recs { var (
wg.Go(func() { wg sync.WaitGroup
recs[i] = f.followUp(t, authID) recs [2]*httptest.ResponseRecorder
}) )
}
auth.FinishAuth(tc.verdict) for i := range recs {
wg.Wait() wg.Go(func() {
recs[i] = f.followUp(t, authID)
var carried, held int })
for _, rec := range recs {
action := sshActionFromRecorder(t, rec)
if carriesSSHVerdict(action, tc.accept) {
carried++
continue
} }
requireSSHHold(t, action) auth.FinishAuth(tc.verdict)
wg.Wait()
held++ var carried, held int
for _, rec := range recs {
action := sshActionFromRecorder(t, rec)
if carriesSSHVerdict(action, tc.accept) {
carried++
continue
}
requireSSHHold(t, action)
held++
}
require.Equal(t, 1, carried, "exactly one waiter must carry the verdict")
require.Equal(t, 1, held, "the other waiter must re-delegate")
} }
assert.Equal(t, 1, carried, "exactly one waiter must carry the verdict")
assert.Equal(t, 1, held, "the other waiter must re-delegate")
}) })
} }
} }