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 @@ -5,6 +5,10 @@

import java.io.File;
import java.io.FileOutputStream;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.net.http.HttpResponse;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -48,8 +52,13 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.opentest4j.AssertionFailedError;

import static java.util.concurrent.TimeUnit.MINUTES;
Expand All @@ -63,7 +72,9 @@
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_LATEST_IMAGE_TAG;
import static oracle.weblogic.kubernetes.TestConstants.WLS_UPDATE_IMAGE_TAG;
import static oracle.weblogic.kubernetes.actions.ActionConstants.APP_DIR;
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
Expand Down Expand Up @@ -188,7 +199,6 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {

}


/**
* Test domain status gets updated when introspectVersion attribute is added under domain.spec.
* Test Creates a domain in persistent volume using WLST.
Expand Down Expand Up @@ -474,9 +484,9 @@ public void conditionEvaluated(EvaluatedCondition condition) {
//access application in managed servers through NGINX load balancer
logger.info("Accessing the clusterview app through NGINX load balancer");
String curlRequest = String.format("curl --silent --show-error --noproxy '*' "
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
domainUid + "." + introDomainNamespace + "." + clusterName + ".test", K8S_NODEPORT_HOST, nodeportshttp);

// verify each managed server can see other member in the cluster
Expand Down Expand Up @@ -595,9 +605,9 @@ public void testDomainIntrospectVersionRolling() {
//access application in managed servers through NGINX load balancer
logger.info("Accessing the clusterview app through NGINX load balancer");
String curlRequest = String.format("curl --silent --show-error --noproxy '*' "
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
domainUid + "." + introDomainNamespace + "." + clusterName + ".test", K8S_NODEPORT_HOST, nodeportshttp);

// verify each managed server can see other member in the cluster
Expand Down Expand Up @@ -848,14 +858,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 skipped if the image tag is the latest WebLogic image tag
*/
@Order(5)
@AssumeWebLogicImage
@Test
@DisplayName("Verify server pods are restarted by updating image name")
public void testUpdateImageName() {

final String domainNamespace = introDomainNamespace;

final String adminServerName = "admin-server";
final String adminServerPodName = domainUid + "-" + adminServerName;
final String managedServerNameBase = "cl2-ms-";
Expand Down Expand Up @@ -929,11 +940,11 @@ public void testUpdateImageName() {
* Create a configmap containing WLST script and property file.
* Create a Kubernetes job to create domain on persistent volume.
*
* @param wlstScriptFile python script to create domain
* @param wlstScriptFile python script to create domain
* @param domainPropertiesFile properties file containing domain configuration
* @param pvName name of the persistent volume to create domain in
* @param pvcName name of the persistent volume claim
* @param namespace name of the domain namespace in which the job is created
* @param pvName name of the persistent volume to create domain in
* @param pvcName name of the persistent volume claim
* @param namespace name of the domain namespace in which the job is created
*/
private void createDomainOnPVUsingWlst(Path wlstScriptFile, Path domainPropertiesFile,
String pvName, String pvcName, String namespace) {
Expand Down Expand Up @@ -966,7 +977,7 @@ private void createDomainOnPVUsingWlst(Path wlstScriptFile, Path domainPropertie
}

private static void verifyMemberHealth(String adminServerPodName, List<String> managedServerNames,
String user, String password) {
String user, String password) {

logger.info("Getting node port for default channel");
int serviceNodePort = assertDoesNotThrow(()
Expand All @@ -979,7 +990,7 @@ private static void verifyMemberHealth(String adminServerPodName, List<String> m

withStandardRetryPolicy.conditionEvaluationListener(
condition -> logger.info("Verifying the health of all cluster members"
+ "(elapsed time {0} ms, remaining time {1} ms)",
+ "(elapsed time {0} ms, remaining time {1} ms)",
condition.getElapsedTimeInMS(),
condition.getRemainingTimeInMS()))
.until((Callable<Boolean>) () -> {
Expand Down Expand Up @@ -1014,4 +1025,40 @@ public void tearDownAll() {
}
}

/**
* JUnit5 extension class to implement ExecutionCondition for the custom
* annotation @AssumeWebLogicImage.
*/
private static class WebLogicImageCondition implements ExecutionCondition {

/**
* Determine if the the test "testUpdateImageName" will be skipped based on WebLogic image tag.
* Skip the test if the image tag is the latest one.
*
* @param context the current extension context
* @return ConditionEvaluationResult disabled if the image tag is the latest one, enabled if the
* image tag is not the latest one
*/
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
if (WEBLOGIC_IMAGE_TAG.equals(WLS_LATEST_IMAGE_TAG)) {
getLogger().info("WebLogic image tag is {0}. No latest image available to continue test. Skipping test",
WLS_LATEST_IMAGE_TAG);
return ConditionEvaluationResult
.disabled(String.format("No latest image available to continue test. Skipping test!"));
} else {
getLogger().info("Updating image to {0}. Continuing test!", WLS_UPDATE_IMAGE_TAG);
return ConditionEvaluationResult
.enabled(String.format("Updating image to {0}. Continuing test!", WLS_UPDATE_IMAGE_TAG));
}
}
}

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Tag("assume-weblogic-image")
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this annotation? There is no annotation called "assume-weblogic-image" right?

Copy link
Member Author

@maggiehe00 maggiehe00 Nov 4, 2020

Choose a reason for hiding this comment

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

Right now there is no use for "assume-weblogic-image". But it won't hurt to add Tag name in case we need it later for different test plans/test cases, just like @tag("integration") or @tag("must-not-run-in-parallel")

Copy link
Member

Choose a reason for hiding this comment

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

ok alright.

@ExtendWith(WebLogicImageCondition.class)
@interface AssumeWebLogicImage {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public interface TestConstants {
public static final String WEBLOGIC_IMAGE_TAG = Optional.ofNullable(System.getenv("WEBLOGIC_IMAGE_TAG"))
.orElse(BASE_IMAGES_REPO.equals(OCR_REGISTRY) ? OCR_WEBLOGIC_IMAGE_TAG : OCIR_WEBLOGIC_IMAGE_TAG);
public static final String WLS_UPDATE_IMAGE_TAG = "14.1.1.0-11";
public static final String WLS_LATEST_IMAGE_TAG = "14.1.1.0-11";

// Get FMWINFRA_IMAGE_NAME/FMWINFRA_IMAGE_TAG from env var, if its not provided and
// if base images repo is OCR use OCR default image values
Expand Down