Skip to content

Commit e1de8bb

Browse files
hzhao-githubrjeberhard
authored andcommitted
Move ItMiiDomainModelInPV.java, ItLBTwoDomainsTraefik.java and ItIstioGatewaySessionMigration.java to internal OKE
1 parent 6b119b4 commit e1de8bb

File tree

8 files changed

+285
-129
lines changed

8 files changed

+285
-129
lines changed

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

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Map;
1313
import java.util.Optional;
1414

15+
import io.kubernetes.client.openapi.models.V1Pod;
1516
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
1617
import oracle.weblogic.kubernetes.annotations.Namespaces;
1718
import oracle.weblogic.kubernetes.logging.LoggingFacade;
@@ -26,21 +27,27 @@
2627
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
2728
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
2829
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
30+
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
2931
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
3032
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
3133
import static oracle.weblogic.kubernetes.actions.TestActions.addLabelsToNamespace;
34+
import static oracle.weblogic.kubernetes.actions.TestActions.getPod;
3235
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppUsingHostHeader;
3336
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.configIstioModelInImageDomain;
3437
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createTestWebAppWarFile;
3538
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.generateNewModelFileWithUpdatedDomainUid;
39+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
3640
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployToClusterUsingRest;
41+
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployUsingRest;
42+
import static oracle.weblogic.kubernetes.utils.FileUtils.copyFileToPod;
3743
import static oracle.weblogic.kubernetes.utils.FileUtils.generateFileFromTemplate;
3844
import static oracle.weblogic.kubernetes.utils.ImageUtils.createMiiImageAndVerify;
3945
import static oracle.weblogic.kubernetes.utils.ImageUtils.imageRepoLoginAndPushImageToRegistry;
4046
import static oracle.weblogic.kubernetes.utils.IstioUtils.deployHttpIstioGatewayAndVirtualservice;
4147
import static oracle.weblogic.kubernetes.utils.IstioUtils.deployIstioDestinationRule;
4248
import static oracle.weblogic.kubernetes.utils.IstioUtils.getIstioHttpIngressPort;
4349
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
50+
import static oracle.weblogic.kubernetes.utils.PodUtils.execInPod;
4451
import static oracle.weblogic.kubernetes.utils.SessionMigrationUtil.getOrigModelFile;
4552
import static oracle.weblogic.kubernetes.utils.SessionMigrationUtil.getServerAndSessionInfoAndVerify;
4653
import static oracle.weblogic.kubernetes.utils.SessionMigrationUtil.shutdownServerAndVerify;
@@ -54,9 +61,9 @@
5461

