Skip to content

Commit

Permalink
Merge branch 'cache-fmw-installer' into 'main'
Browse files Browse the repository at this point in the history
Fix nightly build dependency on FMW installer

See merge request weblogic-cloud/weblogic-image-tool!465
  • Loading branch information
ddsharpe committed Mar 4, 2024
2 parents 32305f2 + 25f2782 commit 4480187
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ConsoleFormatter extends Formatter {

static {
// if user is redirecting output, do not print color codes
if (System.console() == null) {
if (System.getProperty("WLSIMG_IT_ANSICOLOR") == null && System.console() == null) {
AnsiColor.disable();
} else {
// check logging properties to see if the user wants to disable color output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,36 @@ void cacheAddInstallerWdt(TestInfo testInfo) throws IOException, InterruptedExce
}
}

@Test
@Order(8)
@Tag("nightly")
@Tag("cache")
@DisplayName("Add FMW installer to cache")
void cacheAddInstallerFmw(TestInfo testInfo) throws Exception {
// add fmw installer to the cache
String addCommand = new CacheCommand()
.addInstaller(true)
.type("fmw")
.version(WLS_VERSION)
.path(Paths.get(STAGING_DIR, FMW_INSTALLER))
.build();


try (PrintWriter out = getTestMethodWriter(testInfo)) {
CommandResult addResult = Runner.run(addCommand, out, logger);
// the process return code for addInstaller should be 0
assertEquals(0, addResult.exitValue(), "for command: " + addCommand);

// verify the result
String listCommand = new CacheCommand().listItems(true).build();
CommandResult listResult = Runner.run(listCommand, out, logger);
// the process return code for listItems should be 0
assertEquals(0, listResult.exitValue(), "for command: " + listCommand);
// output should show newly added WLS installer
assertTrue(listResult.stdout().contains("fmw_" + WLS_VERSION + "="));
}
}

/**
* create a WLS image with default WLS version.
*
Expand Down Expand Up @@ -768,19 +798,8 @@ void createFmwImgFullInternetAccess(TestInfo testInfo) throws Exception {
// the process return code for addInstaller should be 0
assertEquals(0, addNewJdkResult.exitValue(), "for command: " + addNewJdkCmd);

// add fmw installer to the cache
String addCommand = new CacheCommand()
.addInstaller(true)
.type("fmw")
.version(WLS_VERSION)
.path(Paths.get(STAGING_DIR, FMW_INSTALLER))
.build();
CommandResult addResult = Runner.run(addCommand, out, logger);
// the process return code for addInstaller should be 0
assertEquals(0, addResult.exitValue(), "for command: " + addCommand);

String tagName = build_tag + ":" + getMethodName(testInfo);
// create an an image with FMW and the latest PSU using ARU to download the patch
// create an image with FMW and the latest PSU using ARU to download the patch
String command = new CreateCommand()
.tag(tagName)
.jdkVersion(JDK_VERSION_8u212)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.List;

import com.oracle.weblogic.imagetool.logging.AnsiColor;
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
import com.oracle.weblogic.imagetool.tests.annotations.Logger;
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
Expand All @@ -14,10 +15,16 @@

public class LoggingExtension implements BeforeTestExecutionCallback, AfterTestExecutionCallback {

// emphasis at the beginning and the end of a line.
public static final String EM = "==========";
private static final String BEGIN = EM + AnsiColor.BRIGHT_GREEN;
private static final String FAIL = EM + AnsiColor.BRIGHT_RED;
private static final String END = AnsiColor.RESET + EM;

@Override
public void beforeTestExecution(ExtensionContext context) throws Exception {
getLogger(context.getRequiredTestClass())
.info("========== Starting test [{0}] method={1} ==========",
.info(BEGIN + " Starting test [{0}] method={1} " + END,
context.getDisplayName(),
context.getRequiredTestMethod().getName());
}
Expand All @@ -28,11 +35,11 @@ public void afterTestExecution(ExtensionContext context) throws Exception {
boolean testFailed = context.getExecutionException().isPresent();
LoggingFacade logger = getLogger((context.getRequiredTestClass()));
if (testFailed) {
logger.severe("========== FAILED test [{0}] method={1} ==========",
logger.severe(FAIL + " FAILED test [{0}] method={1} " + END,
context.getDisplayName(), context.getRequiredTestMethod().getName());
logger.severe(context.getExecutionException().get().getMessage());
} else {
logger.info("========== Finished test [{0}] method={1} ==========",
logger.info(EM + " Finished test [{0}] method={1} " + EM,
context.getDisplayName(), context.getRequiredTestMethod().getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class TimingExtension implements BeforeTestExecutionCallback, AfterTestEx
private static final LoggingFacade logger = LoggingFactory.getLogger(TimingExtension.class);

private static final String START_TIME = "start time";
private static final String EM = LoggingExtension.EM;

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

LoggingExtension.getLogger((context.getRequiredTestClass()))
.info("========== Test duration [{0}] method={1}: {2} min, {3} sec ==========",
.info(EM + " Test duration [{0}] method={1}: {2} min, {3} sec " + EM,
context.getDisplayName(),
context.getRequiredTestMethod().getName(),
minutes, seconds);
Expand Down

0 comments on commit 4480187

Please sign in to comment.