Browse code

libnetwork/networkdb: consistently wait for nodes in tests

Use `verifyNetworkExistence` like it was done in 2837fba75f5ee7e57c167af4e70569adaf59377a

Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>

Roman Volosatovs authored on 2021/08/02 00:04:48
Showing 1 changed files
... ...
@@ -481,7 +481,6 @@ func TestNetworkDBCRUDMediumCluster(t *testing.T) {
481 481
 }
482 482
 
483 483
 func TestNetworkDBNodeJoinLeaveIteration(t *testing.T) {
484
-	maxRetry := 5
485 484
 	dbs := createNetworkDBInstances(t, 2, "node", DefaultConfig())
486 485
 
487 486
 	// Single node Join/Leave
... ...
@@ -530,22 +529,12 @@ func TestNetworkDBNodeJoinLeaveIteration(t *testing.T) {
530 530
 	err = dbs[0].JoinNetwork("network1")
531 531
 	assert.NilError(t, err)
532 532
 
533
-	for i := 0; i < maxRetry; i++ {
534
-		if len(dbs[0].networkNodes["network1"]) == 2 {
535
-			break
536
-		}
537
-		time.Sleep(1 * time.Second)
538
-	}
533
+	dbs[0].verifyNetworkExistence(t, dbs[1].config.NodeID, "network1", true)
539 534
 	if len(dbs[0].networkNodes["network1"]) != 2 {
540 535
 		t.Fatalf("The networkNodes list has to have be 2 instead of %d - %v", len(dbs[0].networkNodes["network1"]), dbs[0].networkNodes["network1"])
541 536
 	}
542 537
 
543
-	for i := 0; i < maxRetry; i++ {
544
-		if len(dbs[1].networkNodes["network1"]) == 2 {
545
-			break
546
-		}
547
-		time.Sleep(1 * time.Second)
548
-	}
538
+	dbs[1].verifyNetworkExistence(t, dbs[0].config.NodeID, "network1", true)
549 539
 	if len(dbs[1].networkNodes["network1"]) != 2 {
550 540
 		t.Fatalf("The networkNodes list has to have be 2 instead of %d - %v", len(dbs[1].networkNodes["network1"]), dbs[1].networkNodes["network1"])
551 541
 	}