Browse code

Using the default PollSettings function

Using the default PollSettings functions to adjust the timeout
value instead of changing the value each time when needed.

Signed-off-by: Dennis Chen <dennis.chen@arm.com>

Dennis Chen authored on 2018/03/27 13:06:46
Showing 3 changed files
... ...
@@ -1,7 +1,6 @@
1 1
 package network // import "github.com/docker/docker/integration/network"
2 2
 
3 3
 import (
4
-	"runtime"
5 4
 	"testing"
6 5
 	"time"
7 6
 
... ...
@@ -46,15 +45,8 @@ func TestInspectNetwork(t *testing.T) {
46 46
 	})
47 47
 	assert.NilError(t, err)
48 48
 
49
-	pollSettings := func(config *poll.Settings) {
50
-		if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
51
-			config.Timeout = 30 * time.Second
52
-			config.Delay = 100 * time.Millisecond
53
-		}
54
-	}
55
-
56 49
 	serviceID := serviceResp.ID
57
-	poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), pollSettings)
50
+	poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), swarm.ServicePoll)
58 51
 
59 52
 	_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
60 53
 	assert.NilError(t, err)
... ...
@@ -84,8 +76,8 @@ func TestInspectNetwork(t *testing.T) {
84 84
 	err = client.ServiceRemove(context.Background(), serviceID)
85 85
 	assert.NilError(t, err)
86 86
 
87
-	poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings)
88
-	poll.WaitOn(t, noTasks(client), pollSettings)
87
+	poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
88
+	poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
89 89
 
90 90
 	serviceResp, err = client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
91 91
 		QueryRegistry: false,
... ...
@@ -93,13 +85,13 @@ func TestInspectNetwork(t *testing.T) {
93 93
 	assert.NilError(t, err)
94 94
 
95 95
 	serviceID2 := serviceResp.ID
96
-	poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), pollSettings)
96
+	poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), swarm.ServicePoll)
97 97
 
98 98
 	err = client.ServiceRemove(context.Background(), serviceID2)
99 99
 	assert.NilError(t, err)
100 100
 
101
-	poll.WaitOn(t, serviceIsRemoved(client, serviceID2), pollSettings)
102
-	poll.WaitOn(t, noTasks(client), pollSettings)
101
+	poll.WaitOn(t, serviceIsRemoved(client, serviceID2), swarm.ServicePoll)
102
+	poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
103 103
 
104 104
 	err = client.NetworkRemove(context.Background(), overlayID)
105 105
 	assert.NilError(t, err)
... ...
@@ -1,7 +1,6 @@
1 1
 package network // import "github.com/docker/docker/integration/network"
2 2
 
3 3
 import (
4
-	"runtime"
5 4
 	"testing"
6 5
 	"time"
7 6
 
... ...
@@ -32,18 +31,8 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
32 32
 	})
33 33
 	assert.NilError(t, err)
34 34
 
35
-	pollSettings := func(config *poll.Settings) {
36
-		if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
37
-			config.Timeout = 50 * time.Second
38
-			config.Delay = 100 * time.Millisecond
39
-		} else {
40
-			config.Timeout = 30 * time.Second
41
-			config.Delay = 100 * time.Millisecond
42
-		}
43
-	}
44
-
45 35
 	serviceID := serviceResp.ID
46
-	poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), pollSettings)
36
+	poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), swarm.ServicePoll)
47 37
 
48 38
 	_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
49 39
 	assert.NilError(t, err)
... ...
@@ -62,17 +51,7 @@ func TestServiceWithIngressNetwork(t *testing.T) {
62 62
 	client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
63 63
 	assert.NilError(t, err)
64 64
 
65
-	pollSettings := func(config *poll.Settings) {
66
-		if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
67
-			config.Timeout = 50 * time.Second
68
-			config.Delay = 100 * time.Millisecond
69
-		} else {
70
-			config.Timeout = 30 * time.Second
71
-			config.Delay = 100 * time.Millisecond
72
-		}
73
-	}
74
-
75
-	poll.WaitOn(t, swarmIngressReady(client), pollSettings)
65
+	poll.WaitOn(t, swarmIngressReady(client), swarm.NetworkPoll)
76 66
 
77 67
 	var instances uint64 = 1
78 68
 	serviceName := "TestIngressService"
... ...
@@ -94,7 +73,7 @@ func TestServiceWithIngressNetwork(t *testing.T) {
94 94
 	assert.NilError(t, err)
95 95
 
96 96
 	serviceID := serviceResp.ID
97
-	poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), pollSettings)
97
+	poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), swarm.ServicePoll)
98 98
 
99 99
 	_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
100 100
 	assert.NilError(t, err)
... ...
@@ -102,8 +81,8 @@ func TestServiceWithIngressNetwork(t *testing.T) {
102 102
 	err = client.ServiceRemove(context.Background(), serviceID)
103 103
 	assert.NilError(t, err)
104 104
 
105
-	poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings)
106
-	poll.WaitOn(t, noServices(client), pollSettings)
105
+	poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
106
+	poll.WaitOn(t, noServices(client), swarm.ServicePoll)
107 107
 
108 108
 	// Ensure that "ingress" is not removed or corrupted
109 109
 	time.Sleep(10 * time.Second)
... ...
@@ -2,7 +2,6 @@ package service // import "github.com/docker/docker/integration/service"
2 2
 
3 3
 import (
4 4
 	"io/ioutil"
5
-	"runtime"
6 5
 	"testing"
7 6
 	"time"
8 7
 
... ...
@@ -43,16 +42,8 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
43 43
 	})
44 44
 	assert.NilError(t, err)
45 45
 
46
-	pollSettings := func(config *poll.Settings) {
47
-		// It takes about ~25s to finish the multi services creation in this case per the pratical observation on arm64/arm platform
48
-		if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
49
-			config.Timeout = 30 * time.Second
50
-			config.Delay = 100 * time.Millisecond
51
-		}
52
-	}
53
-
54 46
 	serviceID := serviceResp.ID
55
-	poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), pollSettings)
47
+	poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), swarm.ServicePoll)
56 48
 
57 49
 	_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
58 50
 	assert.NilError(t, err)
... ...
@@ -60,8 +51,8 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
60 60
 	err = client.ServiceRemove(context.Background(), serviceID)
61 61
 	assert.NilError(t, err)
62 62
 
63
-	poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings)
64
-	poll.WaitOn(t, noTasks(client), pollSettings)
63
+	poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
64
+	poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
65 65
 
66 66
 	serviceResp, err = client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
67 67
 		QueryRegistry: false,
... ...
@@ -69,13 +60,13 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
69 69
 	assert.NilError(t, err)
70 70
 
71 71
 	serviceID2 := serviceResp.ID
72
-	poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), pollSettings)
72
+	poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), swarm.ServicePoll)
73 73
 
74 74
 	err = client.ServiceRemove(context.Background(), serviceID2)
75 75
 	assert.NilError(t, err)
76 76
 
77
-	poll.WaitOn(t, serviceIsRemoved(client, serviceID2), pollSettings)
78
-	poll.WaitOn(t, noTasks(client), pollSettings)
77
+	poll.WaitOn(t, serviceIsRemoved(client, serviceID2), swarm.ServicePoll)
78
+	poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
79 79
 
80 80
 	err = client.NetworkRemove(context.Background(), overlayID)
81 81
 	assert.NilError(t, err)
... ...
@@ -116,7 +107,7 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
116 116
 	service, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{})
117 117
 	assert.NilError(t, err)
118 118
 
119
-	poll.WaitOn(t, serviceRunningTasksCount(client, service.ID, instances))
119
+	poll.WaitOn(t, serviceRunningTasksCount(client, service.ID, instances), swarm.ServicePoll)
120 120
 
121 121
 	resp, _, err := client.ServiceInspectWithRaw(context.Background(), service.ID, types.ServiceInspectOptions{})
122 122
 	assert.NilError(t, err)
... ...
@@ -127,7 +118,7 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
127 127
 	assert.NilError(t, err)
128 128
 
129 129
 	// Make sure task has been destroyed.
130
-	poll.WaitOn(t, serviceIsRemoved(client, service.ID))
130
+	poll.WaitOn(t, serviceIsRemoved(client, service.ID), swarm.ServicePoll)
131 131
 
132 132
 	// Remove networks
133 133
 	err = client.NetworkRemove(context.Background(), n3.ID)
... ...
@@ -196,7 +187,7 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
196 196
 	})
197 197
 	assert.NilError(t, err)
198 198
 
199
-	poll.WaitOn(t, serviceRunningTasksCount(client, serviceResp.ID, instances))
199
+	poll.WaitOn(t, serviceRunningTasksCount(client, serviceResp.ID, instances), swarm.ServicePoll)
200 200
 
201 201
 	filter := filters.NewArgs()
202 202
 	filter.Add("service", serviceResp.ID)
... ...
@@ -219,8 +210,8 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
219 219
 	err = client.ServiceRemove(ctx, serviceResp.ID)
220 220
 	assert.NilError(t, err)
221 221
 
222
-	poll.WaitOn(t, serviceIsRemoved(client, serviceResp.ID))
223
-	poll.WaitOn(t, noTasks(client))
222
+	poll.WaitOn(t, serviceIsRemoved(client, serviceResp.ID), swarm.ServicePoll)
223
+	poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
224 224
 
225 225
 	err = client.SecretRemove(ctx, "TestSecret")
226 226
 	assert.NilError(t, err)