Merge pull request #37231 from adshmh/use-unique-names-for-integration-tests-service-create
use unique names for resources in create service integration tests
This commit is contained in:
commit
5ff12f6ba1
|
@ -23,7 +23,7 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
|
||||||
client := d.NewClientT(t)
|
client := d.NewClientT(t)
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
overlayName := "overlay1"
|
overlayName := "overlay1_" + t.Name()
|
||||||
networkCreate := types.NetworkCreate{
|
networkCreate := types.NetworkCreate{
|
||||||
CheckDuplicate: true,
|
CheckDuplicate: true,
|
||||||
Driver: "overlay",
|
Driver: "overlay",
|
||||||
|
@ -35,9 +35,10 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
|
||||||
|
|
||||||
var instances uint64 = 4
|
var instances uint64 = 4
|
||||||
|
|
||||||
|
serviceName := "TestService_" + t.Name()
|
||||||
serviceSpec := []swarm.ServiceSpecOpt{
|
serviceSpec := []swarm.ServiceSpecOpt{
|
||||||
swarm.ServiceWithReplicas(instances),
|
swarm.ServiceWithReplicas(instances),
|
||||||
swarm.ServiceWithName("TestService"),
|
swarm.ServiceWithName(serviceName),
|
||||||
swarm.ServiceWithNetwork(overlayName),
|
swarm.ServiceWithNetwork(overlayName),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
|
||||||
client := d.NewClientT(t)
|
client := d.NewClientT(t)
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
name := "foo"
|
name := "foo_" + t.Name()
|
||||||
networkCreate := types.NetworkCreate{
|
networkCreate := types.NetworkCreate{
|
||||||
CheckDuplicate: false,
|
CheckDuplicate: false,
|
||||||
Driver: "bridge",
|
Driver: "bridge",
|
||||||
|
@ -95,9 +96,10 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
|
||||||
// Create Service with the same name
|
// Create Service with the same name
|
||||||
var instances uint64 = 1
|
var instances uint64 = 1
|
||||||
|
|
||||||
|
serviceName := "top_" + t.Name()
|
||||||
serviceID := swarm.CreateService(t, d,
|
serviceID := swarm.CreateService(t, d,
|
||||||
swarm.ServiceWithReplicas(instances),
|
swarm.ServiceWithReplicas(instances),
|
||||||
swarm.ServiceWithName("top"),
|
swarm.ServiceWithName(serviceName),
|
||||||
swarm.ServiceWithNetwork(name),
|
swarm.ServiceWithNetwork(name),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -138,18 +140,20 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
secretName := "TestSecret_" + t.Name()
|
||||||
secretResp, err := client.SecretCreate(ctx, swarmtypes.SecretSpec{
|
secretResp, err := client.SecretCreate(ctx, swarmtypes.SecretSpec{
|
||||||
Annotations: swarmtypes.Annotations{
|
Annotations: swarmtypes.Annotations{
|
||||||
Name: "TestSecret",
|
Name: secretName,
|
||||||
},
|
},
|
||||||
Data: []byte("TESTSECRET"),
|
Data: []byte("TESTSECRET"),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
var instances uint64 = 1
|
var instances uint64 = 1
|
||||||
|
serviceName := "TestService_" + t.Name()
|
||||||
serviceID := swarm.CreateService(t, d,
|
serviceID := swarm.CreateService(t, d,
|
||||||
swarm.ServiceWithReplicas(instances),
|
swarm.ServiceWithReplicas(instances),
|
||||||
swarm.ServiceWithName("TestService"),
|
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 || /bin/top"}),
|
||||||
swarm.ServiceWithSecret(&swarmtypes.SecretReference{
|
swarm.ServiceWithSecret(&swarmtypes.SecretReference{
|
||||||
File: &swarmtypes.SecretReferenceFileTarget{
|
File: &swarmtypes.SecretReferenceFileTarget{
|
||||||
|
@ -159,7 +163,7 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
||||||
Mode: 0777,
|
Mode: 0777,
|
||||||
},
|
},
|
||||||
SecretID: secretResp.ID,
|
SecretID: secretResp.ID,
|
||||||
SecretName: "TestSecret",
|
SecretName: secretName,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -189,7 +193,7 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
||||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
|
poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
|
||||||
poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
|
poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
|
||||||
|
|
||||||
err = client.SecretRemove(ctx, "TestSecret")
|
err = client.SecretRemove(ctx, secretName)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,17 +205,19 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
configName := "TestConfig_" + t.Name()
|
||||||
configResp, err := client.ConfigCreate(ctx, swarmtypes.ConfigSpec{
|
configResp, err := client.ConfigCreate(ctx, swarmtypes.ConfigSpec{
|
||||||
Annotations: swarmtypes.Annotations{
|
Annotations: swarmtypes.Annotations{
|
||||||
Name: "TestConfig",
|
Name: configName,
|
||||||
},
|
},
|
||||||
Data: []byte("TESTCONFIG"),
|
Data: []byte("TESTCONFIG"),
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
var instances uint64 = 1
|
var instances uint64 = 1
|
||||||
|
serviceName := "TestService_" + t.Name()
|
||||||
serviceID := swarm.CreateService(t, d,
|
serviceID := swarm.CreateService(t, d,
|
||||||
swarm.ServiceWithName("TestService"),
|
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 || /bin/top"}),
|
||||||
swarm.ServiceWithReplicas(instances),
|
swarm.ServiceWithReplicas(instances),
|
||||||
swarm.ServiceWithConfig(&swarmtypes.ConfigReference{
|
swarm.ServiceWithConfig(&swarmtypes.ConfigReference{
|
||||||
|
@ -222,7 +228,7 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
|
||||||
Mode: 0777,
|
Mode: 0777,
|
||||||
},
|
},
|
||||||
ConfigID: configResp.ID,
|
ConfigID: configResp.ID,
|
||||||
ConfigName: "TestConfig",
|
ConfigName: configName,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -252,7 +258,7 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
|
||||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID))
|
poll.WaitOn(t, serviceIsRemoved(client, serviceID))
|
||||||
poll.WaitOn(t, noTasks(client))
|
poll.WaitOn(t, noTasks(client))
|
||||||
|
|
||||||
err = client.ConfigRemove(ctx, "TestConfig")
|
err = client.ConfigRemove(ctx, configName)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue