Skip to content

Commit a1386bc

Browse files
bhavaniravichandranOracle Public Cloud UserOracle Public Cloud UserOracle Public Cloud User
authored
fix integration test to run on OKD (#2316)
* fix integration test to run on OKD * update liftandshift test Co-authored-by: Oracle Public Cloud User <opc@brokd-667035.sub07210031390.markvcn.oraclevcn.com> Co-authored-by: Oracle Public Cloud User <opc@api.c1.okd4.weblogick8s.org> Co-authored-by: Oracle Public Cloud User <opc@api-int.c1.okd4.weblogick8s.org>
1 parent eab6338 commit a1386bc

27 files changed

+694
-164
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItCoherenceTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.junit.jupiter.api.AfterAll;
3535
import org.junit.jupiter.api.BeforeAll;
3636
import org.junit.jupiter.api.DisplayName;
37+
import org.junit.jupiter.api.Tag;
3738
import org.junit.jupiter.api.Test;
3839

3940
import static java.util.concurrent.TimeUnit.MINUTES;
@@ -67,13 +68,14 @@
6768
// which load and verify the cache.
6869
@DisplayName("Test to create a WebLogic domain with Coherence and verify the use of Coherence cache service")
6970
@IntegrationTest
71+
@Tag("okdenv")
7072
class ItCoherenceTests {
7173

7274
// constants for Coherence
7375
private static final String PROXY_CLIENT_APP_NAME = "coherence-proxy-client";
7476
private static final String PROXY_SERVER_APP_NAME = "coherence-proxy-server";
7577
private static final String APP_LOC_ON_HOST = APP_DIR + "/" + PROXY_CLIENT_APP_NAME;
76-
private static final String APP_LOC_IN_POD = "/u01/oracle/apps/" + PROXY_CLIENT_APP_NAME;
78+
private static final String APP_LOC_IN_POD = "/u01/apps/" + PROXY_CLIENT_APP_NAME;
7779
private static final String PROXY_CLIENT_SCRIPT = "buildRunProxyClient.sh";
7880
private static final String OP_CACHE_LOAD = "load";
7981
private static final String OP_CACHE_VALIDATE = "validate";
@@ -143,7 +145,7 @@ void tearDown() {
143145
*/
144146
@Test
145147
@DisplayName("Create domain with a Coherence cluster using WDT and test rolling restart")
146-
public void testCohernceServerRollingRestart() {
148+
public void testCoherenceServerRollingRestart() {
147149
final String successMarker = "CACHE-SUCCESS";
148150

149151
// create a DomainHomeInImage image using WebLogic Image Tool

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItInitContainers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.junit.jupiter.api.AfterAll;
3030
import org.junit.jupiter.api.BeforeAll;
3131
import org.junit.jupiter.api.DisplayName;
32+
import org.junit.jupiter.api.Tag;
3233
import org.junit.jupiter.api.Test;
3334

3435
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE;
@@ -62,6 +63,7 @@
6263
*/
6364
@DisplayName("Test server's pod init container feature")
6465
@IntegrationTest
66+
@Tag("okdenv")
6567
class ItInitContainers {
6668

6769
private static String opNamespace = null;

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIntrospectVersion.java

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
7979
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
8080
import static oracle.weblogic.kubernetes.TestConstants.KIND_REPO;
81+
import static oracle.weblogic.kubernetes.TestConstants.OKD;
8182
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME;
8283
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
8384
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
@@ -114,6 +115,7 @@
114115
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressForDomainAndVerify;
115116
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createPV;
116117
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createPVC;
118+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createRouteForOKD;
117119
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createSecretForBaseImages;
118120
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createSecretWithUsernamePassword;
119121
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getExternalServicePodName;
@@ -146,6 +148,7 @@
146148
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
147149
@DisplayName("Verify the introspectVersion runs the introspector")
148150
@IntegrationTest
151+
@Tag("okdenv")
149152
public class ItIntrospectVersion {
150153

151154
private static String opNamespace = null;
@@ -161,6 +164,9 @@ public class ItIntrospectVersion {
161164
: WEBLOGIC_IMAGE_NAME + ":" + WLS_UPDATE_IMAGE_TAG;
162165
private final String wlSecretName = "weblogic-credentials";
163166

167+
private static String adminSvcExtHost = null;
168+
private static String clusterRouteHost = null;
169+
164170
private Map<String, OffsetDateTime> podsWithTimeStamps = null;
165171

166172
private static final String INTROSPECT_DOMAIN_SCRIPT = "introspectDomain.sh";
@@ -204,8 +210,9 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
204210
nodeportshttp = getNextFreePort();
205211
int nodeportshttps = getNextFreePort();
206212

207-
// install and verify NGINX
208-
nginxHelmParams = installAndVerifyNginx(nginxNamespace, nodeportshttp, nodeportshttps);
213+
if (!OKD) {
214+
nginxHelmParams = installAndVerifyNginx(nginxNamespace, nodeportshttp, nodeportshttps);
215+
}
209216

210217
// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
211218
// this secret is used only for non-kind cluster
@@ -240,6 +247,7 @@ public void testDomainIntrospectVersionNotRolling() {
240247

241248
final String adminServerName = "admin-server";
242249
final String adminServerPodName = domainUid + "-" + adminServerName;
250+
final String clusterServiceName = domainUid + "-cluster-" + clusterName;
243251

244252
final String managedServerNameBase = "managed-server";
245253
String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase;
@@ -374,6 +382,11 @@ public void testDomainIntrospectVersionNotRolling() {
374382
checkPodReady(managedServerPodNamePrefix + i, domainUid, introDomainNamespace);
375383
}
376384

385+
if (OKD) {
386+
adminSvcExtHost = createRouteForOKD(getExternalServicePodName(adminServerPodName), introDomainNamespace);
387+
logger.info("admin svc host = {0}", adminSvcExtHost);
388+
}
389+
377390
// deploy application and verify all servers functions normally
378391
logger.info("Getting port for default channel");
379392
int defaultChannelPort = assertDoesNotThrow(()
@@ -391,15 +404,23 @@ public void testDomainIntrospectVersionNotRolling() {
391404
//deploy clusterview application
392405
logger.info("Deploying clusterview app {0} to cluster {1}",
393406
clusterViewAppPath, clusterName);
394-
ExecResult result = null;
407+
//ExecResult result = null;
395408
String targets = "{identity:[clusters,'mycluster']},{identity:[servers,'admin-server']}";
396-
result = deployUsingRest(K8S_NODEPORT_HOST,
397-
Integer.toString(serviceNodePort),
398-
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT,
399-
targets, clusterViewAppPath, null, "clusterview");
400-
assertNotNull(result, "Application deployment failed");
401-
logger.info("Application deployment returned {0}", result.toString());
402-
assertEquals("202", result.stdout(), "Application deploymen failed with wrong HTTP status code");
409+
410+
String hostAndPort = (OKD) ? adminSvcExtHost : K8S_NODEPORT_HOST + ":" + serviceNodePort;
411+
logger.info("hostAndPort = {0} ", hostAndPort);
412+
413+
withStandardRetryPolicy.conditionEvaluationListener(
414+
condition -> logger.info("Deploying the application using Rest"
415+
+ "(elapsed time {0} ms, remaining time {1} ms)",
416+
condition.getElapsedTimeInMS(),
417+
condition.getRemainingTimeInMS()))
418+
.until((Callable<Boolean>) () -> {
419+
ExecResult result = assertDoesNotThrow(() -> deployUsingRest(hostAndPort,
420+
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT,
421+
targets, clusterViewAppPath, null, "clusterview"));
422+
return result.stdout().equals("202");
423+
});
403424

404425
List<String> managedServerNames = new ArrayList<String>();
405426
for (int i = 1; i <= replicaCount; i++) {
@@ -498,10 +519,14 @@ public void conditionEvaluated(EvaluatedCondition condition) {
498519
}
499520

500521
//create ingress controller
501-
Map<String, Integer> clusterNameMsPortMap = new HashMap<>();
502-
clusterNameMsPortMap.put(clusterName, managedServerPort);
503-
logger.info("Creating ingress for domain {0} in namespace {1}", domainUid, introDomainNamespace);
504-
createIngressForDomainAndVerify(domainUid, introDomainNamespace, clusterNameMsPortMap);
522+
if (!OKD) {
523+
Map<String, Integer> clusterNameMsPortMap = new HashMap<>();
524+
clusterNameMsPortMap.put(clusterName, managedServerPort);
525+
logger.info("Creating ingress for domain {0} in namespace {1}", domainUid, introDomainNamespace);
526+
createIngressForDomainAndVerify(domainUid, introDomainNamespace, clusterNameMsPortMap);
527+
} else {
528+
clusterRouteHost = createRouteForOKD(clusterServiceName, introDomainNamespace);
529+
}
505530

506531
managedServerNames = new ArrayList<String>();
507532
for (int i = 1; i <= replicaCount + 1; i++) {
@@ -511,13 +536,24 @@ public void conditionEvaluated(EvaluatedCondition condition) {
511536
//verify admin server accessibility and the health of cluster members
512537
verifyMemberHealth(adminServerPodName, managedServerNames, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
513538

514-
//access application in managed servers through NGINX load balancer
515-
logger.info("Accessing the clusterview app through NGINX load balancer");
516-
String curlRequest = String.format("curl --silent --show-error --noproxy '*' "
517-
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
539+
String curlRequest = null;
540+
541+
if (OKD) {
542+
logger.info("cluster svc host = {0}", clusterRouteHost);
543+
logger.info("Accessing the clusterview app through cluster route");
544+
curlRequest = String.format("curl --silent --show-error --noproxy '*' "
545+
+ "http://%s/clusterview/ClusterViewServlet"
518546
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
519-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
520-
domainUid + "." + introDomainNamespace + "." + clusterName + ".test", K8S_NODEPORT_HOST, nodeportshttp);
547+
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"", clusterRouteHost);
548+
} else {
549+
//access application in managed servers through NGINX load balancer
550+
logger.info("Accessing the clusterview app through NGINX load balancer");
551+
curlRequest = String.format("curl --silent --show-error --noproxy '*' "
552+
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
553+
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
554+
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
555+
domainUid + "." + introDomainNamespace + "." + clusterName + ".test", K8S_NODEPORT_HOST, nodeportshttp);
556+
}
521557

522558
// verify each managed server can see other member in the cluster
523559
verifyServerCommunication(curlRequest, managedServerNames);
@@ -662,13 +698,23 @@ public void testDomainIntrospectVersionRolling() {
662698
//verify admin server accessibility and the health of cluster members
663699
verifyMemberHealth(adminServerPodName, managedServerNames, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
664700

665-
//access application in managed servers through NGINX load balancer
666-
logger.info("Accessing the clusterview app through NGINX load balancer");
667-
String curlRequest = String.format("curl --silent --show-error --noproxy '*' "
668-
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
701+
String curlRequest = null;
702+
if (OKD) {
703+
logger.info("cluster svc host = {0}", clusterRouteHost);
704+
logger.info("Accessing the clusterview app through cluster route");
705+
curlRequest = String.format("curl --silent --show-error --noproxy '*' "
706+
+ "http://%s/clusterview/ClusterViewServlet"
669707
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
670-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
671-
domainUid + "." + introDomainNamespace + "." + clusterName + ".test", K8S_NODEPORT_HOST, nodeportshttp);
708+
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"", clusterRouteHost);
709+
} else {
710+
//access application in managed servers through NGINX load balancer
711+
logger.info("Accessing the clusterview app through NGINX load balancer");
712+
curlRequest = String.format("curl --silent --show-error --noproxy '*' "
713+
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
714+
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
715+
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
716+
domainUid + "." + introDomainNamespace + "." + clusterName + ".test", K8S_NODEPORT_HOST, nodeportshttp);
717+
}
672718

673719
// verify each managed server can see other member in the cluster
674720
verifyServerCommunication(curlRequest, managedServerNames);
@@ -810,9 +856,9 @@ introDomainNamespace, getExternalServicePodName(adminServerPodName), "default"),
810856
final boolean VALID = true;
811857
final boolean INVALID = false;
812858
logger.info("Check that after patching current credentials are not valid and new credentials are");
813-
verifyCredentials(adminServerPodName, introDomainNamespace,
859+
verifyCredentials(adminSvcExtHost, adminServerPodName, introDomainNamespace,
814860
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, INVALID);
815-
verifyCredentials(adminServerPodName, introDomainNamespace,
861+
verifyCredentials(adminSvcExtHost, adminServerPodName, introDomainNamespace,
816862
ADMIN_USERNAME_PATCH, ADMIN_PASSWORD_PATCH, VALID);
817863

818864
List<String> managedServerNames = new ArrayList<String>();
@@ -1150,8 +1196,11 @@ private static void verifyMemberHealth(String adminServerPodName, List<String> m
11501196
-> getServiceNodePort(introDomainNamespace, getExternalServicePodName(adminServerPodName), "default"),
11511197
"Getting admin server node port failed");
11521198

1199+
String hostAndPort = (OKD) ? adminSvcExtHost : K8S_NODEPORT_HOST + ":" + serviceNodePort;
1200+
logger.info("hostAndPort = {0} ", hostAndPort);
1201+
11531202
logger.info("Checking the health of servers in cluster");
1154-
String url = "http://" + K8S_NODEPORT_HOST + ":" + serviceNodePort
1203+
String url = "http://" + hostAndPort
11551204
+ "/clusterview/ClusterViewServlet?user=" + user + "&password=" + password;
11561205

11571206
withStandardRetryPolicy.conditionEvaluationListener(

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItLiftAndShiftFromOnPremDomain.java

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.awaitility.core.ConditionFactory;
3030
import org.junit.jupiter.api.BeforeAll;
3131
import org.junit.jupiter.api.DisplayName;
32+
import org.junit.jupiter.api.Tag;
3233
import org.junit.jupiter.api.Test;
3334

3435
import static java.util.concurrent.TimeUnit.MINUTES;
@@ -37,6 +38,7 @@
3738
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
3839
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
3940
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
41+
import static oracle.weblogic.kubernetes.TestConstants.OKD;
4042
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
4143
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME;
4244
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG;
@@ -53,6 +55,7 @@
5355
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
5456
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createImageAndVerify;
5557
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createOcirRepoSecret;
58+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createRouteForOKD;
5659
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.dockerLoginAndPushImageToRegistry;
5760
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyOperator;
5861
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyTraefik;
@@ -82,6 +85,7 @@
8285

8386
@DisplayName("Test to validate on-prem to k8s use case")
8487
@IntegrationTest
88+
@Tag("okdenv")
8589
public class ItLiftAndShiftFromOnPremDomain {
8690
private static String opNamespace = null;
8791
private static String traefikNamespace = null;
@@ -106,6 +110,8 @@ public class ItLiftAndShiftFromOnPremDomain {
106110
private Path zipFile;
107111

108112
private static HelmParams traefikHelmParams = null;
113+
private int traefikNodePort = 0;
114+
private String hostName = null;
109115

110116
/**
111117
* Install Operator.
@@ -142,9 +148,11 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
142148
// install and verify operator
143149
installAndVerifyOperator(opNamespace, domainNamespace);
144150

145-
// install and verify Traefik
146-
logger.info("Installing Traefik controller using helm");
147-
traefikHelmParams = installAndVerifyTraefik(traefikNamespace, 0, 0);
151+
if (!OKD) {
152+
// install and verify Traefik
153+
logger.info("Installing Traefik controller using helm");
154+
traefikHelmParams = installAndVerifyTraefik(traefikNamespace, 0, 0);
155+
}
148156

149157
}
150158

@@ -160,6 +168,7 @@ public void testCreateMiiDomainWithClusterFromOnPremDomain() {
160168
// admin/managed server name here should match with model yaml in MII_BASIC_WDT_MODEL_FILE
161169
final String adminServerPodName = domainUid + "-admin-server";
162170
final String managedServerPrefix = domainUid + "-managed-server";
171+
final String clusterService = domainUid + "-cluster-cluster-1";
163172
final int replicaCount = 5;
164173

165174
assertDoesNotThrow(() -> {
@@ -311,18 +320,24 @@ public void testCreateMiiDomainWithClusterFromOnPremDomain() {
311320
checkPodReadyAndServiceExists(managedServerPrefix + i, domainUid, domainNamespace);
312321
}
313322

314-
// create ingress rules with path routing for Traefik
315-
createTraefikIngressRoutingRules(domainNamespace);
323+
if (!OKD) {
324+
// create ingress rules with path routing for Traefik
325+
createTraefikIngressRoutingRules(domainNamespace);
326+
327+
traefikNodePort = getServiceNodePort(traefikNamespace, traefikHelmParams.getReleaseName(), "web");
328+
assertTrue(traefikNodePort != -1,
329+
"Could not get the default external service node port");
330+
logger.info("Found the Traefik service nodePort {0}", traefikNodePort);
331+
logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST);
332+
} else {
333+
hostName = createRouteForOKD(clusterService, domainNamespace);
334+
}
316335

317-
int traefikNodePort = getServiceNodePort(traefikNamespace, traefikHelmParams.getReleaseName(), "web");
318-
assertTrue(traefikNodePort != -1,
319-
"Could not get the default external service node port");
320-
logger.info("Found the Traefik service nodePort {0}", traefikNodePort);
321-
logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST);
336+
String hostAndPort = (OKD) ? hostName : K8S_NODEPORT_HOST + ":" + traefikNodePort;
337+
logger.info("hostAndPort = {0} ", hostAndPort);
322338

323339
String curlString = String.format("curl -v --show-error --noproxy '*' "
324-
+ "http://%s:%s/opdemo/?dsName=testDatasource",
325-
K8S_NODEPORT_HOST, traefikNodePort);
340+
+ "http://%s/opdemo/?dsName=testDatasource", hostAndPort);
326341

327342
// check and wait for the application to be accessible in admin pod
328343
checkAppIsRunning(

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItLivenessProbeCustomization.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import io.kubernetes.client.openapi.models.V1EnvVar;
1515
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
1616
import io.kubernetes.client.openapi.models.V1ObjectMeta;
17-
import io.kubernetes.client.openapi.models.V1PodSecurityContext;
1817
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
1918
import io.kubernetes.client.openapi.models.V1SecretReference;
2019
import oracle.weblogic.domain.AdminServer;
@@ -32,6 +31,7 @@
3231
import org.junit.jupiter.api.DisplayName;
3332
import org.junit.jupiter.api.MethodOrderer;
3433
import org.junit.jupiter.api.Order;
34+
import org.junit.jupiter.api.Tag;
3535
import org.junit.jupiter.api.Test;
3636
import org.junit.jupiter.api.TestMethodOrder;
3737

@@ -71,6 +71,7 @@
7171
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
7272
@DisplayName("Verify liveness probe customization")
7373
@IntegrationTest
74+
@Tag("okdenv")
7475
public class ItLivenessProbeCustomization {
7576

7677
private static String domainNamespace = null;
@@ -297,9 +298,7 @@ private static void createAndVerifyMiiDomain(String miiImage) {
297298
.value("/u01/customLivenessProbe.sh"))
298299
.resources(new V1ResourceRequirements()
299300
.limits(new HashMap<>())
300-
.requests(new HashMap<>()))
301-
.podSecurityContext(new V1PodSecurityContext()
302-
.runAsUser(0L)))
301+
.requests(new HashMap<>())))
303302
.adminServer(new AdminServer()
304303
.serverStartState("RUNNING"))
305304
.clusters(clusterList)

0 commit comments

Comments
 (0)