@@ -48,6 +48,7 @@ func TestMultiNode(t *testing.T) {
48
48
{"DeleteNode" , validateDeleteNodeFromMultiNode },
49
49
{"StopMultiNode" , validateStopMultiNodeCluster },
50
50
{"RestartMultiNode" , validateRestartMultiNodeCluster },
51
+ {"ValidateNameConflict" , validatNameConflict },
51
52
}
52
53
for _ , tc := range tests {
53
54
tc := tc
@@ -308,3 +309,39 @@ func validateDeleteNodeFromMultiNode(ctx context.Context, t *testing.T, profile
308
309
t .Errorf ("expected 2 nodes Ready status to be True, got %v" , rr .Output ())
309
310
}
310
311
}
312
+
313
+ func validatNameConflict (ctx context.Context , t * testing.T , profile string ) {
314
+ rr , err := Run (t , exec .CommandContext (ctx , Target (), "node" , "list" , "-p" , profile ))
315
+ if err != nil {
316
+ t .Errorf ("failed to run node list. args %q : %v" , rr .Command (), err )
317
+ }
318
+ curNodeNum := strings .Count (rr .Stdout .String (), profile )
319
+
320
+ // Start new profile. It's expected failture
321
+ profileName := fmt .Sprintf ("%s-m0%d" , profile , curNodeNum )
322
+ startArgs := append ([]string {"start" , "-p" , profileName }, StartArgs ()... )
323
+ rr , err = Run (t , exec .CommandContext (ctx , Target (), startArgs ... ))
324
+ if err == nil {
325
+ t .Errorf ("expected start profile command to fail. args %q" , rr .Command ())
326
+ }
327
+
328
+ // Start new profile temporary profile to conflict node name.
329
+ profileName = fmt .Sprintf ("%s-m0%d" , profile , curNodeNum + 1 )
330
+ startArgs = append ([]string {"start" , "-p" , profileName }, StartArgs ()... )
331
+ rr , err = Run (t , exec .CommandContext (ctx , Target (), startArgs ... ))
332
+ if err != nil {
333
+ t .Errorf ("failed to start profile. args %q : %v" , rr .Command (), err )
334
+ }
335
+
336
+ // Add a node to the current cluster. It's expected failture
337
+ addArgs := []string {"node" , "add" , "-p" , profile }
338
+ rr , err = Run (t , exec .CommandContext (ctx , Target (), addArgs ... ))
339
+ if err == nil {
340
+ t .Errorf ("expected add node command to fail. args %q : %v" , rr .Command (), err )
341
+ }
342
+
343
+ rr , err = Run (t , exec .CommandContext (ctx , Target (), "delete" , "-p" , profileName ))
344
+ if err != nil {
345
+ t .Logf ("failed to clean temporary profile. args %q : %v" , rr .Command (), err )
346
+ }
347
+ }
0 commit comments