Skip to content

Ignore testUpdateImageName if the image tag is 14.1.1.0-11 #2017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 5, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
import static oracle.weblogic.kubernetes.TestConstants.KIND_REPO;
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
import static oracle.weblogic.kubernetes.TestConstants.WLS_UPDATE_IMAGE_TAG;
import static oracle.weblogic.kubernetes.actions.ActionConstants.APP_DIR;
Expand Down Expand Up @@ -111,6 +112,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

/**
* Tests related to introspectVersion attribute.
Expand Down Expand Up @@ -848,12 +850,15 @@ public void testCreateNewCluster() {
* To: "image: container-registry.oracle.com/middleware/weblogic:14.1.1.0-11"
* Verify all the pods are restarted and back to ready state
* Verify the admin server is accessible and cluster members are healthy
* This test will be aborted if the image tag is: 14.1.1.0-11
*/
@Order(5)
@Test
@DisplayName("Verify server pods are restarted by updating image name")
public void testUpdateImageName() {

logger.info("In the testUpdateImageName() the image version is: " + WEBLOGIC_IMAGE_TAG);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

` class WebLogicImageCondition implements ExecutionCondition {

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
  if (WEBLOGIC_IMAGE_TAG.equals(WLS_UPDATE_IMAGE_TAG)) {
    return ConditionEvaluationResult.
        disabled(String.format("No latest image availbale to continue test. Skipping test!"));
  } else {
    return ConditionEvaluationResult.
        enabled(String.format("Updating image to '%s'. Continuing test!", WLS_UPDATE_IMAGE_TAG));
  }
}

}

@retention(RetentionPolicy.RUNTIME)
@ExtendWith(WebLogicImageCondition.class)
@interface AssumeWebLogicImage {
}`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you can annotate the test method with @AssumeWebLogicImage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sankarpn Thanks for your input. Working on it.

logger.info("This test will be ABORTED if WebLogic image version is: 14.1.1.0-11");
assumeTrue(!WEBLOGIC_IMAGE_TAG.equals("14.1.1.0-11"));
final String domainNamespace = introDomainNamespace;

final String adminServerName = "admin-server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,15 @@ public void interceptTestMethod(Invocation<Void> invocation,
@Override
public void handleTestExecutionException(ExtensionContext context, Throwable throwable)
throws Throwable {
printHeader(String.format("Test failed %s()", methodName), "!");
getLogger().severe(getStackTraceAsString(throwable));
getLogger().info("Test Execution Exception is: " + throwable.getMessage());
Copy link
Member

@sankarpn sankarpn Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Maggie, Instead of modifying the framework methods you can use conditional check to skip a test. You can use the following annotation.

if (throwable.getMessage().contains("assumption is not true")) {
printHeader(String.format("Test aborted %s()", methodName), "!");
printHeader(String.format("Please check assumeTrue condition for test method %s()", methodName), "!");
getLogger().warning(getStackTraceAsString(throwable));
} else {
printHeader(String.format("Test failed %s()", methodName), "!");
getLogger().severe(getStackTraceAsString(throwable));
}
collectLogs(context, "test");
throw throwable;
}
Expand Down