mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
libnetwork: ensure all nodes are available in tests
`github.com/hashicorp/memberlist` update caused `TestNetworkDBCRUDTableEntries` to occasionally fail, because the test would try to check whether an entry write is propagated to all nodes, but it would not wait for all nodes to be available before performing the write. It could be that the failure is caused simply by improved performance of the dependency - it could also be that some connectivity guarantee the test depended on is not provided by the dependency anymore. The same fix is applied to `TestNetworkDBNodeJoinLeaveIteration` due to same issue. Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
This commit is contained in:
parent
cdd04a94bc
commit
2837fba75f
1 changed files with 4 additions and 12 deletions
|
@ -278,6 +278,8 @@ func TestNetworkDBCRUDTableEntries(t *testing.T) {
|
|||
err = dbs[1].JoinNetwork("network1")
|
||||
assert.NilError(t, err)
|
||||
|
||||
dbs[0].verifyNetworkExistence(t, dbs[1].config.NodeID, "network1", true)
|
||||
|
||||
n := 10
|
||||
for i := 1; i <= n; i++ {
|
||||
err = dbs[0].CreateEntry("test_table", "network1",
|
||||
|
@ -497,12 +499,7 @@ func TestNetworkDBNodeJoinLeaveIteration(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
|
||||
// Wait for the propagation on db[0]
|
||||
for i := 0; i < maxRetry; i++ {
|
||||
if len(dbs[0].networkNodes["network1"]) == 2 {
|
||||
break
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
dbs[0].verifyNetworkExistence(t, dbs[1].config.NodeID, "network1", true)
|
||||
if len(dbs[0].networkNodes["network1"]) != 2 {
|
||||
t.Fatalf("The networkNodes list has to have be 2 instead of %d - %v", len(dbs[0].networkNodes["network1"]), dbs[0].networkNodes["network1"])
|
||||
}
|
||||
|
@ -511,12 +508,7 @@ func TestNetworkDBNodeJoinLeaveIteration(t *testing.T) {
|
|||
}
|
||||
|
||||
// Wait for the propagation on db[1]
|
||||
for i := 0; i < maxRetry; i++ {
|
||||
if len(dbs[1].networkNodes["network1"]) == 2 {
|
||||
break
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
dbs[1].verifyNetworkExistence(t, dbs[0].config.NodeID, "network1", true)
|
||||
if len(dbs[1].networkNodes["network1"]) != 2 {
|
||||
t.Fatalf("The networkNodes list has to have be 2 instead of %d - %v", len(dbs[1].networkNodes["network1"]), dbs[1].networkNodes["network1"])
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue