@@ -387,7 +387,7 @@ public void testConfigOverrideAfterDomainStartup() throws Exception {
387387 Paths .get (srcDir , "config_1.xml" ),
388388 Paths .get (dstDir , "config.xml" ),
389389 StandardCopyOption .REPLACE_EXISTING );
390- recreateConfigMapandRestart ("test-secrets" );
390+ recreateConfigMapandRestart ("test-secrets" , "test-secrets" );
391391 transferTests ();
392392 ExecResult result =
393393 TestUtils .exec (
@@ -423,7 +423,7 @@ public void testOverrideJdbcResourceAfterDomainStart() throws Exception {
423423 Paths .get (srcDir , "jdbc-JdbcTestDataSource-1.xml" ),
424424 Paths .get (dstDir , "jdbc-JdbcTestDataSource-1.xml" ),
425425 StandardCopyOption .REPLACE_EXISTING );
426- recreateConfigMapandRestart ("test-secrets" );
426+ recreateConfigMapandRestart ("test-secrets" , "test-secrets" );
427427 transferTests ();
428428 ExecResult result =
429429 TestUtils .exec (
@@ -452,10 +452,10 @@ public void testOverrideJdbcResourceWithNewSecret() throws Exception {
452452 logTestBegin (testMethod );
453453 // recreate the map with new situational config files
454454 String [] files = {"config.xml" , "jdbc-JdbcTestDataSource-0.xml" };
455- String secretName = "test-secrets-new" ;
455+ String newSecret = "test-secrets-new" ;
456456 try {
457- copySitConfigFiles (files , secretName );
458- recreateConfigMapandRestart (secretName );
457+ copySitConfigFiles (files , newSecret );
458+ recreateConfigMapandRestart ("test-secrets" , newSecret );
459459 transferTests ();
460460 ExecResult result =
461461 TestUtils .exec (
@@ -473,7 +473,7 @@ public void testOverrideJdbcResourceWithNewSecret() throws Exception {
473473 logger .log (Level .INFO , "SUCCESS - {0}" , testMethod );
474474 } finally {
475475 copySitConfigFiles (files , "test-secrets" );
476- recreateConfigMapandRestart (secretName );
476+ recreateConfigMapandRestart ("test-secrets-new" , "test-secrets" );
477477 }
478478 }
479479
@@ -506,28 +506,31 @@ private void createJdbcResource() throws Exception {
506506 *
507507 * @throws Exception when pods restart fail
508508 */
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 );
516518
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+ }
531534
532535 int clusterReplicas =
533536 TestUtils .getClusterReplicas (DOMAINUID , domain .getClusterName (), domain .getDomainNs ());
@@ -536,7 +539,7 @@ private void recreateConfigMapandRestart(String secretName) throws Exception {
536539 TestUtils .kubectlpatch (DOMAINUID , domain .getDomainNs (), patchStr );
537540 domain .verifyServerPodsDeleted (clusterReplicas );
538541
539- cmd =
542+ String cmd =
540543 "kubectl create configmap "
541544 + DOMAINUID
542545 + "-sitconfigcm --from-file="
0 commit comments