Skip to content

Commit

Permalink
va: fix race in TestMultiVALogging (#7811)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsha authored Nov 14, 2024
1 parent 5e385e4 commit c39f33e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions va/va_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 +605,29 @@ func TestMultiVALogging(t *testing.T) {
test.AssertNotError(t, err, "performing validation")

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

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

func TestDetailedError(t *testing.T) {
Expand Down

0 comments on commit c39f33e

Please sign in to comment.