From 98f14201a3a0d44a4bb85931475de932db57c1f9 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Fri, 26 Mar 2021 00:10:18 +0000 Subject: [PATCH 1/3] added test for Adminport enabled --- .../kubernetes/ItMonitoringExporter.java | 74 +++++++++++++++---- .../wdt-models/model-adminportenabled.yaml | 47 ++++++++++++ 2 files changed, 107 insertions(+), 14 deletions(-) create mode 100644 integration-tests/src/test/resources/wdt-models/model-adminportenabled.yaml diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java index c9b887b4856..0e5d9929d3f 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java @@ -192,6 +192,7 @@ class ItMonitoringExporter { private static String domain5Namespace = null; private static String domain6Namespace = null; private static String domain7Namespace = null; + private static String domain8Namespace = null; private static String domain1Uid = "monexp-domain-1"; private static String domain2Uid = "monexp-domain-2"; private static String domain3Uid = "monexp-domain-3"; @@ -199,6 +200,7 @@ class ItMonitoringExporter { private static String domain5Uid = "monexp-domain-5"; private static String domain6Uid = "monexp-domain-6"; private static String domain7Uid = "monexp-domain-7"; + private static String domain8Uid = "monexp-domain-8"; private static HelmParams nginxHelmParams = null; private static int nodeportshttp = 0; private static int nodeportshttps = 0; @@ -247,7 +249,7 @@ class ItMonitoringExporter { */ @BeforeAll - public static void initAll(@Namespaces(11) List namespaces) { + public static void initAll(@Namespaces(12) List namespaces) { logger = getLogger(); // create standard, reusable retry/backoff policy @@ -299,9 +301,13 @@ public static void initAll(@Namespaces(11) List namespaces) { assertNotNull(namespaces.get(10), "Namespace list is null"); domain7Namespace = namespaces.get(10); + logger.info("Get a unique namespace for domain8"); + assertNotNull(namespaces.get(11), "Namespace list is null"); + domain8Namespace = namespaces.get(11); + logger.info("install and verify operator"); installAndVerifyOperator(opNamespace, domain1Namespace,domain2Namespace,domain3Namespace, - domain4Namespace,domain5Namespace, domain6Namespace, domain7Namespace); + domain4Namespace,domain5Namespace, domain6Namespace, domain7Namespace, domain8Namespace); logger.info("install monitoring exporter"); installMonitoringExporter(); @@ -312,7 +318,7 @@ public static void initAll(@Namespaces(11) List namespaces) { //buildMonitoringExporterImage("phx.ocir.io/weblogick8s/exporter:beta"); logger.info("create and verify WebLogic domain image using model in image with model files"); - miiImage = createAndVerifyMiiImage(monitoringExporterAppDir); + miiImage = createAndVerifyMiiImage(monitoringExporterAppDir, MODEL_DIR + "/" + MONEXP_MODEL_FILE); // install and verify NGINX nginxHelmParams = installAndVerifyNginx(nginxNamespace, 0, 0); @@ -408,7 +414,7 @@ public void testSideCarBasicFunctionality() throws Exception { // create and verify one cluster mii domain logger.info("Create domain and verify that it's running"); - String miiImage1 = createAndVerifyMiiImage(SESSMIGR_APP_NAME, MODEL_DIR + "/model.sessmigr.yaml"); + String miiImage1 = createAndVerifyMiiImage(MODEL_DIR + "/model.sessmigr.yaml"); String yaml = RESOURCE_DIR + "/exporter/rest_webapp.yaml"; createAndVerifyDomain(miiImage1, domain7Uid, domain7Namespace, "FromModel", 2, false, yaml); installPrometheusGrafana(PROMETHEUS_CHART_VERSION, GRAFANA_CHART_VERSION, @@ -497,7 +503,7 @@ public void testSideCarBasicFunctionalityTwoClusters() throws Exception { // create and verify one cluster mii domain logger.info("Create domain and verify that it's running"); - String miiImage1 = createAndVerifyMiiImage(SESSMIGR_APP_NAME, MODEL_DIR + "/model.sessmigr.2clusters.yaml"); + String miiImage1 = createAndVerifyMiiImage(MODEL_DIR + "/model.sessmigr.2clusters.yaml"); String yaml = RESOURCE_DIR + "/exporter/rest_jvm.yaml"; createAndVerifyDomain(miiImage1, domain5Uid, domain5Namespace, "FromModel", 2, true, yaml); installPrometheusGrafana(PROMETHEUS_CHART_VERSION, GRAFANA_CHART_VERSION, @@ -526,7 +532,7 @@ public void testSideCarBasicFunctionalityWithSSL() throws Exception { // create and verify one cluster mii domain logger.info("Create domain and verify that it's running"); String yaml = RESOURCE_DIR + "/exporter/rest_webapp.yaml"; - String miiImage1 = createAndVerifyMiiImage(SESSMIGR_APP_NAME,MODEL_DIR + "/model.ssl.yaml"); + String miiImage1 = createAndVerifyMiiImage(MODEL_DIR + "/model.ssl.yaml"); createAndVerifyDomain(miiImage1, domain6Uid, domain6Namespace, "FromModel", 2, false, yaml); installPrometheusGrafana(PROMETHEUS_CHART_VERSION, GRAFANA_CHART_VERSION, domain6Namespace, @@ -606,6 +612,41 @@ public void testBasicFunctionality() throws Exception { replaceMetricsNoRestPortConfiguration(); } + + /** + * Test covers basic functionality for MonitoringExporter SideCar . + * Create Prometheus, Grafana. + * Create Model in Image with SSL enabled. + * Check generated monitoring exporter WebLogic metrics via Prometheus, Grafana. + * Check basic functionality of monitoring exporter. + */ + + @Test + @DisplayName("Test Accesability of Monitoring Exporter dashboard and metrics if admin port is enabled.") + public void testAdminPortEnabled() throws Exception { + + // create and verify one cluster mii domain with admin pod enabled + logger.info("Create domain and verify that it's running"); + String miiImage1 = createAndVerifyMiiImage(monitoringExporterAppDir, MODEL_DIR + "/model-adminportenabled.yaml"); + createAndVerifyDomain(miiImage1, domain8Uid, domain8Namespace, "FromModel", 2, false); + logger.info("checking access to wl metrics via https connection"); + + assertTrue(verifyMonExpAppAccess("wls-exporter", + "type: WebAppComponentRuntime", + domain8Uid, + domain8Namespace, + true, null), + "monitoring exporter dashboard page can't be accessed via https"); + + assertTrue(verifyMonExpAppAccess("wls-exporter/metrics", + "wls_servlet_invocation_total_count", + domain8Uid, + domain8Namespace, + true, null), + "monitoring exporter metrics page can't be accessed via https"); + + } + /** * Verify access to monitoring exporter WebLogic metrics via https. */ @@ -617,7 +658,8 @@ public void testAccessExporterViaHttps() throws Exception { try { logger.info("create and verify WebLogic domain image using model in image with model files for norestport"); - miiImage1 = createAndVerifyMiiImage(monitoringExporterAppDir + "/norestport"); + miiImage1 = createAndVerifyMiiImage(monitoringExporterAppDir + "/norestport", + MODEL_DIR + "/" + MONEXP_MODEL_FILE); // create and verify one cluster mii domain logger.info("Create domain and verify that it's running"); @@ -1509,14 +1551,14 @@ private static void deleteMonitoringExporterTempDir() { /** - * Create mii image. + * Create mii image with SESSMIGR application. */ - private static String createAndVerifyMiiImage(String appName, String modelFile) { + private static String createAndVerifyMiiImage(String modelFile) { // create image with model files logger.info("Create image with model file and verify"); List appList = new ArrayList(); - appList.add(appName); + appList.add(SESSMIGR_APP_NAME); // build the model file list final List modelList = Collections.singletonList(modelFile); @@ -1532,7 +1574,7 @@ private static String createAndVerifyMiiImage(String appName, String modelFile) /** * Create mii image with monitoring exporter webapp. */ - private static String createAndVerifyMiiImage(String monexpAppDir) { + private static String createAndVerifyMiiImage(String monexpAppDir, String modelFilePath) { // create image with model files logger.info("Create image with model file with monitoring exporter app and verify"); String appPath = String.format("%s/wls-exporter.war", monexpAppDir); @@ -1541,7 +1583,7 @@ private static String createAndVerifyMiiImage(String monexpAppDir) { appList.add(SESSMIGR_APP_NAME); // build the model file list - final List modelList = Collections.singletonList(MODEL_DIR + "/" + MONEXP_MODEL_FILE); + final List modelList = Collections.singletonList(modelFilePath); String myImage = createMiiImageAndVerify(MONEXP_IMAGE_NAME, modelList, appList); @@ -1815,13 +1857,17 @@ private boolean verifyMonExpAppAccess(String uri, String searchKey, String domai protocol = "https"; port = "8100"; } + String podName = domainUid + "-" + clusterName + "-managed-server1"; + if (clusterName == null) { + podName = domainUid + "-managed-server1"; + } // access metrics final String command = String.format( - "kubectl exec -n " + domainNS + " " + domainUid + "-" + clusterName + "-managed-server1 -- curl -k %s://" + "kubectl exec -n " + domainNS + " " + podName + " -- curl -k %s://" + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT - + "@" + domainUid + "-" + clusterName + "-managed-server1:%s/%s", protocol, port, uri); + + "@" + podName + ":%s/%s", protocol, port, uri); logger.info("accessing managed server exporter via " + command); boolean isFound = false; diff --git a/integration-tests/src/test/resources/wdt-models/model-adminportenabled.yaml b/integration-tests/src/test/resources/wdt-models/model-adminportenabled.yaml new file mode 100644 index 00000000000..1154247aeaa --- /dev/null +++ b/integration-tests/src/test/resources/wdt-models/model-adminportenabled.yaml @@ -0,0 +1,47 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +domainInfo: + AdminUserName: '@@SECRET:__weblogic-credentials__:username@@' + AdminPassword: '@@SECRET:__weblogic-credentials__:password@@' + ServerStartMode: 'prod' + +topology: + Name: "wls-monexp-domain-1" + AdminServerName: "admin-server" + AdministrationPortEnabled: true + + Cluster: + "cluster-1": + DynamicServers: + ServerTemplate: "cluster-1-template" + ServerNamePrefix: "managed-server" + DynamicClusterSize: 5 + MaxDynamicClusterSize: 5 + CalculatedListenPorts: false + Server: + "admin-server": + ListenPort: 7001 + AdministrationPort: 7099 + SSL: + Enabled: true + ListenPort: 7002 + ServerTemplate: + "cluster-1-template": + Cluster: "cluster-1" + ListenPort : 8001 + SSL: + Enabled: true + ListenPort: 8100 + HostnameVerificationIgnored: true + +appDeployments: + Application: + "wls-exporter": + SourcePath: "wlsdeploy/applications/wls-exporter.war" + ModuleType: war + Target: 'cluster-1' + myear: + SourcePath: "wlsdeploy/applications/sessmigr-app.ear" + ModuleType: ear + Target: 'cluster-1' \ No newline at end of file From 72aa76aa441758b3ac0f3147c15a30789b4e6877 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Fri, 26 Mar 2021 02:29:58 +0000 Subject: [PATCH 2/3] corrected javadocs --- .../weblogic/kubernetes/ItMonitoringExporter.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java index 0e5d9929d3f..c3a2ec4df86 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java @@ -614,22 +614,20 @@ public void testBasicFunctionality() throws Exception { /** - * Test covers basic functionality for MonitoringExporter SideCar . - * Create Prometheus, Grafana. - * Create Model in Image with SSL enabled. - * Check generated monitoring exporter WebLogic metrics via Prometheus, Grafana. - * Check basic functionality of monitoring exporter. + * Test covers scenario when admin port enabled . + * Create Model in Image with admin port and ssl enabled. + * Check generated monitoring exporter WebLogic metrics via https request. */ @Test @DisplayName("Test Accesability of Monitoring Exporter dashboard and metrics if admin port is enabled.") public void testAdminPortEnabled() throws Exception { - // create and verify one cluster mii domain with admin pod enabled + // create and verify one cluster mii domain with admin port enabled logger.info("Create domain and verify that it's running"); String miiImage1 = createAndVerifyMiiImage(monitoringExporterAppDir, MODEL_DIR + "/model-adminportenabled.yaml"); createAndVerifyDomain(miiImage1, domain8Uid, domain8Namespace, "FromModel", 2, false); - logger.info("checking access to wl metrics via https connection"); + logger.info("checking access to wls metrics via https connection"); assertTrue(verifyMonExpAppAccess("wls-exporter", "type: WebAppComponentRuntime", From 3fdbb7372d968b3baba98de33b6b5533e0564d3c Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Fri, 26 Mar 2021 20:44:11 +0000 Subject: [PATCH 3/3] commented out the test untill issue will be fixed --- .../java/oracle/weblogic/kubernetes/ItMonitoringExporter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java index c3a2ec4df86..cabb03257e2 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java @@ -618,8 +618,8 @@ public void testBasicFunctionality() throws Exception { * Create Model in Image with admin port and ssl enabled. * Check generated monitoring exporter WebLogic metrics via https request. */ - - @Test + //commented out untill Issue (see oracle/weblogic-monitoring-exporter#138) will be fixed + //@Test @DisplayName("Test Accesability of Monitoring Exporter dashboard and metrics if admin port is enabled.") public void testAdminPortEnabled() throws Exception {