From 0a69fca6574d421c3bdbc97f120b33b5e2e8946e Mon Sep 17 00:00:00 2001 From: Travis Date: Thu, 14 Nov 2019 23:15:51 -0600 Subject: [PATCH] allow for translate store race in test (by using retry) In this case, the test is reading from the translateStore replica before the translateStore replication has had time to deliver its log to the replica. The only way to truly address this in the translate store would be to route all key misses that happen on a read-only replica to the primary translate store (or somehow know when the primary is done sending to replicas) for actual verification that the key does not exist. That's more involved than we want to do here; this PR just addresses the problem in the test. --- api_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api_test.go b/api_test.go index fafae614f..d412def1a 100644 --- a/api_test.go +++ b/api_test.go @@ -175,10 +175,15 @@ func TestAPI_Import(t *testing.T) { } // Query node1. - if res, err := m1.API.Query(ctx, &pilosa.QueryRequest{Index: index, Query: pql}); err != nil { + if err := test.RetryUntil(5*time.Second, func() error { + if res, err := m1.API.Query(ctx, &pilosa.QueryRequest{Index: index, Query: pql}); err != nil { + return err + } else if columns := res.Results[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, colIDs) { + return fmt.Errorf("unexpected column ids: %+v", columns) + } + return nil + }); err != nil { t.Fatal(err) - } else if columns := res.Results[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, colIDs) { - t.Fatalf("unexpected column ids: %+v", columns) } }) }