Skip to content

Commit bdb3c9c

Browse files
authored
Backport owls-96154 (#2770)
* Backport owls-96154
1 parent de00939 commit bdb3c9c

File tree

2 files changed

+133
-150
lines changed

2 files changed

+133
-150
lines changed

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

Lines changed: 21 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.time.OffsetDateTime;
1313
import java.util.ArrayList;
1414
import java.util.Arrays;
15-
import java.util.HashMap;
1615
import java.util.LinkedHashMap;
1716
import java.util.List;
1817
import java.util.Map;
@@ -38,7 +37,6 @@
3837
import oracle.weblogic.domain.ServerPod;
3938
import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
4039
import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
41-
import oracle.weblogic.kubernetes.actions.impl.primitive.HelmParams;
4240
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
4341
import oracle.weblogic.kubernetes.annotations.Namespaces;
4442
import oracle.weblogic.kubernetes.logging.LoggingFacade;
@@ -49,7 +47,6 @@
4947
import org.awaitility.core.ConditionEvaluationListener;
5048
import org.awaitility.core.ConditionFactory;
5149
import org.awaitility.core.EvaluatedCondition;
52-
import org.junit.jupiter.api.AfterAll;
5350
import org.junit.jupiter.api.BeforeAll;
5451
import org.junit.jupiter.api.DisplayName;
5552
import org.junit.jupiter.api.MethodOrderer;
@@ -88,7 +85,6 @@
8885
import static oracle.weblogic.kubernetes.actions.TestActions.now;
8986
import static oracle.weblogic.kubernetes.actions.TestActions.patchDomainResourceWithNewIntrospectVersion;
9087
import static oracle.weblogic.kubernetes.actions.TestActions.scaleCluster;
91-
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallNginx;
9288
import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource;
9389
import static oracle.weblogic.kubernetes.actions.impl.Pod.getPod;
9490
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podStateNotChanged;
@@ -107,8 +103,6 @@
107103
import static oracle.weblogic.kubernetes.utils.ImageUtils.dockerLoginAndPushImageToRegistry;
108104
import static oracle.weblogic.kubernetes.utils.JobUtils.createDomainJob;
109105
import static oracle.weblogic.kubernetes.utils.JobUtils.getIntrospectJobName;
110-
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.createIngressForDomainAndVerify;
111-
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyNginx;
112106
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
113107
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
114108
import static oracle.weblogic.kubernetes.utils.PatchDomainUtils.patchDomainResource;
@@ -126,7 +120,6 @@
126120
import static oracle.weblogic.kubernetes.utils.WLSTUtils.executeWLSTScript;
127121
import static org.apache.commons.io.FileUtils.copyDirectory;
128122
import static org.apache.commons.io.FileUtils.deleteDirectory;
129-
import static org.assertj.core.api.Assertions.assertThat;
130123
import static org.awaitility.Awaitility.with;
131124
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
132125
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -149,10 +142,6 @@ class ItIntrospectVersion {
149142

150143
private static final String domainUid = "myintrodomain";
151144

152-
private static String nginxNamespace = null;
153-
private static int nodeportshttp;
154-
private static HelmParams nginxHelmParams = null;
155-
156145
private final String wlSecretName = "weblogic-credentials";
157146

158147
private static String adminSvcExtHost = null;
@@ -173,6 +162,7 @@ class ItIntrospectVersion {
173162

174163
private static Path clusterViewAppPath;
175164
private static LoggingFacade logger = null;
165+
private final int managedServerPort = 7100;
176166

177167
/**
178168
* Assigns unique namespaces for operator and domains.
@@ -182,29 +172,18 @@ class ItIntrospectVersion {
182172
* @param namespaces injected by JUnit
183173
*/
184174
@BeforeAll
185-
public static void initAll(@Namespaces(3) List<String> namespaces) {
175+
public static void initAll(@Namespaces(2) List<String> namespaces) {
186176
logger = getLogger();
187177
logger.info("Assign a unique namespace for operator");
188178
assertNotNull(namespaces.get(0), "Namespace is null");
189179
opNamespace = namespaces.get(0);
190180
logger.info("Assign a unique namespace for Introspect Version WebLogic domain");
191181
assertNotNull(namespaces.get(1), "Namespace is null");
192182
introDomainNamespace = namespaces.get(1);
193-
logger.info("Assign a unique namespace for NGINX");
194-
assertNotNull(namespaces.get(2), "Namespace is null");
195-
nginxNamespace = namespaces.get(2);
196183

197184
// install operator and verify its running in ready state
198185
installAndVerifyOperator(opNamespace, introDomainNamespace);
199186

200-
// get a free node port for NGINX
201-
nodeportshttp = getNextFreePort();
202-
int nodeportshttps = getNextFreePort();
203-
204-
if (!OKD) {
205-
nginxHelmParams = installAndVerifyNginx(nginxNamespace, nodeportshttp, nodeportshttps);
206-
}
207-
208187
// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
209188
// this secret is used only for non-kind cluster
210189
createSecretForBaseImages(introDomainNamespace);
@@ -242,7 +221,6 @@ void testDomainIntrospectVersionNotRolling() {
242221

243222
final String managedServerNameBase = "managed-server";
244223
String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase;
245-
final int managedServerPort = 7100;
246224

247225
int replicaCount = 2;
248226

@@ -524,16 +502,6 @@ public void conditionEvaluated(EvaluatedCondition condition) {
524502
domainUid, introDomainNamespace, pods.get(i));
525503
}
526504

527-
//create ingress controller
528-
if (!OKD) {
529-
Map<String, Integer> clusterNameMsPortMap = new HashMap<>();
530-
clusterNameMsPortMap.put(clusterName, managedServerPort);
531-
logger.info("Creating ingress for domain {0} in namespace {1}", domainUid, introDomainNamespace);
532-
createIngressForDomainAndVerify(domainUid, introDomainNamespace, clusterNameMsPortMap);
533-
} else {
534-
clusterRouteHost = createRouteForOKD(clusterServiceName, introDomainNamespace);
535-
}
536-
537505
managedServerNames = new ArrayList<String>();
538506
for (int i = 1; i <= replicaCount + 1; i++) {
539507
managedServerNames.add(managedServerNameBase + i);
@@ -542,28 +510,12 @@ public void conditionEvaluated(EvaluatedCondition condition) {
542510
//verify admin server accessibility and the health of cluster members
543511
verifyMemberHealth(adminServerPodName, managedServerNames, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
544512

545-
String curlRequest = null;
513+
// verify each managed server can see other member in the cluster
546514

547-
if (OKD) {
548-
logger.info("cluster svc host = {0}", clusterRouteHost);
549-
logger.info("Accessing the clusterview app through cluster route");
550-
curlRequest = String.format("curl --silent --show-error --noproxy '*' "
551-
+ "http://%s/clusterview/ClusterViewServlet"
552-
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
553-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"", clusterRouteHost);
554-
} else {
555-
//access application in managed servers through NGINX load balancer
556-
logger.info("Accessing the clusterview app through NGINX load balancer");
557-
curlRequest = String.format("curl --silent --show-error --noproxy '*' "
558-
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
559-
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
560-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
561-
domainUid + "." + introDomainNamespace + "." + clusterName + ".test", K8S_NODEPORT_HOST, nodeportshttp);
515+
for (String managedServerName : managedServerNames) {
516+
verifyConnectionBetweenClusterMembers(managedServerName, managedServerNames);
562517
}
563518

564-
// verify each managed server can see other member in the cluster
565-
verifyServerCommunication(curlRequest, managedServerNames);
566-
567519
// verify when a domain resource has spec.introspectVersion configured,
568520
// all WebLogic server pods will have a label "weblogic.introspectVersion"
569521
// set to the value of spec.introspectVersion.
@@ -704,26 +656,10 @@ void testDomainIntrospectVersionRolling() {
704656
//verify admin server accessibility and the health of cluster members
705657
verifyMemberHealth(adminServerPodName, managedServerNames, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
706658

707-
String curlRequest = null;
708-
if (OKD) {
709-
logger.info("cluster svc host = {0}", clusterRouteHost);
710-
logger.info("Accessing the clusterview app through cluster route");
711-
curlRequest = String.format("curl --silent --show-error --noproxy '*' "
712-
+ "http://%s/clusterview/ClusterViewServlet"
713-
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
714-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"", clusterRouteHost);
715-
} else {
716-
//access application in managed servers through NGINX load balancer
717-
logger.info("Accessing the clusterview app through NGINX load balancer");
718-
curlRequest = String.format("curl --silent --show-error --noproxy '*' "
719-
+ "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
720-
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
721-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",
722-
domainUid + "." + introDomainNamespace + "." + clusterName + ".test", K8S_NODEPORT_HOST, nodeportshttp);
723-
}
724-
725659
// verify each managed server can see other member in the cluster
726-
verifyServerCommunication(curlRequest, managedServerNames);
660+
for (String managedServerName : managedServerNames) {
661+
verifyConnectionBetweenClusterMembers(managedServerName, managedServerNames);
662+
}
727663

728664
// verify when a domain/cluster is rolling restarted without changing the spec.introspectVersion,
729665
// all server pods' weblogic.introspectVersion label stay unchanged after the pods are restarted.
@@ -1369,22 +1305,6 @@ private void verifyIntrospectVersionLabelValue(String podName, String introspect
13691305
}
13701306
}
13711307

1372-
/**
1373-
* Uninstall Nginx.
1374-
* The cleanup framework does not uninstall Nginx release.
1375-
* Do it here for now.
1376-
*/
1377-
@AfterAll
1378-
public void tearDownAll() {
1379-
// uninstall NGINX release
1380-
if (nginxHelmParams != null) {
1381-
assertThat(uninstallNginx(nginxHelmParams))
1382-
.as("Test uninstallNginx returns true")
1383-
.withFailMessage("uninstallNginx() did not return true")
1384-
.isTrue();
1385-
}
1386-
}
1387-
13881308
// copy samples directory to a temporary location
13891309
private static void setupSample() {
13901310
assertDoesNotThrow(() -> {
@@ -1412,4 +1332,17 @@ private String executeLifecycleScript(String script, String extraParams) {
14121332

14131333
return execResult.toString();
14141334
}
1335+
1336+
private void verifyConnectionBetweenClusterMembers(String serverName, List<String> managedServerNames) {
1337+
String podName = domainUid + "-" + serverName;
1338+
final String command = String.format(
1339+
"kubectl exec -n " + introDomainNamespace + " " + podName + " -- curl http://"
1340+
+ ADMIN_USERNAME_DEFAULT
1341+
+ ":"
1342+
+ ADMIN_PASSWORD_DEFAULT
1343+
+ "@" + podName + ":%s/clusterview/ClusterViewServlet"
1344+
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
1345+
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"",managedServerPort);
1346+
verifyServerCommunication(command, serverName, managedServerNames);
1347+
}
14151348
}

0 commit comments

Comments
 (0)