From 9482961b1cfd2e72200edddf7b015e8ba4ee5169 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 20 Jul 2020 18:20:02 -0400 Subject: [PATCH 1/2] stream: handle empty event in TestEventSnapshot When the race detector is enabled we see this test fail occasionally. The reordering of execution seems to make it possible for the snapshot splice to happen before any events are published to the topicBuffers. We can handle this case in the test the same way it is handled by a subscription, by proceeding to the next event. --- agent/consul/stream/event_snapshot_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/agent/consul/stream/event_snapshot_test.go b/agent/consul/stream/event_snapshot_test.go index a11be78551..5e62e7f94f 100644 --- a/agent/consul/stream/event_snapshot_test.go +++ b/agent/consul/stream/event_snapshot_test.go @@ -121,6 +121,12 @@ func TestEventSnapshot(t *testing.T) { require.NoError(t, err, "current state: snapDone=%v snapIDs=%s updateIDs=%s", snapDone, snapIDs, updateIDs) + if len(curItem.Events) == 0 { + // An item without an error or events is a bufferItem.NextLink event. + // A subscription handles this by proceeding to the next item, + // so we do the same here. + continue + } e := curItem.Events[0] switch { case snapDone: From 48435511251c72bc91f8c8b08dac4e119c60c683 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 20 Jul 2020 18:34:45 -0400 Subject: [PATCH 2/2] ci: Add jsonfile artifact for go-test-race So that we can better debug failures --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 22237f1d2b..5a91e03627 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -154,9 +154,10 @@ jobs: - run: name: go test -race command: | - mkdir -p $TEST_RESULTS_DIR + mkdir -p $TEST_RESULTS_DIR /tmp/jsonfile gotestsum \ --format=short-verbose \ + --jsonfile /tmp/jsonfile/go-test-race.log \ --junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \ -tags="$GOTAGS" -p 2 \ -race -gcflags=all=-d=checkptr=0 \ @@ -168,6 +169,8 @@ jobs: path: *TEST_RESULTS_DIR - store_artifacts: path: *TEST_RESULTS_DIR + - store_artifacts: + path: /tmp/jsonfile # split off a job for the API package since it is separate go-test-api: