Skip to content

Commit 8907113

Browse files
Merge pull request #2706 from oracle/backport-remocon
Backport remote console PR#2649 to release/3.3
2 parents 055ac44 + a82069c commit 8907113

File tree

1 file changed

+49
-122
lines changed

1 file changed

+49
-122
lines changed

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

Lines changed: 49 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -31,25 +31,23 @@
3131

3232
import static java.util.concurrent.TimeUnit.MINUTES;
3333
import static java.util.concurrent.TimeUnit.SECONDS;
34+
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
3435
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE;
36+
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
3537
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
3638
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
3739
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
3840
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
3941
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
40-
import static oracle.weblogic.kubernetes.TestConstants.VOYAGER_CHART_NAME;
4142
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
42-
import static oracle.weblogic.kubernetes.actions.TestActions.createIngress;
4343
import static oracle.weblogic.kubernetes.actions.TestActions.listIngresses;
4444
import static oracle.weblogic.kubernetes.actions.impl.Service.getServiceNodePort;
45-
import static oracle.weblogic.kubernetes.assertions.TestAssertions.isVoyagerReady;
4645
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
4746
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReturnedCode;
4847
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createMiiDomainAndVerify;
4948
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.createIngressAndRetryIfFail;
5049
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyNginx;
5150
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyTraefik;
52-
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyVoyager;
5351
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
5452
import static oracle.weblogic.kubernetes.utils.PodUtils.getExternalServicePodName;
5553
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
@@ -68,12 +66,9 @@ class ItRemoteConsole {
6866

6967
private static String domainNamespace = null;
7068
private static String traefikNamespace = null;
71-
private static String voyagerNamespace = null;
7269
private static String nginxNamespace = null;
7370
private static HelmParams traefikHelmParams = null;
74-
private static HelmParams voyagerHelmParams = null;
7571
private static HelmParams nginxHelmParams = null;
76-
private static int voyagerNodePort;
7772
private static int nginxNodePort;
7873

7974
// domain constants
@@ -83,8 +78,7 @@ class ItRemoteConsole {
8378
private static final String managedServerPrefix = domainUid + "-" + MANAGED_SERVER_NAME_BASE;
8479
private static LoggingFacade logger = null;
8580
private static final int ADMIN_SERVER_PORT = 7001;
86-
private static final String voyagerIngressName = "voyager-path-routing";
87-
81+
8882
private static ConditionFactory withStandardRetryPolicy =
8983
with().pollDelay(2, SECONDS)
9084
.and().with().pollInterval(10, SECONDS)
@@ -97,7 +91,7 @@ class ItRemoteConsole {
9791
* JUnit engine parameter resolution mechanism
9892
*/
9993
@BeforeAll
100-
public static void initAll(@Namespaces(5) List<String> namespaces) {
94+
public static void initAll(@Namespaces(4) List<String> namespaces) {
10195
logger = getLogger();
10296
// get a unique operator namespace
10397
logger.info("Getting a unique namespace for operator");
@@ -113,15 +107,10 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
113107
assertNotNull(namespaces.get(2), "Namespace list is null");
114108
traefikNamespace = namespaces.get(2);
115109

116-
// get a unique Voyager namespace
117-
logger.info("Assign a unique namespace for Voyager");
118-
assertNotNull(namespaces.get(3), "Namespace list is null");
119-
voyagerNamespace = namespaces.get(3);
120-
121110
// get a unique Nginx namespace
122111
logger.info("Assign a unique namespace for Nginx");
123-
assertNotNull(namespaces.get(4), "Namespace list is null");
124-
nginxNamespace = namespaces.get(4);
112+
assertNotNull(namespaces.get(3), "Namespace list is null");
113+
nginxNamespace = namespaces.get(3);
125114

126115
// install and verify operator
127116
installAndVerifyOperator(opNamespace, domainNamespace);
@@ -130,12 +119,6 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
130119
logger.info("Installing Traefik controller using helm");
131120
traefikHelmParams = installAndVerifyTraefik(traefikNamespace, 0, 0);
132121

133-
// install and verify Voyager
134-
final String cloudProvider = "baremetal";
135-
final boolean enableValidatingWebhook = false;
136-
voyagerHelmParams =
137-
installAndVerifyVoyager(voyagerNamespace, cloudProvider, enableValidatingWebhook);
138-
139122
// install and verify Nginx
140123
nginxHelmParams = installAndVerifyNginx(nginxNamespace, 0, 0);
141124

@@ -148,9 +131,8 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
148131
managedServerPrefix,
149132
replicaCount);
150133

151-
// create ingress rules with path routing for Traefik, Voyager and NGINX
134+
// create ingress rules with path routing for Traefik, and NGINX
152135
createTraefikIngressRoutingRules(domainNamespace);
153-
createVoyagerIngressPathRoutingRules();
154136
createNginxIngressPathRoutingRules();
155137

156138
// install WebLogic remote console
@@ -161,7 +143,7 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
161143
}
162144

163145
/**
164-
* Verify k8s WebLogic domain is accessible through remote console using Traefik.
146+
* Access WebLogic domain through remote console using Traefik.
165147
*/
166148
@Test
167149
@DisplayName("Verify Connecting to Mii domain WLS Remote Console through Traefik is successful")
@@ -172,37 +154,12 @@ void testWlsRemoteConsoleConnectionThroughTraefik() {
172154
"Could not get the default external service node port");
173155
logger.info("Found the Traefik service nodePort {0}", traefikNodePort);
174156
logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST);
175-
String curlCmd = "curl -v --user weblogic:welcome1 -H Content-Type:application/json -d "
176-
+ "\"{ \\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://"
177-
+ K8S_NODEPORT_HOST + ":" + traefikNodePort + "\\" + "\" }" + "\""
178-
+ " http://localhost:8012/api/connection --write-out %{http_code} -o /dev/null";
179-
logger.info("Executing Traefik nodeport curl command {0}", curlCmd);
180-
assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed");
157+
verifyRemoteConsoleConnectionThroughLB(traefikNodePort);
181158
logger.info("WebLogic domain is accessible through remote console using Traefik");
182159
}
183160

184161
/**
185-
* Verify k8s WebLogic domain is accessible through remote console using Voyager.
186-
*/
187-
@Test
188-
@DisplayName("Verify Connecting to Mii domain WLS Remote Console through Voyager is successful")
189-
void testWlsRemoteConsoleConnectionThroughVoyager() {
190-
191-
assertTrue(voyagerNodePort != -1, "Could not get the default external service node port");
192-
logger.info("Found the Voyager service nodePort {0}", voyagerNodePort);
193-
logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST);
194-
195-
String curlCmd = "curl -v --user weblogic:welcome1 -H Content-Type:application/json -d "
196-
+ "\"{ \\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://"
197-
+ K8S_NODEPORT_HOST + ":" + voyagerNodePort + "\\" + "\" }" + "\""
198-
+ " http://localhost:8012/api/connection --write-out %{http_code} -o /dev/null";
199-
logger.info("Executing Voyager nodeport curl command {0}", curlCmd);
200-
assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed");
201-
logger.info("WebLogic domain is accessible through remote console using Voyager");
202-
}
203-
204-
/**
205-
* Verify k8s WebLogic domain is accessible through remote console using NGINX.
162+
* Access WebLogic domain through remote console using NGINX.
206163
*/
207164
@Test
208165
@DisplayName("Verify Connecting to Mii domain WLS Remote Console through NGINX is successful")
@@ -212,12 +169,7 @@ void testWlsRemoteConsoleConnectionThroughNginx() {
212169
logger.info("Found the NGINX service nodePort {0}", nginxNodePort);
213170
logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST);
214171

215-
String curlCmd = "curl -v --user weblogic:welcome1 -H Content-Type:application/json -d "
216-
+ "\"{ \\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://"
217-
+ K8S_NODEPORT_HOST + ":" + nginxNodePort + "\\" + "\" }" + "\""
218-
+ " http://localhost:8012/api/connection --write-out %{http_code} -o /dev/null";
219-
logger.info("Executing NGINX nodeport curl command {0}", curlCmd);
220-
assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed");
172+
verifyRemoteConsoleConnectionThroughLB(nginxNodePort);
221173
logger.info("WebLogic domain is accessible through remote console using NGINX");
222174
}
223175

@@ -258,64 +210,6 @@ private static void createTraefikIngressRoutingRules(String domainNamespace) {
258210
}
259211
}
260212

261-
private static void createVoyagerIngressPathRoutingRules() {
262-
263-
// set the annotations for Voyager
264-
HashMap<String, String> annotations = new HashMap<>();
265-
annotations.put("ingress.appscode.com/type", "NodePort");
266-
annotations.put("kubernetes.io/ingress.class", "voyager");
267-
annotations.put("ingress.appscode.com/rewrite-target", "/");
268-
269-
List<NetworkingV1beta1IngressRule> ingressRules = new ArrayList<>();
270-
List<NetworkingV1beta1HTTPIngressPath> httpIngressPaths = new ArrayList<>();
271-
272-
NetworkingV1beta1HTTPIngressPath httpIngressPath = new NetworkingV1beta1HTTPIngressPath()
273-
.path("/")
274-
.backend(new NetworkingV1beta1IngressBackend()
275-
.serviceName(domainUid + "-admin-server")
276-
.servicePort(new IntOrString(ADMIN_SERVER_PORT))
277-
);
278-
httpIngressPaths.add(httpIngressPath);
279-
280-
NetworkingV1beta1IngressRule ingressRule = new NetworkingV1beta1IngressRule()
281-
.host("")
282-
.http(new NetworkingV1beta1HTTPIngressRuleValue()
283-
.paths(httpIngressPaths));
284-
285-
ingressRules.add(ingressRule);
286-
287-
assertDoesNotThrow(() -> createIngress(voyagerIngressName, domainNamespace, annotations, ingressRules, null));
288-
289-
// wait until voyager ingress pod is ready
290-
withStandardRetryPolicy
291-
.conditionEvaluationListener(
292-
condition -> logger.info(
293-
"Waiting for Voyager ingress to be ready in namespace {0} (elapsed time {1}ms, remaining time {2}ms)",
294-
domainNamespace,
295-
condition.getElapsedTimeInMS(),
296-
condition.getRemainingTimeInMS()))
297-
.until(assertDoesNotThrow(() -> isVoyagerReady(domainNamespace, voyagerIngressName),
298-
"isVoyagerReady failed with ApiException"));
299-
300-
// check the ingress was found in the domain namespace
301-
assertThat(assertDoesNotThrow(() -> listIngresses(domainNamespace)))
302-
.as(String.format("Test ingress %s was found in namespace %s", voyagerIngressName, domainNamespace))
303-
.withFailMessage(String.format("Ingress %s was not found in namespace %s", voyagerIngressName, domainNamespace))
304-
.contains(voyagerIngressName);
305-
306-
logger.info("ingress {0} was created in namespace {1}", voyagerIngressName, domainNamespace);
307-
308-
// check the ingress is ready to route the app to the server pod
309-
voyagerNodePort = assertDoesNotThrow(() ->
310-
getServiceNodePort(domainNamespace, VOYAGER_CHART_NAME + "-" + voyagerIngressName, "tcp-80"),
311-
"Getting voyager loadbalancer service node port failed");
312-
String curlCmd = "curl --silent --show-error --noproxy '*' http://" + K8S_NODEPORT_HOST + ":" + voyagerNodePort
313-
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";
314-
315-
logger.info("Executing curl command {0}", curlCmd);
316-
assertTrue(callWebAppAndWaitTillReady(curlCmd, 60));
317-
}
318-
319213
private static void createNginxIngressPathRoutingRules() {
320214

321215
// create an ingress in domain namespace
@@ -372,12 +266,45 @@ private static void verifyWlsRemoteConsoleConnection() {
372266
"Could not get the default external service node port");
373267
logger.info("Found the default service nodePort {0}", nodePort);
374268
logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST);
375-
String curlCmd = "curl -v --user weblogic:welcome1 -H Content-Type:application/json -d "
376-
+ "\"{ \\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://"
377-
+ K8S_NODEPORT_HOST + ":" + nodePort + "\\" + "\" }" + "\""
378-
+ " http://localhost:8012/api/connection --write-out %{http_code} -o /dev/null";
269+
270+
271+
//The final complete curl command to run is like:
272+
//curl -v --show-error --user username:password http://localhost:8012/api/providers/AdminServerConnection -H
273+
//"Content-Type:application/json" --data "{ \"name\": \"asconn\", \"domainUrl\": \"http://myhost://nodeport\"}"
274+
//--write-out %{http_code} -o /dev/null
275+
String curlCmd = "curl -v --show-error --noproxy '*' --user "
276+
+ ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT
277+
+ " http://localhost:8012/api/providers/AdminServerConnection -H "
278+
+ "\"" + "Content-Type:application/json" + "\""
279+
+ " --data "
280+
+ "\"{\\" + "\"name\\" + "\"" + ": " + "\\" + "\"" + "asconn\\" + "\"" + ", "
281+
+ "\\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://"
282+
+ K8S_NODEPORT_HOST + ":" + nodePort + "\\" + "\"}" + "\""
283+
+ " --write-out %{http_code} -o /dev/null";
379284
logger.info("Executing default nodeport curl command {0}", curlCmd);
380285
assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed");
381286
logger.info("WebLogic domain is accessible through remote console");
382287
}
288+
289+
private static void verifyRemoteConsoleConnectionThroughLB(int nodePortOfLB) {
290+
logger.info("LB nodePort is {0}", nodePortOfLB);
291+
logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST);
292+
293+
//The final complete curl command to run is like:
294+
//curl -v --user username:password http://localhost:8012/api/providers/AdminServerConnection -H
295+
//"Content-Type:application/json" --data "{ \"name\": \"asconn\", \"domainUrl\": \"http://myhost://nodeport\"}"
296+
//--write-out %{http_code} -o /dev/null
297+
String curlCmd = "curl -v --user " + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT
298+
+ " http://localhost:8012/api/providers/AdminServerConnection -H "
299+
+ "\"" + "Content-Type:application/json" + "\""
300+
+ " --data "
301+
+ "\"{ \\" + "\"name\\" + "\"" + ": " + "\\" + "\"" + "asconn\\" + "\"" + ", "
302+
+ "\\" + "\"" + "domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://"
303+
+ K8S_NODEPORT_HOST + ":" + nodePortOfLB + "\\" + "\" }" + "\""
304+
+ " --write-out %{http_code} -o /dev/null";
305+
logger.info("Executing LB nodeport curl command {0}", curlCmd);
306+
assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10),
307+
"Calling web app failed");
308+
}
309+
383310
}

0 commit comments

Comments
 (0)