Skip to content

Commit dc33089

Browse files
authored
Nightly 4.0 ItWlsSamples failures fix (#3713)
* Nightly 4.0 ItWlsSamples failures fix
1 parent 223e85e commit dc33089

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItWlsSamples.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
5454
import static oracle.weblogic.kubernetes.TestConstants.TEST_NGINX_IMAGE_NAME;
5555
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
56+
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG_DEFAULT;
5657
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
5758
import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR;
5859
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
@@ -227,7 +228,7 @@ void testSampleDomainInImage(String model) {
227228
// update domainHomeImageBase with right values in create-domain-inputs.yaml
228229
assertDoesNotThrow(() -> {
229230
replaceStringInFile(get(sampleBase.toString(), "create-domain-inputs.yaml").toString(),
230-
"domainHomeImageBase: container-registry.oracle.com/middleware/weblogic:" + WEBLOGIC_IMAGE_TAG,
231+
"domainHomeImageBase: container-registry.oracle.com/middleware/weblogic:" + WEBLOGIC_IMAGE_TAG_DEFAULT,
231232
"domainHomeImageBase: " + WEBLOGIC_IMAGE_TO_USE_IN_SPEC);
232233
replaceStringInFile(get(sampleBase.toString(), "create-domain-inputs.yaml").toString(),
233234
"#image:",
@@ -302,7 +303,7 @@ void testSampleDomainInPv(String model) {
302303
"createDomainFilesDir: wlst", "createDomainFilesDir: "
303304
+ script);
304305
replaceStringInFile(get(sampleBase.toString(), "create-domain-inputs.yaml").toString(),
305-
"image: container-registry.oracle.com/middleware/weblogic:" + WEBLOGIC_IMAGE_TAG,
306+
"image: container-registry.oracle.com/middleware/weblogic:" + WEBLOGIC_IMAGE_TAG_DEFAULT,
306307
"image: " + WEBLOGIC_IMAGE_TO_USE_IN_SPEC);
307308
});
308309

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.io.FileNotFoundException;
88
import java.io.FileOutputStream;
99
import java.io.IOException;
10-
import java.nio.charset.Charset;
1110
import java.nio.charset.StandardCharsets;
1211
import java.nio.file.FileVisitResult;
1312
import java.nio.file.Files;
@@ -469,15 +468,16 @@ public static void replaceStringInFile(String filePath, String regex, String rep
469468
throws IOException {
470469
LoggingFacade logger = getLogger();
471470
Path src = Paths.get(filePath);
472-
logger.info("Replacing {0} in {1}", regex, src.toString());
473-
Charset charset = StandardCharsets.UTF_8;
474-
String content = new String(Files.readAllBytes(src), charset);
475-
String newcontent = content.replaceAll(regex, replacement);
476-
logger.info("with {0}", replacement);
477-
if (content.equals(newcontent)) {
471+
logger.info("Replacing {0} in {1} with {2}", regex, src.toString(), replacement);
472+
String content = new String(Files.readAllBytes(src), StandardCharsets.UTF_8);
473+
if (!content.contains(regex)) {
478474
logger.info("search string {0} not found to replace with {1}", regex, replacement);
479475
}
480-
Files.write(src, newcontent.getBytes(charset));
476+
long oldModified = src.toFile().lastModified();
477+
Files.write(src, content.replaceAll(regex, replacement).getBytes(StandardCharsets.UTF_8));
478+
if (oldModified == src.toFile().lastModified()) {
479+
logger.info("No modification was done to the file");
480+
}
481481
}
482482

483483
/**

0 commit comments

Comments
 (0)