From fdfc9bcdd24f6861353a41b0cd630c7d82e1f868 Mon Sep 17 00:00:00 2001 From: Steve Greene Date: Tue, 11 May 2021 03:11:20 -0400 Subject: [PATCH] test: Fix rare race condition in TestZoneReload (#4617) The following test failure for `TestZoneReload` can be observed periodically: `file_reload_test.go:58: Expected two RR in answer section got 2` This failure can be consistently reproduced using the following command (on my machine, at least): `( cd test ; go test -v -race -run "TestZoneReload" ./... -count=500)` test/file_reload_test.go: Address a typo in a test failure message. Sleep for double the file reload interval to avoid a rare race condition between test code and the file plugin's reload code, which is presumably a result of the time it takes to actually reload. Signed-off-by: Stephen Greene --- test/file_reload_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/file_reload_test.go b/test/file_reload_test.go index 95cc860bb..69b9af5f6 100644 --- a/test/file_reload_test.go +++ b/test/file_reload_test.go @@ -47,7 +47,7 @@ func TestZoneReload(t *testing.T) { // Remove RR from the Apex ioutil.WriteFile(name, []byte(exampleOrgUpdated), 0644) - time.Sleep(10 * time.Millisecond) // reload time + time.Sleep(20 * time.Millisecond) // reload time, with some race insurance resp, err = dns.Exchange(m, udp) if err != nil { @@ -55,7 +55,7 @@ func TestZoneReload(t *testing.T) { } if len(resp.Answer) != 1 { - t.Fatalf("Expected two RR in answer section got %d", len(resp.Answer)) + t.Fatalf("Expected one RR in answer section got %d", len(resp.Answer)) } }