Browse code

integration tests under integration/config use unique names when creating resources

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>

Arash Deshmeh authored on 2018/04/06 19:06:02
Showing 1 changed files
... ...
@@ -36,8 +36,8 @@ func TestConfigList(t *testing.T) {
36 36
 	assert.NilError(t, err)
37 37
 	assert.Check(t, is.Equal(len(configs), 0))
38 38
 
39
-	testName0 := "test0"
40
-	testName1 := "test1"
39
+	testName0 := "test0-" + t.Name()
40
+	testName1 := "test1-" + t.Name()
41 41
 	testNames := []string{testName0, testName1}
42 42
 	sort.Strings(testNames)
43 43
 
... ...
@@ -122,7 +122,7 @@ func TestConfigsCreateAndDelete(t *testing.T) {
122 122
 
123 123
 	ctx := context.Background()
124 124
 
125
-	testName := "test_config"
125
+	testName := "test_config-" + t.Name()
126 126
 
127 127
 	// This test case is ported from the original TestConfigsCreate
128 128
 	configID := createConfig(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
... ...
@@ -150,7 +150,7 @@ func TestConfigsUpdate(t *testing.T) {
150 150
 
151 151
 	ctx := context.Background()
152 152
 
153
-	testName := "test_config"
153
+	testName := "test_config-" + t.Name()
154 154
 
155 155
 	// This test case is ported from the original TestConfigsCreate
156 156
 	configID := createConfig(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
... ...
@@ -200,27 +200,30 @@ func TestTemplatedConfig(t *testing.T) {
200 200
 	ctx := context.Background()
201 201
 	client := swarm.GetClient(t, d)
202 202
 
203
+	referencedSecretName := "referencedsecret-" + t.Name()
203 204
 	referencedSecretSpec := swarmtypes.SecretSpec{
204 205
 		Annotations: swarmtypes.Annotations{
205
-			Name: "referencedsecret",
206
+			Name: referencedSecretName,
206 207
 		},
207 208
 		Data: []byte("this is a secret"),
208 209
 	}
209 210
 	referencedSecret, err := client.SecretCreate(ctx, referencedSecretSpec)
210 211
 	assert.Check(t, err)
211 212
 
213
+	referencedConfigName := "referencedconfig-" + t.Name()
212 214
 	referencedConfigSpec := swarmtypes.ConfigSpec{
213 215
 		Annotations: swarmtypes.Annotations{
214
-			Name: "referencedconfig",
216
+			Name: referencedConfigName,
215 217
 		},
216 218
 		Data: []byte("this is a config"),
217 219
 	}
218 220
 	referencedConfig, err := client.ConfigCreate(ctx, referencedConfigSpec)
219 221
 	assert.Check(t, err)
220 222
 
223
+	templatedConfigName := "templated_config-" + t.Name()
221 224
 	configSpec := swarmtypes.ConfigSpec{
222 225
 		Annotations: swarmtypes.Annotations{
223
-			Name: "templated_config",
226
+			Name: templatedConfigName,
224 227
 		},
225 228
 		Templating: &swarmtypes.Driver{
226 229
 			Name: "golang",
... ...
@@ -237,13 +240,13 @@ func TestTemplatedConfig(t *testing.T) {
237 237
 		swarm.ServiceWithConfig(
238 238
 			&swarmtypes.ConfigReference{
239 239
 				File: &swarmtypes.ConfigReferenceFileTarget{
240
-					Name: "/templated_config",
240
+					Name: "/" + templatedConfigName,
241 241
 					UID:  "0",
242 242
 					GID:  "0",
243 243
 					Mode: 0600,
244 244
 				},
245 245
 				ConfigID:   templatedConfig.ID,
246
-				ConfigName: "templated_config",
246
+				ConfigName: templatedConfigName,
247 247
 			},
248 248
 		),
249 249
 		swarm.ServiceWithConfig(
... ...
@@ -255,7 +258,7 @@ func TestTemplatedConfig(t *testing.T) {
255 255
 					Mode: 0600,
256 256
 				},
257 257
 				ConfigID:   referencedConfig.ID,
258
-				ConfigName: "referencedconfig",
258
+				ConfigName: referencedConfigName,
259 259
 			},
260 260
 		),
261 261
 		swarm.ServiceWithSecret(
... ...
@@ -267,7 +270,7 @@ func TestTemplatedConfig(t *testing.T) {
267 267
 					Mode: 0600,
268 268
 				},
269 269
 				SecretID:   referencedSecret.ID,
270
-				SecretName: "referencedsecret",
270
+				SecretName: referencedSecretName,
271 271
 			},
272 272
 		),
273 273
 		swarm.ServiceWithName("svc"),
... ...
@@ -288,7 +291,7 @@ func TestTemplatedConfig(t *testing.T) {
288 288
 	})
289 289
 
290 290
 	attach := swarm.ExecTask(t, d, task, types.ExecConfig{
291
-		Cmd:          []string{"/bin/cat", "/templated_config"},
291
+		Cmd:          []string{"/bin/cat", "/" + templatedConfigName},
292 292
 		AttachStdout: true,
293 293
 		AttachStderr: true,
294 294
 	})
... ...
@@ -303,7 +306,7 @@ func TestTemplatedConfig(t *testing.T) {
303 303
 		AttachStdout: true,
304 304
 		AttachStderr: true,
305 305
 	})
306
-	assertAttachedStream(t, attach, "tmpfs on /templated_config type tmpfs")
306
+	assertAttachedStream(t, attach, "tmpfs on /"+templatedConfigName+" type tmpfs")
307 307
 }
308 308
 
309 309
 func assertAttachedStream(t *testing.T, attach types.HijackedResponse, expect string) {