Browse code

use unique names for resources in integration tests of integration/secret package

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

Arash Deshmeh authored on 2018/06/01 19:25:00
Showing 1 changed files
... ...
@@ -29,7 +29,7 @@ func TestSecretInspect(t *testing.T) {
29 29
 
30 30
 	ctx := context.Background()
31 31
 
32
-	testName := "test_secret"
32
+	testName := "test_secret_" + t.Name()
33 33
 	secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
34 34
 
35 35
 	secret, _, err := client.SecretInspectWithRaw(context.Background(), secretID)
... ...
@@ -51,8 +51,8 @@ func TestSecretList(t *testing.T) {
51 51
 	defer client.Close()
52 52
 	ctx := context.Background()
53 53
 
54
-	testName0 := "test0"
55
-	testName1 := "test1"
54
+	testName0 := "test0_" + t.Name()
55
+	testName1 := "test1_" + t.Name()
56 56
 	testNames := []string{testName0, testName1}
57 57
 	sort.Strings(testNames)
58 58
 
... ...
@@ -137,7 +137,7 @@ func TestSecretsCreateAndDelete(t *testing.T) {
137 137
 	defer client.Close()
138 138
 	ctx := context.Background()
139 139
 
140
-	testName := "test_secret"
140
+	testName := "test_secret_" + t.Name()
141 141
 	secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
142 142
 
143 143
 	// create an already existin secret, daemon should return a status code of 409
... ...
@@ -160,7 +160,7 @@ func TestSecretsCreateAndDelete(t *testing.T) {
160 160
 	assert.Check(t, is.ErrorContains(err, "No such secret: non-existin"))
161 161
 
162 162
 	// Ported from original TestSecretsCreteaWithLabels
163
-	testName = "test_secret_with_labels"
163
+	testName = "test_secret_with_labels_" + t.Name()
164 164
 	secretID = createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), map[string]string{
165 165
 		"key1": "value1",
166 166
 		"key2": "value2",
... ...
@@ -184,7 +184,7 @@ func TestSecretsUpdate(t *testing.T) {
184 184
 	defer client.Close()
185 185
 	ctx := context.Background()
186 186
 
187
-	testName := "test_secret"
187
+	testName := "test_secret_" + t.Name()
188 188
 	secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
189 189
 
190 190
 	insp, _, err := client.SecretInspectWithRaw(ctx, secretID)
... ...
@@ -232,27 +232,30 @@ func TestTemplatedSecret(t *testing.T) {
232 232
 	defer client.Close()
233 233
 	ctx := context.Background()
234 234
 
235
+	referencedSecretName := "referencedsecret_" + t.Name()
235 236
 	referencedSecretSpec := swarmtypes.SecretSpec{
236 237
 		Annotations: swarmtypes.Annotations{
237
-			Name: "referencedsecret",
238
+			Name: referencedSecretName,
238 239
 		},
239 240
 		Data: []byte("this is a secret"),
240 241
 	}
241 242
 	referencedSecret, err := client.SecretCreate(ctx, referencedSecretSpec)
242 243
 	assert.Check(t, err)
243 244
 
245
+	referencedConfigName := "referencedconfig_" + t.Name()
244 246
 	referencedConfigSpec := swarmtypes.ConfigSpec{
245 247
 		Annotations: swarmtypes.Annotations{
246
-			Name: "referencedconfig",
248
+			Name: referencedConfigName,
247 249
 		},
248 250
 		Data: []byte("this is a config"),
249 251
 	}
250 252
 	referencedConfig, err := client.ConfigCreate(ctx, referencedConfigSpec)
251 253
 	assert.Check(t, err)
252 254
 
255
+	templatedSecretName := "templated_secret_" + t.Name()
253 256
 	secretSpec := swarmtypes.SecretSpec{
254 257
 		Annotations: swarmtypes.Annotations{
255
-			Name: "templated_secret",
258
+			Name: templatedSecretName,
256 259
 		},
257 260
 		Templating: &swarmtypes.Driver{
258 261
 			Name: "golang",
... ...
@@ -265,6 +268,7 @@ func TestTemplatedSecret(t *testing.T) {
265 265
 	templatedSecret, err := client.SecretCreate(ctx, secretSpec)
266 266
 	assert.Check(t, err)
267 267
 
268
+	serviceName := "svc_" + t.Name()
268 269
 	serviceID := swarm.CreateService(t, d,
269 270
 		swarm.ServiceWithSecret(
270 271
 			&swarmtypes.SecretReference{
... ...
@@ -275,7 +279,7 @@ func TestTemplatedSecret(t *testing.T) {
275 275
 					Mode: 0600,
276 276
 				},
277 277
 				SecretID:   templatedSecret.ID,
278
-				SecretName: "templated_secret",
278
+				SecretName: templatedSecretName,
279 279
 			},
280 280
 		),
281 281
 		swarm.ServiceWithConfig(
... ...
@@ -287,7 +291,7 @@ func TestTemplatedSecret(t *testing.T) {
287 287
 					Mode: 0600,
288 288
 				},
289 289
 				ConfigID:   referencedConfig.ID,
290
-				ConfigName: "referencedconfig",
290
+				ConfigName: referencedConfigName,
291 291
 			},
292 292
 		),
293 293
 		swarm.ServiceWithSecret(
... ...
@@ -299,10 +303,10 @@ func TestTemplatedSecret(t *testing.T) {
299 299
 					Mode: 0600,
300 300
 				},
301 301
 				SecretID:   referencedSecret.ID,
302
-				SecretName: "referencedsecret",
302
+				SecretName: referencedSecretName,
303 303
 			},
304 304
 		),
305
-		swarm.ServiceWithName("svc"),
305
+		swarm.ServiceWithName(serviceName),
306 306
 	)
307 307
 
308 308
 	var tasks []swarmtypes.Task
... ...
@@ -325,7 +329,7 @@ func TestTemplatedSecret(t *testing.T) {
325 325
 		AttachStderr: true,
326 326
 	})
327 327
 
328
-	expect := "SERVICE_NAME=svc\n" +
328
+	expect := "SERVICE_NAME=" + serviceName + "\n" +
329 329
 		"this is a secret\n" +
330 330
 		"this is a config\n"
331 331
 	assertAttachedStream(t, attach, expect)