Skip to content

Commit d65a1ce

Browse files
xiancaorjeberhard
authored andcommitted
backport - intermittent test failures when multiple tests download WIT at the same time to release/4.1
1 parent 26e0580 commit d65a1ce

File tree

3 files changed

+92
-56
lines changed

3 files changed

+92
-56
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.actions.impl.primitive;
@@ -34,8 +34,6 @@
3434
*/
3535

3636
public class Installer {
37-
private static final String TMP_FILE_NAME = "temp-download-file.out";
38-
3937

4038
private InstallParams params;
4139

@@ -189,7 +187,8 @@ && new File(downloadDir, getInstallerFileName(params.type())).exists()) {
189187
}
190188
if (params.unzip()) {
191189
// only unzip WIT once
192-
if (!(doesFileExist(IMAGE_TOOL)) || !(doesFileExist(REMOTECONSOLE_FILE))) {
190+
if ((params.type().equalsIgnoreCase(WIT) && !(doesFileExist(IMAGE_TOOL)))
191+
|| (params.type().equalsIgnoreCase(REMOTECONSOLE) && !(doesFileExist(REMOTECONSOLE_FILE)))) {
193192
unzipSucceeded = unzip(downloadDir);
194193
}
195194
}

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/WebLogicImageTool.java

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.actions.impl.primitive;
@@ -22,6 +22,8 @@
2222
import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.defaultInstallWdtParams;
2323
import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.defaultInstallWitParams;
2424
import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.installWdtParams;
25+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
26+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
2527
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
2628

2729

@@ -96,34 +98,44 @@ public boolean updateImage() {
9698
public String inspectImage(String imageName, String imageTag) {
9799
String output = null;
98100
// download WIT if it is not in the expected location
99-
if (!downloadWit()) {
100-
return output;
101-
}
101+
testUntil(
102+
withStandardRetryPolicy,
103+
() -> downloadWit(),
104+
getLogger(),
105+
"downloading WIT succeeds");
102106

103107
// download WDT if it is not in the expected location
104-
if (!downloadWdt()) {
105-
return output;
106-
}
108+
testUntil(
109+
withStandardRetryPolicy,
110+
() -> downloadWdt(),
111+
getLogger(),
112+
"downloading WDT succeeds");
107113

108114
// delete the old cache entry for the WDT installer
109-
if (!deleteEntry()) {
110-
return output;
111-
}
115+
testUntil(
116+
withStandardRetryPolicy,
117+
() -> deleteEntry(),
118+
getLogger(),
119+
"deleting cache entry for WDT installer succeeds");
112120

113121
// add the WDT installer that we just downloaded into WIT cache entry
114-
if (!addInstaller()) {
115-
return output;
116-
}
122+
testUntil(
123+
withStandardRetryPolicy,
124+
() -> addInstaller(),
125+
getLogger(),
126+
"adding WDT installer to the cache succeeds");
127+
117128
ExecResult result = Command.withParams(
118129
defaultCommandParams()
119130
.command(buildInspectWitCommand(imageName,
120131
imageTag))
121132
.redirect(params.redirect()))
122133
.executeAndReturnResult();
123-
// check exitValue to determine if the command execution has failed.
124134

135+
// check exitValue to determine if the command execution has failed.
125136
if (result.exitValue() != 0) {
126137
getLogger().severe("The command execution failed because it returned non-zero exit value: {0}.", result);
138+
output = result.stderr();
127139
} else {
128140
getLogger().info("The command execution succeeded with result: {0}.", result);
129141
output = result.stdout();
@@ -339,35 +351,41 @@ public boolean createAuxImage() {
339351
*/
340352
public ExecResult createAuxImageAndReturnResult() {
341353
// download WIT if it is not in the expected location
342-
if (!downloadWit()) {
343-
return new ExecResult(1, "failed to download WIT", "failed to download WIT");
344-
}
354+
testUntil(
355+
withStandardRetryPolicy,
356+
() -> downloadWit(),
357+
getLogger(),
358+
"downloading WIT succeeds");
345359

346360
// download WDT if it is not in the expected location
347361
if (params.wdtVersion() != null && !Objects.equals(params.wdtVersion(), "NONE")) {
348-
if (!downloadWdt(params.wdtVersion())) {
349-
return new ExecResult(1, "failed to download WDT with version " + params.wdtVersion(),
350-
"failed to download WDT with version " + params.wdtVersion());
351-
352-
}
362+
testUntil(
363+
withStandardRetryPolicy,
364+
() -> downloadWdt(params.wdtVersion()),
365+
getLogger(),
366+
"downloading WDT with version {0} succeeds",
367+
params.wdtVersion());
353368
} else {
354-
if (!downloadWdt()) {
355-
return new ExecResult(1, "failed to download latest WDT",
356-
"failed to download latest WDT");
357-
}
369+
testUntil(
370+
withStandardRetryPolicy,
371+
() -> downloadWdt(),
372+
getLogger(),
373+
"downloading latest WDT succeeds");
358374
}
359375

360376
// delete the old cache entry for the WDT installer
361-
if (!deleteEntry()) {
362-
return new ExecResult(1, "failed to delete cache entry for the WDT installer",
363-
"failed to delete cache entry for the WDT installer");
364-
}
377+
testUntil(
378+
withStandardRetryPolicy,
379+
() -> deleteEntry(),
380+
getLogger(),
381+
"deleting cache entry for WDT installer succeeds");
365382

366383
// add the WDT installer that we just downloaded into WIT cache entry
367-
if (!addInstaller()) {
368-
return new ExecResult(1, "failed to add WDT installer to the cache",
369-
"failed to add WDT installer to the cache");
370-
}
384+
testUntil(
385+
withStandardRetryPolicy,
386+
() -> addInstaller(),
387+
getLogger(),
388+
"adding WDT installer to the cache succeeds");
371389

372390
return Command.withParams(
373391
defaultCommandParams()

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

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import static oracle.weblogic.kubernetes.assertions.TestAssertions.doesImageExist;
6363
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getDateAndTimeStamp;
6464
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
65+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
6566
import static oracle.weblogic.kubernetes.utils.FileUtils.checkDirectory;
6667
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
6768
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
@@ -421,24 +422,34 @@ public static String createImageAndVerify(String imageNameBase,
421422
// build an image using WebLogic Image Tool
422423
logger.info("Creating image {0} using model directory {1}", image, MODEL_DIR);
423424
boolean result = false;
425+
424426
if (!modelType) { //create a domain home in image image
425-
result = createImage(
426-
new WitParams()
427-
.baseImageName(baseImageName)
428-
.baseImageTag(baseImageTag)
429-
.domainType(domainType)
430-
.modelImageName(imageName)
431-
.modelImageTag(imageTag)
432-
.modelFiles(wdtModelList)
433-
.modelVariableFiles(modelPropList)
434-
.modelArchiveFiles(archiveList)
435-
.domainHome(WDT_IMAGE_DOMAINHOME_BASE_DIR + "/" + domainHome)
436-
.wdtModelOnly(modelType)
437-
.wdtOperation("CREATE")
438-
.wdtVersion(WDT_VERSION)
439-
.target(witTarget)
440-
.env(env)
441-
.redirect(true));
427+
WitParams witParams = new WitParams()
428+
.baseImageName(baseImageName)
429+
.baseImageTag(baseImageTag)
430+
.domainType(domainType)
431+
.modelImageName(imageName)
432+
.modelImageTag(imageTag)
433+
.modelFiles(wdtModelList)
434+
.modelVariableFiles(modelPropList)
435+
.modelArchiveFiles(archiveList)
436+
.domainHome(WDT_IMAGE_DOMAINHOME_BASE_DIR + "/" + domainHome)
437+
.wdtModelOnly(modelType)
438+
.wdtOperation("CREATE")
439+
.wdtVersion(WDT_VERSION)
440+
.target(witTarget)
441+
.env(env)
442+
.redirect(true);
443+
444+
testUntil(
445+
withStandardRetryPolicy,
446+
() -> createImage(witParams),
447+
getLogger(),
448+
"creating image {0}:{1} succeeds",
449+
imageName,
450+
imageTag);
451+
452+
result = true;
442453
} else {
443454
WitParams witParams = new WitParams()
444455
.baseImageName(baseImageName)
@@ -470,7 +481,15 @@ public static String createImageAndVerify(String imageNameBase,
470481
witParams.target("OpenShift");
471482
}
472483

473-
result = createImage(witParams);
484+
testUntil(
485+
withStandardRetryPolicy,
486+
() -> createImage(witParams),
487+
getLogger(),
488+
"creating image {0}:{1} succeeds",
489+
imageName,
490+
imageTag);
491+
492+
result = true;
474493
}
475494

476495
assertTrue(result, String.format("Failed to create the image %s using WebLogic Image Tool", image));

0 commit comments

Comments
 (0)