test: Fix badly formatted retry.Run tests

This commit is contained in:
Frank Schroeder 2017-05-05 12:14:43 +02:00
parent c3d6814149
commit 2794db5aac
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
5 changed files with 141 additions and 172 deletions

View File

@ -318,12 +318,9 @@ func TestEventList_EventBufOrder(t *testing.T) {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
} }
retry.
// Test that the event order is preserved when name // Test that the event order is preserved when name
// filtering on a list of > 1 matching event. // filtering on a list of > 1 matching event.
Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
url := "/v1/event/list?name=foo" url := "/v1/event/list?name=foo"
req, err := http.NewRequest("GET", url, nil) req, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {
@ -342,7 +339,6 @@ func TestEventList_EventBufOrder(t *testing.T) {
r.Fatalf("bad: %#v", list) r.Fatalf("bad: %#v", list)
} }
}) })
}) })
} }

View File

@ -167,11 +167,8 @@ func TestHealthChecksInState_DistanceSort(t *testing.T) {
if err := srv.agent.RPC("Coordinate.Update", &arg, &out); err != nil { if err := srv.agent.RPC("Coordinate.Update", &arg, &out); err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
retry.
// Retry until foo moves to the front of the line. // Retry until foo moves to the front of the line.
Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
resp = httptest.NewRecorder() resp = httptest.NewRecorder()
obj, err = srv.HealthChecksInState(resp, req) obj, err = srv.HealthChecksInState(resp, req)
if err != nil { if err != nil {
@ -189,7 +186,6 @@ func TestHealthChecksInState_DistanceSort(t *testing.T) {
r.Fatalf("bad: %v", nodes) r.Fatalf("bad: %v", nodes)
} }
}) })
} }
func TestHealthNodeChecks(t *testing.T) { func TestHealthNodeChecks(t *testing.T) {
@ -428,11 +424,8 @@ func TestHealthServiceChecks_DistanceSort(t *testing.T) {
if err := srv.agent.RPC("Coordinate.Update", &arg, &out); err != nil { if err := srv.agent.RPC("Coordinate.Update", &arg, &out); err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
retry.
// Retry until foo has moved to the front of the line. // Retry until foo has moved to the front of the line.
Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
resp = httptest.NewRecorder() resp = httptest.NewRecorder()
obj, err = srv.HealthServiceChecks(resp, req) obj, err = srv.HealthServiceChecks(resp, req)
if err != nil { if err != nil {
@ -450,7 +443,6 @@ func TestHealthServiceChecks_DistanceSort(t *testing.T) {
r.Fatalf("bad: %v", nodes) r.Fatalf("bad: %v", nodes)
} }
}) })
} }
func TestHealthServiceNodes(t *testing.T) { func TestHealthServiceNodes(t *testing.T) {
@ -662,11 +654,8 @@ func TestHealthServiceNodes_DistanceSort(t *testing.T) {
if err := srv.agent.RPC("Coordinate.Update", &arg, &out); err != nil { if err := srv.agent.RPC("Coordinate.Update", &arg, &out); err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
retry.
// Retry until foo has moved to the front of the line. // Retry until foo has moved to the front of the line.
Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
resp = httptest.NewRecorder() resp = httptest.NewRecorder()
obj, err = srv.HealthServiceNodes(resp, req) obj, err = srv.HealthServiceNodes(resp, req)
if err != nil { if err != nil {
@ -684,7 +673,6 @@ func TestHealthServiceNodes_DistanceSort(t *testing.T) {
r.Fatalf("bad: %v", nodes) r.Fatalf("bad: %v", nodes)
} }
}) })
} }
func TestHealthServiceNodes_PassingFilter(t *testing.T) { func TestHealthServiceNodes_PassingFilter(t *testing.T) {

View File

@ -1289,11 +1289,8 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
Node: agent.config.NodeName, Node: agent.config.NodeName,
} }
var services structs.IndexedNodeServices var services structs.IndexedNodeServices
retry.
// Wait for the sync // Wait for the sync
Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
if err := agent.RPC("Catalog.NodeServices", &req, &services); err != nil { if err := agent.RPC("Catalog.NodeServices", &req, &services); err != nil {
r.Fatalf("err: %v", err) r.Fatalf("err: %v", err)
} }
@ -1317,12 +1314,8 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
// Trigger anti-entropy run and wait // Trigger anti-entropy run and wait
agent.StartSync() agent.StartSync()
retry. // Wait for the sync - this should have been a sync of just the node info
retry.Run(t, func(r *retry.R) {
// Wait for the sync - this should have been a sync of just the
// node info
Run(t, func(r *retry.R) {
if err := agent.RPC("Catalog.NodeServices", &req, &services); err != nil { if err := agent.RPC("Catalog.NodeServices", &req, &services); err != nil {
r.Fatalf("err: %v", err) r.Fatalf("err: %v", err)
} }
@ -1336,7 +1329,6 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
r.Fatalf("bad: %v", services.NodeServices.Node) r.Fatalf("bad: %v", services.NodeServices.Node)
} }
}) })
} }
func TestAgentAntiEntropy_deleteService_fails(t *testing.T) { func TestAgentAntiEntropy_deleteService_fails(t *testing.T) {

View File

@ -239,13 +239,10 @@ func TestAutopilot_PromoteNonVoter(t *testing.T) {
} }
testrpc.WaitForLeader(t, s1.RPC, "dc1") testrpc.WaitForLeader(t, s1.RPC, "dc1")
retry.
// Wait for the new server to be added as a non-voter, but make sure // Wait for the new server to be added as a non-voter, but make sure
// it doesn't get promoted to a voter even after ServerStabilizationTime, // it doesn't get promoted to a voter even after ServerStabilizationTime,
// because that would result in an even-numbered quorum count. // because that would result in an even-numbered quorum count.
Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
future := s1.raft.GetConfiguration() future := s1.raft.GetConfiguration()
if err := future.Error(); err != nil { if err := future.Error(); err != nil {
r.Fatal(err) r.Fatal(err)

View File

@ -676,17 +676,13 @@ func TestCatalog_ListNodes_NodeMetaFilter(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
retry.
// Should get an empty list of nodes back // Should get an empty list of nodes back
Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
msgpackrpc.CallWithCodec(codec, "Catalog.ListNodes", &args, &out) msgpackrpc.CallWithCodec(codec, "Catalog.ListNodes", &args, &out)
if len(out.Nodes) != 0 { if len(out.Nodes) != 0 {
r.Fatal(nil) r.Fatal(nil)
} }
}) })
} }
func TestCatalog_ListNodes_StaleRaad(t *testing.T) { func TestCatalog_ListNodes_StaleRaad(t *testing.T) {