Merge pull request #42971 from thaJeztah/20.10_backport_fix_TestCreateServiceSecretFileMode
[20.10 backport] Fix race in TestCreateServiceSecretFileMode, TestCreateServiceConfigFileMode
This commit is contained in:
commit
9a309c6165
|
@ -267,7 +267,7 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
||||||
serviceID := swarm.CreateService(t, d,
|
serviceID := swarm.CreateService(t, d,
|
||||||
swarm.ServiceWithReplicas(instances),
|
swarm.ServiceWithReplicas(instances),
|
||||||
swarm.ServiceWithName(serviceName),
|
swarm.ServiceWithName(serviceName),
|
||||||
swarm.ServiceWithCommand([]string{"/bin/sh", "-c", "ls -l /etc/secret || /bin/top"}),
|
swarm.ServiceWithCommand([]string{"/bin/sh", "-c", "ls -l /etc/secret && sleep inf"}),
|
||||||
swarm.ServiceWithSecret(&swarmtypes.SecretReference{
|
swarm.ServiceWithSecret(&swarmtypes.SecretReference{
|
||||||
File: &swarmtypes.SecretReferenceFileTarget{
|
File: &swarmtypes.SecretReferenceFileTarget{
|
||||||
Name: "/etc/secret",
|
Name: "/etc/secret",
|
||||||
|
@ -282,15 +282,8 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
||||||
|
|
||||||
poll.WaitOn(t, swarm.RunningTasksCount(client, serviceID, instances), swarm.ServicePoll)
|
poll.WaitOn(t, swarm.RunningTasksCount(client, serviceID, instances), swarm.ServicePoll)
|
||||||
|
|
||||||
filter := filters.NewArgs()
|
body, err := client.ServiceLogs(ctx, serviceID, types.ContainerLogsOptions{
|
||||||
filter.Add("service", serviceID)
|
Tail: "1",
|
||||||
tasks, err := client.TaskList(ctx, types.TaskListOptions{
|
|
||||||
Filters: filter,
|
|
||||||
})
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Check(t, is.Equal(len(tasks), 1))
|
|
||||||
|
|
||||||
body, err := client.ContainerLogs(ctx, tasks[0].Status.ContainerStatus.ContainerID, types.ContainerLogsOptions{
|
|
||||||
ShowStdout: true,
|
ShowStdout: true,
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
@ -330,7 +323,7 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
|
||||||
serviceName := "TestService_" + t.Name()
|
serviceName := "TestService_" + t.Name()
|
||||||
serviceID := swarm.CreateService(t, d,
|
serviceID := swarm.CreateService(t, d,
|
||||||
swarm.ServiceWithName(serviceName),
|
swarm.ServiceWithName(serviceName),
|
||||||
swarm.ServiceWithCommand([]string{"/bin/sh", "-c", "ls -l /etc/config || /bin/top"}),
|
swarm.ServiceWithCommand([]string{"/bin/sh", "-c", "ls -l /etc/config && sleep inf"}),
|
||||||
swarm.ServiceWithReplicas(instances),
|
swarm.ServiceWithReplicas(instances),
|
||||||
swarm.ServiceWithConfig(&swarmtypes.ConfigReference{
|
swarm.ServiceWithConfig(&swarmtypes.ConfigReference{
|
||||||
File: &swarmtypes.ConfigReferenceFileTarget{
|
File: &swarmtypes.ConfigReferenceFileTarget{
|
||||||
|
@ -346,15 +339,8 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
|
||||||
|
|
||||||
poll.WaitOn(t, swarm.RunningTasksCount(client, serviceID, instances))
|
poll.WaitOn(t, swarm.RunningTasksCount(client, serviceID, instances))
|
||||||
|
|
||||||
filter := filters.NewArgs()
|
body, err := client.ServiceLogs(ctx, serviceID, types.ContainerLogsOptions{
|
||||||
filter.Add("service", serviceID)
|
Tail: "1",
|
||||||
tasks, err := client.TaskList(ctx, types.TaskListOptions{
|
|
||||||
Filters: filter,
|
|
||||||
})
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Check(t, is.Equal(len(tasks), 1))
|
|
||||||
|
|
||||||
body, err := client.ContainerLogs(ctx, tasks[0].Status.ContainerStatus.ContainerID, types.ContainerLogsOptions{
|
|
||||||
ShowStdout: true,
|
ShowStdout: true,
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
Loading…
Reference in New Issue