integration tests under integration/config use unique names when creating resources
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
This commit is contained in:
parent
8a9e1808cf
commit
69481edc07
|
@ -36,8 +36,8 @@ func TestConfigList(t *testing.T) {
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Check(t, is.Equal(len(configs), 0))
|
assert.Check(t, is.Equal(len(configs), 0))
|
||||||
|
|
||||||
testName0 := "test0"
|
testName0 := "test0-" + t.Name()
|
||||||
testName1 := "test1"
|
testName1 := "test1-" + t.Name()
|
||||||
testNames := []string{testName0, testName1}
|
testNames := []string{testName0, testName1}
|
||||||
sort.Strings(testNames)
|
sort.Strings(testNames)
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ func TestConfigsCreateAndDelete(t *testing.T) {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
testName := "test_config"
|
testName := "test_config-" + t.Name()
|
||||||
|
|
||||||
// This test case is ported from the original TestConfigsCreate
|
// This test case is ported from the original TestConfigsCreate
|
||||||
configID := createConfig(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
|
configID := createConfig(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
|
||||||
|
@ -150,7 +150,7 @@ func TestConfigsUpdate(t *testing.T) {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
testName := "test_config"
|
testName := "test_config-" + t.Name()
|
||||||
|
|
||||||
// This test case is ported from the original TestConfigsCreate
|
// This test case is ported from the original TestConfigsCreate
|
||||||
configID := createConfig(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
|
configID := createConfig(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
|
||||||
|
@ -200,27 +200,30 @@ func TestTemplatedConfig(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
client := swarm.GetClient(t, d)
|
client := swarm.GetClient(t, d)
|
||||||
|
|
||||||
|
referencedSecretName := "referencedsecret-" + t.Name()
|
||||||
referencedSecretSpec := swarmtypes.SecretSpec{
|
referencedSecretSpec := swarmtypes.SecretSpec{
|
||||||
Annotations: swarmtypes.Annotations{
|
Annotations: swarmtypes.Annotations{
|
||||||
Name: "referencedsecret",
|
Name: referencedSecretName,
|
||||||
},
|
},
|
||||||
Data: []byte("this is a secret"),
|
Data: []byte("this is a secret"),
|
||||||
}
|
}
|
||||||
referencedSecret, err := client.SecretCreate(ctx, referencedSecretSpec)
|
referencedSecret, err := client.SecretCreate(ctx, referencedSecretSpec)
|
||||||
assert.Check(t, err)
|
assert.Check(t, err)
|
||||||
|
|
||||||
|
referencedConfigName := "referencedconfig-" + t.Name()
|
||||||
referencedConfigSpec := swarmtypes.ConfigSpec{
|
referencedConfigSpec := swarmtypes.ConfigSpec{
|
||||||
Annotations: swarmtypes.Annotations{
|
Annotations: swarmtypes.Annotations{
|
||||||
Name: "referencedconfig",
|
Name: referencedConfigName,
|
||||||
},
|
},
|
||||||
Data: []byte("this is a config"),
|
Data: []byte("this is a config"),
|
||||||
}
|
}
|
||||||
referencedConfig, err := client.ConfigCreate(ctx, referencedConfigSpec)
|
referencedConfig, err := client.ConfigCreate(ctx, referencedConfigSpec)
|
||||||
assert.Check(t, err)
|
assert.Check(t, err)
|
||||||
|
|
||||||
|
templatedConfigName := "templated_config-" + t.Name()
|
||||||
configSpec := swarmtypes.ConfigSpec{
|
configSpec := swarmtypes.ConfigSpec{
|
||||||
Annotations: swarmtypes.Annotations{
|
Annotations: swarmtypes.Annotations{
|
||||||
Name: "templated_config",
|
Name: templatedConfigName,
|
||||||
},
|
},
|
||||||
Templating: &swarmtypes.Driver{
|
Templating: &swarmtypes.Driver{
|
||||||
Name: "golang",
|
Name: "golang",
|
||||||
|
@ -237,13 +240,13 @@ func TestTemplatedConfig(t *testing.T) {
|
||||||
swarm.ServiceWithConfig(
|
swarm.ServiceWithConfig(
|
||||||
&swarmtypes.ConfigReference{
|
&swarmtypes.ConfigReference{
|
||||||
File: &swarmtypes.ConfigReferenceFileTarget{
|
File: &swarmtypes.ConfigReferenceFileTarget{
|
||||||
Name: "/templated_config",
|
Name: "/" + templatedConfigName,
|
||||||
UID: "0",
|
UID: "0",
|
||||||
GID: "0",
|
GID: "0",
|
||||||
Mode: 0600,
|
Mode: 0600,
|
||||||
},
|
},
|
||||||
ConfigID: templatedConfig.ID,
|
ConfigID: templatedConfig.ID,
|
||||||
ConfigName: "templated_config",
|
ConfigName: templatedConfigName,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
swarm.ServiceWithConfig(
|
swarm.ServiceWithConfig(
|
||||||
|
@ -255,7 +258,7 @@ func TestTemplatedConfig(t *testing.T) {
|
||||||
Mode: 0600,
|
Mode: 0600,
|
||||||
},
|
},
|
||||||
ConfigID: referencedConfig.ID,
|
ConfigID: referencedConfig.ID,
|
||||||
ConfigName: "referencedconfig",
|
ConfigName: referencedConfigName,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
swarm.ServiceWithSecret(
|
swarm.ServiceWithSecret(
|
||||||
|
@ -267,7 +270,7 @@ func TestTemplatedConfig(t *testing.T) {
|
||||||
Mode: 0600,
|
Mode: 0600,
|
||||||
},
|
},
|
||||||
SecretID: referencedSecret.ID,
|
SecretID: referencedSecret.ID,
|
||||||
SecretName: "referencedsecret",
|
SecretName: referencedSecretName,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
swarm.ServiceWithName("svc"),
|
swarm.ServiceWithName("svc"),
|
||||||
|
@ -288,7 +291,7 @@ func TestTemplatedConfig(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
attach := swarm.ExecTask(t, d, task, types.ExecConfig{
|
attach := swarm.ExecTask(t, d, task, types.ExecConfig{
|
||||||
Cmd: []string{"/bin/cat", "/templated_config"},
|
Cmd: []string{"/bin/cat", "/" + templatedConfigName},
|
||||||
AttachStdout: true,
|
AttachStdout: true,
|
||||||
AttachStderr: true,
|
AttachStderr: true,
|
||||||
})
|
})
|
||||||
|
@ -303,7 +306,7 @@ func TestTemplatedConfig(t *testing.T) {
|
||||||
AttachStdout: true,
|
AttachStdout: true,
|
||||||
AttachStderr: true,
|
AttachStderr: true,
|
||||||
})
|
})
|
||||||
assertAttachedStream(t, attach, "tmpfs on /templated_config type tmpfs")
|
assertAttachedStream(t, attach, "tmpfs on /"+templatedConfigName+" type tmpfs")
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertAttachedStream(t *testing.T, attach types.HijackedResponse, expect string) {
|
func assertAttachedStream(t *testing.T, attach types.HijackedResponse, expect string) {
|
||||||
|
|
Loading…
Reference in New Issue