Skip to content

Commit c39f33e

Browse files
authored
va: fix race in TestMultiVALogging (#7811)
1 parent 5e385e4 commit c39f33e

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

va/va_test.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,14 +605,29 @@ func TestMultiVALogging(t *testing.T) {
605605
test.AssertNotError(t, err, "performing validation")
606606

607607
// We do not log perspective or RIR for the local VAs.
608+
// We expect these log lines to be available immediately.
608609
test.Assert(t, len(vaLog.GetAllMatching(`"Perspective"`)) == 0, "expected no logged perspective for primary")
609610
test.Assert(t, len(vaLog.GetAllMatching(`"RIR"`)) == 0, "expected no logged RIR for primary")
610611

611612
// We do log perspective and RIR for the remote VAs.
612-
test.Assert(t, len(rva1Log.GetAllMatching(`"Perspective":"dev-arin"`)) == 1, "expected perspective of VA to be dev-arin")
613-
test.Assert(t, len(rva1Log.GetAllMatching(`"RIR":"ARIN"`)) == 1, "expected perspective of VA to be ARIN")
614-
test.Assert(t, len(rva2Log.GetAllMatching(`"Perspective":"dev-ripe"`)) == 1, "expected perspective of VA to be dev-ripe")
615-
test.Assert(t, len(rva2Log.GetAllMatching(`"RIR":"RIPE"`)) == 1, "expected perspective of VA to be RIPE")
613+
//
614+
// Because the remote VAs are operating on different goroutines, we aren't guaranteed their
615+
// log lines have arrived yet. Give it a few tries.
616+
for i := 0; i < 10; i++ {
617+
if len(rva1Log.GetAllMatching(`"Perspective":"dev-arin"`)) >= 1 &&
618+
len(rva1Log.GetAllMatching(`"RIR":"ARIN"`)) >= 1 &&
619+
len(rva2Log.GetAllMatching(`"Perspective":"dev-ripe"`)) >= 1 &&
620+
len(rva2Log.GetAllMatching(`"RIR":"RIPE"`)) >= 1 {
621+
break
622+
}
623+
if i == 9 {
624+
t.Logf("VA:\n%s\n", strings.Join(vaLog.GetAll(), "\n"))
625+
t.Logf("RVA 1:\n%s\n", strings.Join(rva1Log.GetAll(), "\n"))
626+
t.Logf("RVA 2:\n%s\n", strings.Join(rva2Log.GetAll(), "\n"))
627+
t.Errorf("expected perspective and RIR logs for remote VAs, but they never arrived")
628+
}
629+
time.Sleep(100 * time.Millisecond)
630+
}
616631
}
617632

618633
func TestDetailedError(t *testing.T) {

0 commit comments

Comments
 (0)