TestServiceWithPredefinedNetwork test case was failing
at times. To fix the issue, added new API to check
for services after we clean up all services. Tested
multiple times and this sould fix flaky issue.
Signed-off-by: selansen <elango.siva@docker.com>
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/api/types" |
| 9 |
- "github.com/docker/docker/api/types/filters" |
|
| 10 | 9 |
swarmtypes "github.com/docker/docker/api/types/swarm" |
| 11 | 10 |
"github.com/docker/docker/client" |
| 12 | 11 |
"github.com/docker/docker/integration/internal/swarm" |
| ... | ... |
@@ -51,10 +50,6 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
|
| 51 | 51 |
|
| 52 | 52 |
err = client.ServiceRemove(context.Background(), serviceID) |
| 53 | 53 |
assert.NilError(t, err) |
| 54 |
- |
|
| 55 |
- poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings) |
|
| 56 |
- poll.WaitOn(t, noTasks(client), pollSettings) |
|
| 57 |
- |
|
| 58 | 54 |
} |
| 59 | 55 |
|
| 60 | 56 |
const ingressNet = "ingress" |
| ... | ... |
@@ -108,7 +103,7 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
| 108 | 108 |
assert.NilError(t, err) |
| 109 | 109 |
|
| 110 | 110 |
poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings) |
| 111 |
- poll.WaitOn(t, noTasks(client), pollSettings) |
|
| 111 |
+ poll.WaitOn(t, noServices(client), pollSettings) |
|
| 112 | 112 |
|
| 113 | 113 |
// Ensure that "ingress" is not removed or corrupted |
| 114 | 114 |
time.Sleep(10 * time.Second) |
| ... | ... |
@@ -125,8 +120,6 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
| 125 | 125 |
|
| 126 | 126 |
func serviceRunningCount(client client.ServiceAPIClient, serviceID string, instances uint64) func(log poll.LogT) poll.Result {
|
| 127 | 127 |
return func(log poll.LogT) poll.Result {
|
| 128 |
- filter := filters.NewArgs() |
|
| 129 |
- filter.Add("service", serviceID)
|
|
| 130 | 128 |
services, err := client.ServiceList(context.Background(), types.ServiceListOptions{})
|
| 131 | 129 |
if err != nil {
|
| 132 | 130 |
return poll.Error(err) |
| ... | ... |
@@ -160,3 +153,17 @@ func swarmIngressReady(client client.NetworkAPIClient) func(log poll.LogT) poll. |
| 160 | 160 |
return poll.Success() |
| 161 | 161 |
} |
| 162 | 162 |
} |
| 163 |
+ |
|
| 164 |
+func noServices(client client.ServiceAPIClient) func(log poll.LogT) poll.Result {
|
|
| 165 |
+ return func(log poll.LogT) poll.Result {
|
|
| 166 |
+ services, err := client.ServiceList(context.Background(), types.ServiceListOptions{})
|
|
| 167 |
+ switch {
|
|
| 168 |
+ case err != nil: |
|
| 169 |
+ return poll.Error(err) |
|
| 170 |
+ case len(services) == 0: |
|
| 171 |
+ return poll.Success() |
|
| 172 |
+ default: |
|
| 173 |
+ return poll.Continue("Service count at %d waiting for 0", len(services))
|
|
| 174 |
+ } |
|
| 175 |
+ } |
|
| 176 |
+} |