@@ -387,7 +387,7 @@ public void testConfigOverrideAfterDomainStartup() throws Exception {
387
387
Paths .get (srcDir , "config_1.xml" ),
388
388
Paths .get (dstDir , "config.xml" ),
389
389
StandardCopyOption .REPLACE_EXISTING );
390
- recreateConfigMapandRestart ("test-secrets" );
390
+ recreateConfigMapandRestart ("test-secrets" , "test-secrets" );
391
391
transferTests ();
392
392
ExecResult result =
393
393
TestUtils .exec (
@@ -423,7 +423,7 @@ public void testOverrideJdbcResourceAfterDomainStart() throws Exception {
423
423
Paths .get (srcDir , "jdbc-JdbcTestDataSource-1.xml" ),
424
424
Paths .get (dstDir , "jdbc-JdbcTestDataSource-1.xml" ),
425
425
StandardCopyOption .REPLACE_EXISTING );
426
- recreateConfigMapandRestart ("test-secrets" );
426
+ recreateConfigMapandRestart ("test-secrets" , "test-secrets" );
427
427
transferTests ();
428
428
ExecResult result =
429
429
TestUtils .exec (
@@ -452,10 +452,10 @@ public void testOverrideJdbcResourceWithNewSecret() throws Exception {
452
452
logTestBegin (testMethod );
453
453
// recreate the map with new situational config files
454
454
String [] files = {"config.xml" , "jdbc-JdbcTestDataSource-0.xml" };
455
- String secretName = "test-secrets-new" ;
455
+ String newSecret = "test-secrets-new" ;
456
456
try {
457
- copySitConfigFiles (files , secretName );
458
- recreateConfigMapandRestart (secretName );
457
+ copySitConfigFiles (files , newSecret );
458
+ recreateConfigMapandRestart ("test-secrets" , newSecret );
459
459
transferTests ();
460
460
ExecResult result =
461
461
TestUtils .exec (
@@ -473,7 +473,7 @@ public void testOverrideJdbcResourceWithNewSecret() throws Exception {
473
473
logger .log (Level .INFO , "SUCCESS - {0}" , testMethod );
474
474
} finally {
475
475
copySitConfigFiles (files , "test-secrets" );
476
- recreateConfigMapandRestart (secretName );
476
+ recreateConfigMapandRestart ("test-secrets-new" , "test-secrets" );
477
477
}
478
478
}
479
479
@@ -506,28 +506,31 @@ private void createJdbcResource() throws Exception {
506
506
*
507
507
* @throws Exception when pods restart fail
508
508
*/
509
- private void recreateConfigMapandRestart (String secretName ) throws Exception {
510
- String content = new String (Files .readAllBytes (Paths .get (domainYaml )), StandardCharsets .UTF_8 );
511
- content = content .replaceAll ("test-secrets" , secretName );
512
- Files .write (
513
- Paths .get (domainYaml ),
514
- content .getBytes (StandardCharsets .UTF_8 ),
515
- StandardOpenOption .TRUNCATE_EXISTING );
509
+ private void recreateConfigMapandRestart (String oldSecret , String newSecret ) throws Exception {
510
+ if (!oldSecret .equals (newSecret )) {
511
+ String content =
512
+ new String (Files .readAllBytes (Paths .get (domainYaml )), StandardCharsets .UTF_8 );
513
+ content = content .replaceAll (oldSecret , newSecret );
514
+ Files .write (
515
+ Paths .get (domainYaml ),
516
+ content .getBytes (StandardCharsets .UTF_8 ),
517
+ StandardOpenOption .TRUNCATE_EXISTING );
516
518
517
- TestUtils .exec ("kubectl delete secret " + domain .getDomainUid () + "-test-secrets" , true );
518
- String cmd =
519
- "kubectl -n "
520
- + domain .getDomainNs ()
521
- + " create secret generic "
522
- + domain .getDomainUid ()
523
- + "-"
524
- + secretName
525
- + " --from-literal=hostname="
526
- + TestUtils .getHostName ()
527
- + " --from-literal=dbusername=root"
528
- + " --from-literal=dbpassword=root123" ;
529
- TestUtils .exec (cmd , true );
530
- TestUtils .exec ("kubectl apply -f " + domainYaml , true );
519
+ TestUtils .exec ("kubectl delete secret " + domain .getDomainUid () + "-" + oldSecret , true );
520
+ String cmd =
521
+ "kubectl -n "
522
+ + domain .getDomainNs ()
523
+ + " create secret generic "
524
+ + domain .getDomainUid ()
525
+ + "-"
526
+ + newSecret
527
+ + " --from-literal=hostname="
528
+ + TestUtils .getHostName ()
529
+ + " --from-literal=dbusername=root"
530
+ + " --from-literal=dbpassword=root123" ;
531
+ TestUtils .exec (cmd , true );
532
+ TestUtils .exec ("kubectl apply -f " + domainYaml , true );
533
+ }
531
534
532
535
int clusterReplicas =
533
536
TestUtils .getClusterReplicas (DOMAINUID , domain .getClusterName (), domain .getDomainNs ());
@@ -536,7 +539,7 @@ private void recreateConfigMapandRestart(String secretName) throws Exception {
536
539
TestUtils .kubectlpatch (DOMAINUID , domain .getDomainNs (), patchStr );
537
540
domain .verifyServerPodsDeleted (clusterReplicas );
538
541
539
- cmd =
542
+ String cmd =
540
543
"kubectl create configmap "
541
544
+ DOMAINUID
542
545
+ "-sitconfigcm --from-file="
0 commit comments