Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
| ... | ... |
@@ -99,7 +99,15 @@ func (db *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool |
| 99 | 99 |
|
| 100 | 100 |
func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string, present bool) {
|
| 101 | 101 |
t.Helper() |
| 102 |
- for i := 0; i < 80; i++ {
|
|
| 102 |
+ |
|
| 103 |
+ const sleepInterval = 50 * time.Millisecond |
|
| 104 |
+ var maxRetries int64 |
|
| 105 |
+ if dl, ok := t.Deadline(); ok {
|
|
| 106 |
+ maxRetries = int64(time.Until(dl) / sleepInterval) |
|
| 107 |
+ } else {
|
|
| 108 |
+ maxRetries = 80 |
|
| 109 |
+ } |
|
| 110 |
+ for i := int64(0); i < maxRetries; i++ {
|
|
| 103 | 111 |
db.RLock() |
| 104 | 112 |
nn, nnok := db.networks[node] |
| 105 | 113 |
db.RUnlock() |
| ... | ... |
@@ -116,7 +124,7 @@ func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string |
| 116 | 116 |
} |
| 117 | 117 |
} |
| 118 | 118 |
|
| 119 |
- time.Sleep(50 * time.Millisecond) |
|
| 119 |
+ time.Sleep(sleepInterval) |
|
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 | 122 |
t.Error("Network existence verification failed")
|