mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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>
This commit is contained in:
parent
ee6959addc
commit
b8912feeff
3 changed files with 22 additions and 60 deletions
|
@ -1,7 +1,6 @@
|
|||
package network // import "github.com/docker/docker/integration/network"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -46,15 +45,8 @@ func TestInspectNetwork(t *testing.T) {
|
|||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
pollSettings := func(config *poll.Settings) {
|
||||
if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
|
||||
config.Timeout = 30 * time.Second
|
||||
config.Delay = 100 * time.Millisecond
|
||||
}
|
||||
}
|
||||
|
||||
serviceID := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), pollSettings)
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), swarm.ServicePoll)
|
||||
|
||||
_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
@ -84,8 +76,8 @@ func TestInspectNetwork(t *testing.T) {
|
|||
err = client.ServiceRemove(context.Background(), serviceID)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings)
|
||||
poll.WaitOn(t, noTasks(client), pollSettings)
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
|
||||
poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
|
||||
|
||||
serviceResp, err = client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
||||
QueryRegistry: false,
|
||||
|
@ -93,13 +85,13 @@ func TestInspectNetwork(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
|
||||
serviceID2 := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), pollSettings)
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), swarm.ServicePoll)
|
||||
|
||||
err = client.ServiceRemove(context.Background(), serviceID2)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID2), pollSettings)
|
||||
poll.WaitOn(t, noTasks(client), pollSettings)
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID2), swarm.ServicePoll)
|
||||
poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
|
||||
|
||||
err = client.NetworkRemove(context.Background(), overlayID)
|
||||
assert.NilError(t, err)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package network // import "github.com/docker/docker/integration/network"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -32,18 +31,8 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
|
|||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
pollSettings := func(config *poll.Settings) {
|
||||
if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
|
||||
config.Timeout = 50 * time.Second
|
||||
config.Delay = 100 * time.Millisecond
|
||||
} else {
|
||||
config.Timeout = 30 * time.Second
|
||||
config.Delay = 100 * time.Millisecond
|
||||
}
|
||||
}
|
||||
|
||||
serviceID := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), pollSettings)
|
||||
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), swarm.ServicePoll)
|
||||
|
||||
_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
@ -62,17 +51,7 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
|||
client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
|
||||
assert.NilError(t, err)
|
||||
|
||||
pollSettings := func(config *poll.Settings) {
|
||||
if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
|
||||
config.Timeout = 50 * time.Second
|
||||
config.Delay = 100 * time.Millisecond
|
||||
} else {
|
||||
config.Timeout = 30 * time.Second
|
||||
config.Delay = 100 * time.Millisecond
|
||||
}
|
||||
}
|
||||
|
||||
poll.WaitOn(t, swarmIngressReady(client), pollSettings)
|
||||
poll.WaitOn(t, swarmIngressReady(client), swarm.NetworkPoll)
|
||||
|
||||
var instances uint64 = 1
|
||||
serviceName := "TestIngressService"
|
||||
|
@ -94,7 +73,7 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
|
||||
serviceID := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), pollSettings)
|
||||
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), swarm.ServicePoll)
|
||||
|
||||
_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
@ -102,8 +81,8 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
|||
err = client.ServiceRemove(context.Background(), serviceID)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings)
|
||||
poll.WaitOn(t, noServices(client), pollSettings)
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
|
||||
poll.WaitOn(t, noServices(client), swarm.ServicePoll)
|
||||
|
||||
// Ensure that "ingress" is not removed or corrupted
|
||||
time.Sleep(10 * time.Second)
|
||||
|
|
|
@ -2,7 +2,6 @@ package service // import "github.com/docker/docker/integration/service"
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -43,16 +42,8 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
|
|||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
pollSettings := func(config *poll.Settings) {
|
||||
// It takes about ~25s to finish the multi services creation in this case per the pratical observation on arm64/arm platform
|
||||
if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
|
||||
config.Timeout = 30 * time.Second
|
||||
config.Delay = 100 * time.Millisecond
|
||||
}
|
||||
}
|
||||
|
||||
serviceID := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), pollSettings)
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), swarm.ServicePoll)
|
||||
|
||||
_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
@ -60,8 +51,8 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
|
|||
err = client.ServiceRemove(context.Background(), serviceID)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings)
|
||||
poll.WaitOn(t, noTasks(client), pollSettings)
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
|
||||
poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
|
||||
|
||||
serviceResp, err = client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
||||
QueryRegistry: false,
|
||||
|
@ -69,13 +60,13 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
|
||||
serviceID2 := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), pollSettings)
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), swarm.ServicePoll)
|
||||
|
||||
err = client.ServiceRemove(context.Background(), serviceID2)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID2), pollSettings)
|
||||
poll.WaitOn(t, noTasks(client), pollSettings)
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID2), swarm.ServicePoll)
|
||||
poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
|
||||
|
||||
err = client.NetworkRemove(context.Background(), overlayID)
|
||||
assert.NilError(t, err)
|
||||
|
@ -116,7 +107,7 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
|
|||
service, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, service.ID, instances))
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, service.ID, instances), swarm.ServicePoll)
|
||||
|
||||
resp, _, err := client.ServiceInspectWithRaw(context.Background(), service.ID, types.ServiceInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
@ -127,7 +118,7 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
|
||||
// Make sure task has been destroyed.
|
||||
poll.WaitOn(t, serviceIsRemoved(client, service.ID))
|
||||
poll.WaitOn(t, serviceIsRemoved(client, service.ID), swarm.ServicePoll)
|
||||
|
||||
// Remove networks
|
||||
err = client.NetworkRemove(context.Background(), n3.ID)
|
||||
|
@ -196,7 +187,7 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
|||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceResp.ID, instances))
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceResp.ID, instances), swarm.ServicePoll)
|
||||
|
||||
filter := filters.NewArgs()
|
||||
filter.Add("service", serviceResp.ID)
|
||||
|
@ -219,8 +210,8 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
|||
err = client.ServiceRemove(ctx, serviceResp.ID)
|
||||
assert.NilError(t, err)
|
||||
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceResp.ID))
|
||||
poll.WaitOn(t, noTasks(client))
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceResp.ID), swarm.ServicePoll)
|
||||
poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
|
||||
|
||||
err = client.SecretRemove(ctx, "TestSecret")
|
||||
assert.NilError(t, err)
|
||||
|
|
Loading…
Add table
Reference in a new issue