From c9178bcd16371434cb3a30efbc6301b74a11c088 Mon Sep 17 00:00:00 2001 From: "MAGGIE.HE@ORACLE.COM" Date: Thu, 2 Dec 2021 03:19:58 +0000 Subject: [PATCH 1/3] backport remoteConsole integ fix to release/3.3 --- .../weblogic/kubernetes/ItRemoteConsole.java | 171 +++++------------- 1 file changed, 49 insertions(+), 122 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java index d5b11812ca2..bea3cc31479 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java @@ -31,25 +31,23 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; +import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT; import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE; +import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT; import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST; import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE; import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME; import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG; import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT; -import static oracle.weblogic.kubernetes.TestConstants.VOYAGER_CHART_NAME; import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR; -import static oracle.weblogic.kubernetes.actions.TestActions.createIngress; import static oracle.weblogic.kubernetes.actions.TestActions.listIngresses; import static oracle.weblogic.kubernetes.actions.impl.Service.getServiceNodePort; -import static oracle.weblogic.kubernetes.assertions.TestAssertions.isVoyagerReady; import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady; import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReturnedCode; import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createMiiDomainAndVerify; import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.createIngressAndRetryIfFail; import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyNginx; import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyTraefik; -import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyVoyager; import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator; import static oracle.weblogic.kubernetes.utils.PodUtils.getExternalServicePodName; import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger; @@ -68,12 +66,9 @@ class ItRemoteConsole { private static String domainNamespace = null; private static String traefikNamespace = null; - private static String voyagerNamespace = null; private static String nginxNamespace = null; private static HelmParams traefikHelmParams = null; - private static HelmParams voyagerHelmParams = null; private static HelmParams nginxHelmParams = null; - private static int voyagerNodePort; private static int nginxNodePort; // domain constants @@ -83,8 +78,7 @@ class ItRemoteConsole { private static final String managedServerPrefix = domainUid + "-" + MANAGED_SERVER_NAME_BASE; private static LoggingFacade logger = null; private static final int ADMIN_SERVER_PORT = 7001; - private static final String voyagerIngressName = "voyager-path-routing"; - + private static ConditionFactory withStandardRetryPolicy = with().pollDelay(2, SECONDS) .and().with().pollInterval(10, SECONDS) @@ -97,7 +91,7 @@ class ItRemoteConsole { * JUnit engine parameter resolution mechanism */ @BeforeAll - public static void initAll(@Namespaces(5) List namespaces) { + public static void initAll(@Namespaces(4) List namespaces) { logger = getLogger(); // get a unique operator namespace logger.info("Getting a unique namespace for operator"); @@ -113,15 +107,10 @@ public static void initAll(@Namespaces(5) List namespaces) { assertNotNull(namespaces.get(2), "Namespace list is null"); traefikNamespace = namespaces.get(2); - // get a unique Voyager namespace - logger.info("Assign a unique namespace for Voyager"); - assertNotNull(namespaces.get(3), "Namespace list is null"); - voyagerNamespace = namespaces.get(3); - // get a unique Nginx namespace logger.info("Assign a unique namespace for Nginx"); - assertNotNull(namespaces.get(4), "Namespace list is null"); - nginxNamespace = namespaces.get(4); + assertNotNull(namespaces.get(3), "Namespace list is null"); + nginxNamespace = namespaces.get(3); // install and verify operator installAndVerifyOperator(opNamespace, domainNamespace); @@ -130,12 +119,6 @@ public static void initAll(@Namespaces(5) List namespaces) { logger.info("Installing Traefik controller using helm"); traefikHelmParams = installAndVerifyTraefik(traefikNamespace, 0, 0); - // install and verify Voyager - final String cloudProvider = "baremetal"; - final boolean enableValidatingWebhook = false; - voyagerHelmParams = - installAndVerifyVoyager(voyagerNamespace, cloudProvider, enableValidatingWebhook); - // install and verify Nginx nginxHelmParams = installAndVerifyNginx(nginxNamespace, 0, 0); @@ -148,9 +131,8 @@ public static void initAll(@Namespaces(5) List namespaces) { managedServerPrefix, replicaCount); - // create ingress rules with path routing for Traefik, Voyager and NGINX + // create ingress rules with path routing for Traefik, and NGINX createTraefikIngressRoutingRules(domainNamespace); - createVoyagerIngressPathRoutingRules(); createNginxIngressPathRoutingRules(); // install WebLogic remote console @@ -161,7 +143,7 @@ public static void initAll(@Namespaces(5) List namespaces) { } /** - * Verify k8s WebLogic domain is accessible through remote console using Traefik. + * Access WebLogic domain through remote console using Traefik. */ @Test @DisplayName("Verify Connecting to Mii domain WLS Remote Console through Traefik is successful") @@ -172,37 +154,12 @@ void testWlsRemoteConsoleConnectionThroughTraefik() { "Could not get the default external service node port"); logger.info("Found the Traefik service nodePort {0}", traefikNodePort); logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST); - String curlCmd = "curl -v --user weblogic:welcome1 -H Content-Type:application/json -d " - + "\"{ \\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://" - + K8S_NODEPORT_HOST + ":" + traefikNodePort + "\\" + "\" }" + "\"" - + " http://localhost:8012/api/connection --write-out %{http_code} -o /dev/null"; - logger.info("Executing Traefik nodeport curl command {0}", curlCmd); - assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed"); + verifyRemoteConsoleConnectionThroughLB(traefikNodePort); logger.info("WebLogic domain is accessible through remote console using Traefik"); } - /** - * Verify k8s WebLogic domain is accessible through remote console using Voyager. - */ - @Test - @DisplayName("Verify Connecting to Mii domain WLS Remote Console through Voyager is successful") - void testWlsRemoteConsoleConnectionThroughVoyager() { - - assertTrue(voyagerNodePort != -1, "Could not get the default external service node port"); - logger.info("Found the Voyager service nodePort {0}", voyagerNodePort); - logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST); - - String curlCmd = "curl -v --user weblogic:welcome1 -H Content-Type:application/json -d " - + "\"{ \\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://" - + K8S_NODEPORT_HOST + ":" + voyagerNodePort + "\\" + "\" }" + "\"" - + " http://localhost:8012/api/connection --write-out %{http_code} -o /dev/null"; - logger.info("Executing Voyager nodeport curl command {0}", curlCmd); - assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed"); - logger.info("WebLogic domain is accessible through remote console using Voyager"); - } - - /** - * Verify k8s WebLogic domain is accessible through remote console using NGINX. + /** + * Access WebLogic domain through remote console using NGINX. */ @Test @DisplayName("Verify Connecting to Mii domain WLS Remote Console through NGINX is successful") @@ -212,12 +169,7 @@ void testWlsRemoteConsoleConnectionThroughNginx() { logger.info("Found the NGINX service nodePort {0}", nginxNodePort); logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST); - String curlCmd = "curl -v --user weblogic:welcome1 -H Content-Type:application/json -d " - + "\"{ \\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://" - + K8S_NODEPORT_HOST + ":" + nginxNodePort + "\\" + "\" }" + "\"" - + " http://localhost:8012/api/connection --write-out %{http_code} -o /dev/null"; - logger.info("Executing NGINX nodeport curl command {0}", curlCmd); - assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed"); + verifyRemoteConsoleConnectionThroughLB(nginxNodePort); logger.info("WebLogic domain is accessible through remote console using NGINX"); } @@ -258,64 +210,6 @@ private static void createTraefikIngressRoutingRules(String domainNamespace) { } } - private static void createVoyagerIngressPathRoutingRules() { - - // set the annotations for Voyager - HashMap annotations = new HashMap<>(); - annotations.put("ingress.appscode.com/type", "NodePort"); - annotations.put("kubernetes.io/ingress.class", "voyager"); - annotations.put("ingress.appscode.com/rewrite-target", "/"); - - List ingressRules = new ArrayList<>(); - List httpIngressPaths = new ArrayList<>(); - - NetworkingV1beta1HTTPIngressPath httpIngressPath = new NetworkingV1beta1HTTPIngressPath() - .path("/") - .backend(new NetworkingV1beta1IngressBackend() - .serviceName(domainUid + "-admin-server") - .servicePort(new IntOrString(ADMIN_SERVER_PORT)) - ); - httpIngressPaths.add(httpIngressPath); - - NetworkingV1beta1IngressRule ingressRule = new NetworkingV1beta1IngressRule() - .host("") - .http(new NetworkingV1beta1HTTPIngressRuleValue() - .paths(httpIngressPaths)); - - ingressRules.add(ingressRule); - - assertDoesNotThrow(() -> createIngress(voyagerIngressName, domainNamespace, annotations, ingressRules, null)); - - // wait until voyager ingress pod is ready - withStandardRetryPolicy - .conditionEvaluationListener( - condition -> logger.info( - "Waiting for Voyager ingress to be ready in namespace {0} (elapsed time {1}ms, remaining time {2}ms)", - domainNamespace, - condition.getElapsedTimeInMS(), - condition.getRemainingTimeInMS())) - .until(assertDoesNotThrow(() -> isVoyagerReady(domainNamespace, voyagerIngressName), - "isVoyagerReady failed with ApiException")); - - // check the ingress was found in the domain namespace - assertThat(assertDoesNotThrow(() -> listIngresses(domainNamespace))) - .as(String.format("Test ingress %s was found in namespace %s", voyagerIngressName, domainNamespace)) - .withFailMessage(String.format("Ingress %s was not found in namespace %s", voyagerIngressName, domainNamespace)) - .contains(voyagerIngressName); - - logger.info("ingress {0} was created in namespace {1}", voyagerIngressName, domainNamespace); - - // check the ingress is ready to route the app to the server pod - voyagerNodePort = assertDoesNotThrow(() -> - getServiceNodePort(domainNamespace, VOYAGER_CHART_NAME + "-" + voyagerIngressName, "tcp-80"), - "Getting voyager loadbalancer service node port failed"); - String curlCmd = "curl --silent --show-error --noproxy '*' http://" + K8S_NODEPORT_HOST + ":" + voyagerNodePort - + "/weblogic/ready --write-out %{http_code} -o /dev/null"; - - logger.info("Executing curl command {0}", curlCmd); - assertTrue(callWebAppAndWaitTillReady(curlCmd, 60)); - } - private static void createNginxIngressPathRoutingRules() { // create an ingress in domain namespace @@ -372,12 +266,45 @@ private static void verifyWlsRemoteConsoleConnection() { "Could not get the default external service node port"); logger.info("Found the default service nodePort {0}", nodePort); logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST); - String curlCmd = "curl -v --user weblogic:welcome1 -H Content-Type:application/json -d " - + "\"{ \\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://" - + K8S_NODEPORT_HOST + ":" + nodePort + "\\" + "\" }" + "\"" - + " http://localhost:8012/api/connection --write-out %{http_code} -o /dev/null"; + + + //The final complete curl command to run is like: + //curl -v --show-error --user username:password http://localhost:8012/api/providers/AdminServerConnection -H + //"Content-Type:application/json" --data "{ \"name\": \"asconn\", \"domainUrl\": \"http://myhost://nodeport\"}" + //--write-out %{http_code} -o /dev/null + String curlCmd = "curl -v --show-error --noproxy '*' --user " + + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + + " http://localhost:8012/api/providers/AdminServerConnection -H " + + "\"" + "Content-Type:application/json" + "\"" + + " --data " + + "\"{\\" + "\"name\\" + "\"" + ": " + "\\" + "\"" + "asconn\\" + "\"" + ", " + + "\\" + "\"domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://" + + K8S_NODEPORT_HOST + ":" + nodePort + "\\" + "\"}" + "\"" + + " --write-out %{http_code} -o /dev/null"; logger.info("Executing default nodeport curl command {0}", curlCmd); assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), "Calling web app failed"); logger.info("WebLogic domain is accessible through remote console"); } + + private static void verifyRemoteConsoleConnectionThroughLB(int nodePortOfLB) { + logger.info("LB nodePort is {0}", nodePortOfLB); + logger.info("The K8S_NODEPORT_HOST is {0}", K8S_NODEPORT_HOST); + + //The final complete curl command to run is like: + //curl -v --user username:password http://localhost:8012/api/providers/AdminServerConnection -H + //"Content-Type:application/json" --data "{ \"name\": \"asconn\", \"domainUrl\": \"http://myhost://nodeport\"}" + //--write-out %{http_code} -o /dev/null + String curlCmd = "curl -v --user " + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + + " http://localhost:8012/api/providers/AdminServerConnection -H " + + "\"" + "Content-Type:application/json" + "\"" + + " --data " + + "\"{ \\" + "\"name\\" + "\"" + ": " + "\\" + "\"" + "asconn\\" + "\"" + ", " + + "\\" + "\"" + "domainUrl\\" + "\"" + ": " + "\\" + "\"" + "http://" + + K8S_NODEPORT_HOST + ":" + nodePortOfLB + "\\" + "\" }" + "\"" + + " --write-out %{http_code} -o /dev/null"; + logger.info("Executing LB nodeport curl command {0}", curlCmd); + assertTrue(callWebAppAndWaitTillReturnedCode(curlCmd, "201", 10), + "Calling web app failed"); + } + } From 9d33b9759e32198f471db3bb16ce287d1a7206ba Mon Sep 17 00:00:00 2001 From: "MAGGIE.HE@ORACLE.COM" Date: Fri, 7 Jan 2022 22:45:55 +0000 Subject: [PATCH 2/3] fix the checkstyle --- .../test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java index bea3cc31479..ea5c258544e 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java @@ -158,7 +158,7 @@ void testWlsRemoteConsoleConnectionThroughTraefik() { logger.info("WebLogic domain is accessible through remote console using Traefik"); } - /** + /** * Access WebLogic domain through remote console using NGINX. */ @Test From 86717fda0e62bf58864da05852e2335f78e8bb3f Mon Sep 17 00:00:00 2001 From: "MAGGIE.HE@ORACLE.COM" Date: Fri, 7 Jan 2022 22:48:16 +0000 Subject: [PATCH 3/3] modify the copyright --- .../test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java index ea5c258544e..b9351b57a32 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItRemoteConsole.java @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Oracle and/or its affiliates. +// Copyright (c) 2021, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes;