mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-10 08:40:07 +09:00
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:
committed by
Kristoffer Dalby
parent
c9992efaca
commit
97c4bf264e
+33
-26
@@ -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")
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user