5562
@DisplayName("Test WLS Session Migration via istio enabled using Istio gateway")
5663
@IntegrationTest
57-
@Tag("oke-parallel")
5864
@Tag("kind-parallel")
5965
@Tag("olcne")
66+
@Tag("oke-gate")
6067
class ItIstioGatewaySessionMigration {
6168

6269
private static String opNamespace = null;
@@ -83,6 +90,9 @@ class ItIstioGatewaySessionMigration {
8390
private static int istioIngressPort = 0;
8491
private static String testWebAppWarLoc = null;
8592

93+
private static final String istioNamespace = "istio-system";
94+
private static final String istioIngressServiceName = "istio-ingressgateway";
95+
8696
private static LoggingFacade logger = null;
8797

8898
/**
@@ -168,10 +178,18 @@ void testSessionMigrationIstioGateway() {
168178
final String webServiceGetUrl = SESSMIGR_APP_WAR_NAME + "/?getCounter";
169179
String serverName = managedServerPrefix + "1";
170180

181+
// In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort
182+
String istioIngressIP = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null
183+
? getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) : K8S_NODEPORT_HOST;
184+
171185
// send a HTTP request to set http session state(count number) and save HTTP session info
172186
// before shutting down the primary server
173-
Map<String, String> httpDataInfo = getServerAndSessionInfoAndVerify(domainNamespace,
174-
adminServerPodName, serverName, K8S_NODEPORT_HOST, istioIngressPort, webServiceSetUrl, " -c ");
187+
// the NodePort services created by the operator are not usable, because they would expose ports
188+
// on the worker node’s private IP addresses only, which are not reachable from outside the cluster
189+
Map<String, String> httpDataInfo = OKE_CLUSTER ? getServerAndSessionInfoAndVerify(domainNamespace,
190+
adminServerPodName, serverName, istioIngressIP, 0, webServiceSetUrl, " -c ")
191+
: getServerAndSessionInfoAndVerify(domainNamespace,
192+
adminServerPodName, serverName, istioIngressIP, istioIngressPort, webServiceSetUrl, " -c ");
175193
// get server and session info from web service deployed on the cluster
176194
String origPrimaryServerName = httpDataInfo.get(primaryServerAttr);
177195
String origSecondaryServerName = httpDataInfo.get(secondaryServerAttr);
@@ -186,8 +204,10 @@ void testSessionMigrationIstioGateway() {
186204

187205
// send a HTTP request to get server and session info after shutting down the primary server
188206
serverName = domainUid + "-" + origSecondaryServerName;
189-
httpDataInfo = getServerAndSessionInfoAndVerify(domainNamespace,
190-
adminServerPodName, serverName, K8S_NODEPORT_HOST, istioIngressPort, webServiceGetUrl, " -b ");
207+
httpDataInfo = OKE_CLUSTER ? getServerAndSessionInfoAndVerify(domainNamespace,
208+
adminServerPodName, serverName, istioIngressIP, 0, webServiceGetUrl, " -b ")
209+
: getServerAndSessionInfoAndVerify(domainNamespace,
210+
adminServerPodName, serverName, istioIngressIP, istioIngressPort, webServiceGetUrl, " -b ");
191211
// get server and session info from web service deployed on the cluster
192212
String primaryServerName = httpDataInfo.get(primaryServerAttr);
193213
String sessionCreateTime = httpDataInfo.get(sessionCreateTimeAttr);
@@ -254,10 +274,15 @@ private static int configIstioGatewayModelInImageDomain(String miiImage,
254274
int istioIngressPort = getIstioHttpIngressPort();
255275
logger.info("Istio Ingress Port is {0}", istioIngressPort);
256276

277+
// In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort
278+
String hostAndPort = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null
279+
? getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace)
280+
: K8S_NODEPORT_HOST + ":" + istioIngressPort;
281+
257282
// We can not verify Rest Management console thru Adminstration NodePort
258283
// in istio, as we can not enable Adminstration NodePort
259284
if (!WEBLOGIC_SLIM) {
260-
String consoleUrl = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/console/login/LoginForm.jsp";
285+
String consoleUrl = "http://" + hostAndPort + "/console/login/LoginForm.jsp";
261286
boolean checkConsole =
262287
checkAppUsingHostHeader(consoleUrl, domainNamespace + ".org");
263288
assertTrue(checkConsole, "Failed to access WebLogic console");
@@ -266,17 +291,51 @@ private static int configIstioGatewayModelInImageDomain(String miiImage,
266291
logger.info("Skipping WebLogic console in WebLogic slim image");
267292
}
268293

269-
Path archivePath = Paths.get(testWebAppWarLoc);
270294
ExecResult result = null;
271-
result = deployToClusterUsingRest(K8S_NODEPORT_HOST,
295+
Path archivePath = Paths.get(testWebAppWarLoc);
296+
// Use WebLogic restful management services to deploy Web App
297+
if (OKE_CLUSTER) {
298+
// In internal OKE env, deploy App in domain pods using WLST
299+
String destLocation = "/u01/testwebapp.war";
300+
301+
// Copy App archive to admin pod
302+
assertDoesNotThrow(() -> copyFileToPod(domainNamespace,
303+
adminServerPodName, "",
304+
archivePath,
305+
Paths.get(destLocation)));
306+
307+
// chown of App archive in admin pod
308+
V1Pod adminPod = assertDoesNotThrow(() -> getPod(domainNamespace, null, adminServerPodName));
309+
execInPod(adminPod, null, true, "chown 1000:root " + destLocation);
310+
311+
for (int i = 1; i <= replicaCount; i++) {
312+
// Copy App archive to managed server pod
313+
String managedServerPodName = managedServerPrefix + i;
314+
assertDoesNotThrow(() -> copyFileToPod(domainNamespace,
315+
managedServerPodName, "",
316+
archivePath,
317+
Paths.get(destLocation)));
318+
319+
// chown of App archive in managed server pod
320+
V1Pod msPod = assertDoesNotThrow(() -> getPod(domainNamespace, null, managedServerPodName));
321+
execInPod(msPod, null, true, "chown 1000:root " + destLocation);
322+
}
323+
324+
String target = "{identity: [clusters,'" + clusterName + "']}";
325+
result = deployUsingRest(hostAndPort, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT,
326+
target, Paths.get(destLocation), domainNamespace + ".org", "testwebapp");
327+
assertNotNull(result, "Application deployment failed");
328+
} else {
329+
result = deployToClusterUsingRest(K8S_NODEPORT_HOST,
272330
String.valueOf(istioIngressPort),
273331
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT,
274332
clusterName, archivePath, domainNamespace + ".org", "testwebapp");
275-
assertNotNull(result, "Application deployment failed");
276-
logger.info("Application deployment returned {0}", result.toString());
277-
assertEquals("202", result.stdout(), "Deployment didn't return HTTP status code 202");
333+
assertNotNull(result, "Application deployment failed");
334+
logger.info("Application deployment returned {0}", result.toString());
335+
assertEquals("202", result.stdout(), "Deployment didn't return HTTP status code 202");
336+
}
278337

279-
String url = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/testwebapp/index.jsp";
338+
String url = "http://" + hostAndPort + "/testwebapp/index.jsp";
280339
logger.info("Application Access URL {0}", url);
281340

282341
return istioIngressPort;

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.junit.jupiter.api.Test;
2929
import org.junit.jupiter.api.TestMethodOrder;
3030

31+
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
3132
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
3233
import static oracle.weblogic.kubernetes.TestConstants.SKIP_CLEANUP;
3334
import static oracle.weblogic.kubernetes.actions.TestActions.deletePersistentVolume;
@@ -37,6 +38,7 @@
3738
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.createMultipleDomainsSharingPVUsingWlstAndVerify;
3839
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.verifyAdminServerAccess;
3940
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.verifyClusterLoadbalancing;
41+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
4042
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
4143
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyTraefik;
4244
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
@@ -53,8 +55,8 @@
5355
@DisplayName("Verify a single operator manages multiple WebLogic domains with a single Traefik fronted loadbalancer")
5456
@IntegrationTest
5557
@Tag("olcne")
56-
@Tag("oke-parallel")
5758
@Tag("kind-parallel")
59+
@Tag("oke-gate")
5860
class ItLBTwoDomainsTraefik {
5961

6062
private static final int numberOfDomains = 2;
@@ -75,6 +77,8 @@ class ItLBTwoDomainsTraefik {
7577
private static final int ADMIN_SERVER_PORT = 7001;
7678
private static final String clusterName = "cluster-1";
7779

80+
private static String ingressIP = null;
81+
7882
/**
7983
* Assigns unique namespaces for operator and domains.
8084
* Pull WebLogic image if running tests in Kind cluster.
@@ -122,6 +126,10 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
122126

123127
// install Traefik ingress controller for all test cases using Traefik
124128
installTraefikIngressController();
129+
130+
String ingressServiceName = traefikHelmParams.getReleaseName();
131+
ingressIP = getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) != null
132+
? getServiceExtIPAddrtOke(ingressServiceName, traefikNamespace) : K8S_NODEPORT_HOST;
125133
}
126134

127135
/**
@@ -134,7 +142,7 @@ void testTraefikHostRoutingAdminServer() {
134142
logger.info("Verifying WebLogic admin console is accessible through Traefik host routing with HTTP protocol");
135143
for (String domainUid : domainUids) {
136144
verifyAdminServerAccess(false, getTraefikLbNodePort(false), true,
137-
domainUid + "." + domainNamespace + "." + "admin-server" + ".test", "");
145+
domainUid + "." + domainNamespace + "." + "admin-server" + ".test", "", ingressIP);
138146
}
139147
}
140148

@@ -151,7 +159,7 @@ void testTraefikHttpHostRoutingAcrossDomains() {
151159
logger.info("Verifying Traefik host routing with HTTP protocol across two domains");
152160
for (String domainUid : domainUids) {
153161
verifyClusterLoadbalancing(domainUid, domainUid + "." + domainNamespace + ".cluster-1.test",
154-
"http", getTraefikLbNodePort(false), replicaCount, true, "");
162+
"http", getTraefikLbNodePort(false), replicaCount, true, "", ingressIP);
155163
}
156164
}
157165

@@ -166,7 +174,7 @@ void testTraefikHttpsHostRoutingAcrossDomains() {
166174
logger.info("Verifying Traefik host routing with HTTPS protocol across two domains");
167175
for (String domainUid : domainUids) {
168176
verifyClusterLoadbalancing(domainUid, domainUid + "." + domainNamespace + ".cluster-1.test",
169-
"https", getTraefikLbNodePort(true), replicaCount, true, "");
177+
"https", getTraefikLbNodePort(true), replicaCount, true, "", ingressIP);
170178
}
171179
}
172180

@@ -179,7 +187,7 @@ void testTraefikPathRoutingAcrossDomains() {
179187
logger.info("Verifying Traefik path routing with HTTP protocol across two domains");
180188
for (String domainUid : domainUids) {
181189
verifyClusterLoadbalancing(domainUid, "", "http", getTraefikLbNodePort(false),
182-
replicaCount, false, "/" + domainUid.substring(12).replace("-", ""));
190+
replicaCount, false, "/" + domainUid.substring(12).replace("-", ""), ingressIP);
183191
}
184192
}
185193

@@ -258,5 +266,4 @@ private int getTraefikLbNodePort(boolean isHttps) {
258266
getServiceNodePort(traefikNamespace, traefikHelmParams.getReleaseName(), isHttps ? "websecure" : "web"),
259267
"Getting web node port for Traefik loadbalancer failed");
260268
}
261-
262269
}

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

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package oracle.weblogic.kubernetes;
55

6+
import java.io.IOException;
67
import java.net.http.HttpResponse;
78
import java.nio.file.Files;
89
import java.nio.file.Path;
@@ -31,6 +32,8 @@
3132
import oracle.weblogic.kubernetes.annotations.Namespaces;
3233
import oracle.weblogic.kubernetes.logging.LoggingFacade;
3334
import oracle.weblogic.kubernetes.utils.CommonMiiTestUtils;
35+
import oracle.weblogic.kubernetes.utils.ExecCommand;
36+
import oracle.weblogic.kubernetes.utils.ExecResult;
3437
import oracle.weblogic.kubernetes.utils.OracleHttpClient;
3538
import org.junit.jupiter.api.BeforeAll;
3639
import org.junit.jupiter.api.DisplayName;
@@ -47,6 +50,7 @@
4750
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_USERNAME;
4851
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_IMAGES_REPO;
4952
import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
53+
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
5054
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
5155
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
5256
import static oracle.weblogic.kubernetes.TestConstants.OKD;
@@ -96,9 +100,9 @@
96100
@DisplayName("Verify MII domain can be created from model file in PV location and custom wdtModelHome")
97101
@IntegrationTest
98102
@Tag("olcne")
99-
@Tag("oke-parallel")
100103
@Tag("kind-parallel")
101104
@Tag("okd-wls-srg")
105+
@Tag("oke-gate")
102106
public class ItMiiDomainModelInPV {
103107

104108
private static String domainNamespace = null;
@@ -313,33 +317,64 @@ private void createVerifyDomain(String domainUid, DomainResource domain,
313317
private static void verifyMemberHealth(String adminServerPodName, List<String> managedServerNames,
314318
String user, String password) {
315319

316-
adminSvcExtHost = createRouteForOKD(getExternalServicePodName(adminServerPodName), domainNamespace);
317-
logger.info("admin svc host = {0}", adminSvcExtHost);
318-
319-
logger.info("Getting node port for default channel");
320-
int serviceNodePort = assertDoesNotThrow(()
321-
-> getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"),
322-
"Getting admin server node port failed");
323-
324-
String hostAndPort = getHostAndPort(adminSvcExtHost, serviceNodePort);
325320
logger.info("Checking the health of servers in cluster");
326-
String url = "http://" + hostAndPort
327-
+ "/clusterview/ClusterViewServlet?user=" + user + "&password=" + password;
328321

329322
testUntil(
330323
() -> {
331-
HttpResponse<String> response = assertDoesNotThrow(() -> OracleHttpClient.get(url, true));
332-
assertEquals(200, response.statusCode(), "Status code not equals to 200");
333-
boolean health = true;
334-
for (String managedServer : managedServerNames) {
335-
health = health && response.body().contains(managedServer + ":HEALTH_OK");
336-
if (health) {
337-
logger.info(managedServer + " is healthy");
338-
} else {
339-
logger.info(managedServer + " health is not OK or server not found");
324+
if (OKE_CLUSTER) {
325+
// In internal OKE env, verifyMemberHealth in admin server pod
326+
int adminPort = 7001;
327+
final String command = KUBERNETES_CLI + " exec -n "
328+
+ domainNamespace + " " + adminServerPodName + " -- curl http://"
329+
+ adminServerPodName + ":"
330+
+ adminPort + "/clusterview/ClusterViewServlet"
331+
+ "\"?user=" + user
332+
+ "&password=" + password + "\"";
333+
334+
ExecResult result = null;
335+
try {
336+
result = ExecCommand.exec(command, true);
337+
} catch (IOException | InterruptedException ex) {
338+
logger.severe(ex.getMessage());
339+
}
340+
String response = result.stdout().trim();
341+
logger.info(response);
342+
boolean health = true;
343+
for (String managedServer : managedServerNames) {
344+
health = health && response.contains(managedServer + ":HEALTH_OK");
345+
if (health) {
346+
logger.info(managedServer + " is healthy");
347+
} else {
348+
logger.info(managedServer + " health is not OK or server not found");
349+
}
350+
}
351+
return health;
352+
} else {
353+
// In non-internal OKE env, verifyMemberHealth using adminSvcExtHost by sending HTTP request from local VM
354+
adminSvcExtHost = createRouteForOKD(getExternalServicePodName(adminServerPodName), domainNamespace);
355+
logger.info("admin svc host = {0}", adminSvcExtHost);
356+
357+
logger.info("Getting node port for default channel");
358+
int serviceNodePort = assertDoesNotThrow(()
359+
-> getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"),
360+
"Getting admin server node port failed");
361+
String hostAndPort = getHostAndPort(adminSvcExtHost, serviceNodePort);
362+
363+
String url = "http://" + hostAndPort
364+
+ "/clusterview/ClusterViewServlet?user=" + user + "&password=" + password;
365+
HttpResponse<String> response = assertDoesNotThrow(() -> OracleHttpClient.get(url, true));
366+
assertEquals(200, response.statusCode(), "Status code not equals to 200");
367+
boolean health = true;
368+
for (String managedServer : managedServerNames) {
369+
health = health && response.body().contains(managedServer + ":HEALTH_OK");
370+
if (health) {
371+
logger.info(managedServer + " is healthy");
372+
} else {
373+
logger.info(managedServer + " health is not OK or server not found");
374+
}
340375
}
376+
return health;
341377
}
342-
return health;
343378
},
344379
logger,
345380
"Verifying the health of all cluster members");

0 commit comments

Comments
 (0)