Skip to content

Commit 3028de2

Browse files
committed
Overwrite the existing config files
1 parent 51a106e commit 3028de2

File tree

1 file changed

+8
-7
lines changed
  • integration-tests/src/test/java/oracle/kubernetes/operator

1 file changed

+8
-7
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/SitConfig.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public class SitConfig extends BaseTest {
4343
private static String mysqlYamlFile = "";
4444
private static String domainYaml;
4545
private static String JDBC_RES_SCRIPT;
46+
private static String oldSecret = "test-secrets";
47+
private static String newSecret = "test-secrets-new";
4648

4749
/**
4850
* This method gets called only once before any of the test methods are executed. It does the
@@ -84,7 +86,7 @@ protected static void staticPrepare(String domainInputYaml, String domainScript)
8486
"jms-ClusterJmsSystemResource.xml",
8587
"version.txt"
8688
};
87-
copySitConfigFiles(files, "test-secrets");
89+
copySitConfigFiles(files, oldSecret);
8890
// create weblogic domain with configOverrides
8991
domain = createSitConfigDomain(domainInputYaml, domainScript);
9092
Assert.assertNotNull(domain);
@@ -183,13 +185,13 @@ private static void copySitConfigFiles(String files[], String secretName) throws
183185
logger.log(Level.INFO, "Copying {0}", path.toString());
184186
String content = new String(Files.readAllBytes(path), charset);
185187
content = content.replaceAll("JDBC_URL", JDBC_URL);
186-
content = content.replaceAll("test-secrets", secretName);
188+
content = content.replaceAll(oldSecret, secretName);
187189
if (getWeblogicImageTag().contains(PS3_TAG)) {
188190
content = content.replaceAll(JDBC_DRIVER_NEW, JDBC_DRIVER_OLD);
189191
}
190192
path = Paths.get(dstDir, file);
191193
logger.log(Level.INFO, "to {0}", path.toString());
192-
Files.write(path, content.getBytes(charset));
194+
Files.write(path, content.getBytes(charset), StandardOpenOption.TRUNCATE_EXISTING);
193195
}
194196
}
195197

@@ -381,7 +383,7 @@ protected void testConfigOverrideAfterDomainStartup() throws Exception {
381383
Paths.get(srcDir, "config_1.xml"),
382384
Paths.get(dstDir, "config.xml"),
383385
StandardCopyOption.REPLACE_EXISTING);
384-
recreateConfigMapandRestart("test-secrets", "test-secrets");
386+
recreateConfigMapandRestart(oldSecret, oldSecret);
385387
transferTests();
386388
ExecResult result =
387389
TestUtils.exec(
@@ -416,7 +418,7 @@ protected void testOverrideJdbcResourceAfterDomainStart() throws Exception {
416418
Paths.get(srcDir, "jdbc-JdbcTestDataSource-1.xml"),
417419
Paths.get(dstDir, "jdbc-JdbcTestDataSource-1.xml"),
418420
StandardCopyOption.REPLACE_EXISTING);
419-
recreateConfigMapandRestart("test-secrets", "test-secrets");
421+
recreateConfigMapandRestart(oldSecret, oldSecret);
420422
transferTests();
421423
ExecResult result =
422424
TestUtils.exec(
@@ -444,10 +446,9 @@ protected void testOverrideJdbcResourceWithNewSecret() throws Exception {
444446
logTestBegin(testMethod);
445447
// recreate the map with new situational config files
446448
String[] files = {"config.xml", "jdbc-JdbcTestDataSource-0.xml"};
447-
String newSecret = "test-secrets-new";
448449
try {
449450
copySitConfigFiles(files, newSecret);
450-
recreateConfigMapandRestart("test-secrets", newSecret);
451+
recreateConfigMapandRestart(oldSecret, newSecret);
451452
transferTests();
452453
ExecResult result =
453454
TestUtils.exec(

0 commit comments

Comments
 (0)