Skip to content

Commit 25f2782

Browse files
committed
Fix nightly build dependency on FMW installer
1 parent 32305f2 commit 25f2782

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/logging/ConsoleFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ConsoleFormatter extends Formatter {
2222

2323
static {
2424
// if user is redirecting output, do not print color codes
25-
if (System.console() == null) {
25+
if (System.getProperty("WLSIMG_IT_ANSICOLOR") == null && System.console() == null) {
2626
AnsiColor.disable();
2727
} else {
2828
// check logging properties to see if the user wants to disable color output

tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,36 @@ void cacheAddInstallerWdt(TestInfo testInfo) throws IOException, InterruptedExce
543543
}
544544
}
545545

546+
@Test
547+
@Order(8)
548+
@Tag("nightly")
549+
@Tag("cache")
550+
@DisplayName("Add FMW installer to cache")
551+
void cacheAddInstallerFmw(TestInfo testInfo) throws Exception {
552+
// add fmw installer to the cache
553+
String addCommand = new CacheCommand()
554+
.addInstaller(true)
555+
.type("fmw")
556+
.version(WLS_VERSION)
557+
.path(Paths.get(STAGING_DIR, FMW_INSTALLER))
558+
.build();
559+
560+
561+
try (PrintWriter out = getTestMethodWriter(testInfo)) {
562+
CommandResult addResult = Runner.run(addCommand, out, logger);
563+
// the process return code for addInstaller should be 0
564+
assertEquals(0, addResult.exitValue(), "for command: " + addCommand);
565+
566+
// verify the result
567+
String listCommand = new CacheCommand().listItems(true).build();
568+
CommandResult listResult = Runner.run(listCommand, out, logger);
569+
// the process return code for listItems should be 0
570+
assertEquals(0, listResult.exitValue(), "for command: " + listCommand);
571+
// output should show newly added WLS installer
572+
assertTrue(listResult.stdout().contains("fmw_" + WLS_VERSION + "="));
573+
}
574+
}
575+
546576
/**
547577
* create a WLS image with default WLS version.
548578
*
@@ -768,19 +798,8 @@ void createFmwImgFullInternetAccess(TestInfo testInfo) throws Exception {
768798
// the process return code for addInstaller should be 0
769799
assertEquals(0, addNewJdkResult.exitValue(), "for command: " + addNewJdkCmd);
770800

771-
// add fmw installer to the cache
772-
String addCommand = new CacheCommand()
773-
.addInstaller(true)
774-
.type("fmw")
775-
.version(WLS_VERSION)
776-
.path(Paths.get(STAGING_DIR, FMW_INSTALLER))
777-
.build();
778-
CommandResult addResult = Runner.run(addCommand, out, logger);
779-
// the process return code for addInstaller should be 0
780-
assertEquals(0, addResult.exitValue(), "for command: " + addCommand);
781-
782801
String tagName = build_tag + ":" + getMethodName(testInfo);
783-
// create an an image with FMW and the latest PSU using ARU to download the patch
802+
// create an image with FMW and the latest PSU using ARU to download the patch
784803
String command = new CreateCommand()
785804
.tag(tagName)
786805
.jdkVersion(JDK_VERSION_8u212)

tests/src/test/java/com/oracle/weblogic/imagetool/tests/extensions/LoggingExtension.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.util.List;
77

8+
import com.oracle.weblogic.imagetool.logging.AnsiColor;
89
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
910
import com.oracle.weblogic.imagetool.tests.annotations.Logger;
1011
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
@@ -14,10 +15,16 @@
1415

1516
public class LoggingExtension implements BeforeTestExecutionCallback, AfterTestExecutionCallback {
1617

18+
// emphasis at the beginning and the end of a line.
19+
public static final String EM = "==========";
20+
private static final String BEGIN = EM + AnsiColor.BRIGHT_GREEN;
21+
private static final String FAIL = EM + AnsiColor.BRIGHT_RED;
22+
private static final String END = AnsiColor.RESET + EM;
23+
1724
@Override
1825
public void beforeTestExecution(ExtensionContext context) throws Exception {
1926
getLogger(context.getRequiredTestClass())
20-
.info("========== Starting test [{0}] method={1} ==========",
27+
.info(BEGIN + " Starting test [{0}] method={1} " + END,
2128
context.getDisplayName(),
2229
context.getRequiredTestMethod().getName());
2330
}
@@ -28,11 +35,11 @@ public void afterTestExecution(ExtensionContext context) throws Exception {
2835
boolean testFailed = context.getExecutionException().isPresent();
2936
LoggingFacade logger = getLogger((context.getRequiredTestClass()));
3037
if (testFailed) {
31-
logger.severe("========== FAILED test [{0}] method={1} ==========",
38+
logger.severe(FAIL + " FAILED test [{0}] method={1} " + END,
3239
context.getDisplayName(), context.getRequiredTestMethod().getName());
3340
logger.severe(context.getExecutionException().get().getMessage());
3441
} else {
35-
logger.info("========== Finished test [{0}] method={1} ==========",
42+
logger.info(EM + " Finished test [{0}] method={1} " + EM,
3643
context.getDisplayName(), context.getRequiredTestMethod().getName());
3744
}
3845
}

tests/src/test/java/com/oracle/weblogic/imagetool/tests/extensions/TimingExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class TimingExtension implements BeforeTestExecutionCallback, AfterTestEx
1515
private static final LoggingFacade logger = LoggingFactory.getLogger(TimingExtension.class);
1616

1717
private static final String START_TIME = "start time";
18+
private static final String EM = LoggingExtension.EM;
1819

1920
@Override
2021
public void beforeTestExecution(ExtensionContext context) throws Exception {
@@ -29,7 +30,7 @@ public void afterTestExecution(ExtensionContext context) throws Exception {
2930
long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(minutes);
3031

3132
LoggingExtension.getLogger((context.getRequiredTestClass()))
32-
.info("========== Test duration [{0}] method={1}: {2} min, {3} sec ==========",
33+
.info(EM + " Test duration [{0}] method={1}: {2} min, {3} sec " + EM,
3334
context.getDisplayName(),
3435
context.getRequiredTestMethod().getName(),
3536
minutes, seconds);

0 commit comments

Comments
 (0)