Skip to content

Commit c135b96

Browse files
authored
added test for Adminport enabled (#2283)
* added test for Adminport enabled
1 parent d02c538 commit c135b96

File tree

2 files changed

+105
-14
lines changed

2 files changed

+105
-14
lines changed

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

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,15 @@ class ItMonitoringExporter {
192192
private static String domain5Namespace = null;
193193
private static String domain6Namespace = null;
194194
private static String domain7Namespace = null;
195+
private static String domain8Namespace = null;
195196
private static String domain1Uid = "monexp-domain-1";
196197
private static String domain2Uid = "monexp-domain-2";
197198
private static String domain3Uid = "monexp-domain-3";
198199
private static String domain4Uid = "monexp-domain-4";
199200
private static String domain5Uid = "monexp-domain-5";
200201
private static String domain6Uid = "monexp-domain-6";
201202
private static String domain7Uid = "monexp-domain-7";
203+
private static String domain8Uid = "monexp-domain-8";
202204
private static HelmParams nginxHelmParams = null;
203205
private static int nodeportshttp = 0;
204206
private static int nodeportshttps = 0;
@@ -247,7 +249,7 @@ class ItMonitoringExporter {
247249
*/
248250
@BeforeAll
249251

250-
public static void initAll(@Namespaces(11) List<String> namespaces) {
252+
public static void initAll(@Namespaces(12) List<String> namespaces) {
251253

252254
logger = getLogger();
253255
// create standard, reusable retry/backoff policy
@@ -299,9 +301,13 @@ public static void initAll(@Namespaces(11) List<String> namespaces) {
299301
assertNotNull(namespaces.get(10), "Namespace list is null");
300302
domain7Namespace = namespaces.get(10);
301303

304+
logger.info("Get a unique namespace for domain8");
305+
assertNotNull(namespaces.get(11), "Namespace list is null");
306+
domain8Namespace = namespaces.get(11);
307+
302308
logger.info("install and verify operator");
303309
installAndVerifyOperator(opNamespace, domain1Namespace,domain2Namespace,domain3Namespace,
304-
domain4Namespace,domain5Namespace, domain6Namespace, domain7Namespace);
310+
domain4Namespace,domain5Namespace, domain6Namespace, domain7Namespace, domain8Namespace);
305311

306312
logger.info("install monitoring exporter");
307313
installMonitoringExporter();
@@ -312,7 +318,7 @@ public static void initAll(@Namespaces(11) List<String> namespaces) {
312318
//buildMonitoringExporterImage("phx.ocir.io/weblogick8s/exporter:beta");
313319

314320
logger.info("create and verify WebLogic domain image using model in image with model files");
315-
miiImage = createAndVerifyMiiImage(monitoringExporterAppDir);
321+
miiImage = createAndVerifyMiiImage(monitoringExporterAppDir, MODEL_DIR + "/" + MONEXP_MODEL_FILE);
316322

317323
// install and verify NGINX
318324
nginxHelmParams = installAndVerifyNginx(nginxNamespace, 0, 0);
@@ -408,7 +414,7 @@ public void testSideCarBasicFunctionality() throws Exception {
408414

409415
// create and verify one cluster mii domain
410416
logger.info("Create domain and verify that it's running");
411-
String miiImage1 = createAndVerifyMiiImage(SESSMIGR_APP_NAME, MODEL_DIR + "/model.sessmigr.yaml");
417+
String miiImage1 = createAndVerifyMiiImage(MODEL_DIR + "/model.sessmigr.yaml");
412418
String yaml = RESOURCE_DIR + "/exporter/rest_webapp.yaml";
413419
createAndVerifyDomain(miiImage1, domain7Uid, domain7Namespace, "FromModel", 2, false, yaml);
414420
installPrometheusGrafana(PROMETHEUS_CHART_VERSION, GRAFANA_CHART_VERSION,
@@ -497,7 +503,7 @@ public void testSideCarBasicFunctionalityTwoClusters() throws Exception {
497503

498504
// create and verify one cluster mii domain
499505
logger.info("Create domain and verify that it's running");
500-
String miiImage1 = createAndVerifyMiiImage(SESSMIGR_APP_NAME, MODEL_DIR + "/model.sessmigr.2clusters.yaml");
506+
String miiImage1 = createAndVerifyMiiImage(MODEL_DIR + "/model.sessmigr.2clusters.yaml");
501507
String yaml = RESOURCE_DIR + "/exporter/rest_jvm.yaml";
502508
createAndVerifyDomain(miiImage1, domain5Uid, domain5Namespace, "FromModel", 2, true, yaml);
503509
installPrometheusGrafana(PROMETHEUS_CHART_VERSION, GRAFANA_CHART_VERSION,
@@ -526,7 +532,7 @@ public void testSideCarBasicFunctionalityWithSSL() throws Exception {
526532
// create and verify one cluster mii domain
527533
logger.info("Create domain and verify that it's running");
528534
String yaml = RESOURCE_DIR + "/exporter/rest_webapp.yaml";
529-
String miiImage1 = createAndVerifyMiiImage(SESSMIGR_APP_NAME,MODEL_DIR + "/model.ssl.yaml");
535+
String miiImage1 = createAndVerifyMiiImage(MODEL_DIR + "/model.ssl.yaml");
530536
createAndVerifyDomain(miiImage1, domain6Uid, domain6Namespace, "FromModel", 2, false, yaml);
531537
installPrometheusGrafana(PROMETHEUS_CHART_VERSION, GRAFANA_CHART_VERSION,
532538
domain6Namespace,
@@ -606,6 +612,39 @@ public void testBasicFunctionality() throws Exception {
606612
replaceMetricsNoRestPortConfiguration();
607613
}
608614

615+
616+
/**
617+
* Test covers scenario when admin port enabled .
618+
* Create Model in Image with admin port and ssl enabled.
619+
* Check generated monitoring exporter WebLogic metrics via https request.
620+
*/
621+
//commented out untill Issue (see oracle/weblogic-monitoring-exporter#138) will be fixed
622+
//@Test
623+
@DisplayName("Test Accesability of Monitoring Exporter dashboard and metrics if admin port is enabled.")
624+
public void testAdminPortEnabled() throws Exception {
625+
626+
// create and verify one cluster mii domain with admin port enabled
627+
logger.info("Create domain and verify that it's running");
628+
String miiImage1 = createAndVerifyMiiImage(monitoringExporterAppDir, MODEL_DIR + "/model-adminportenabled.yaml");
629+
createAndVerifyDomain(miiImage1, domain8Uid, domain8Namespace, "FromModel", 2, false);
630+
logger.info("checking access to wls metrics via https connection");
631+
632+
assertTrue(verifyMonExpAppAccess("wls-exporter",
633+
"type: WebAppComponentRuntime",
634+
domain8Uid,
635+
domain8Namespace,
636+
true, null),
637+
"monitoring exporter dashboard page can't be accessed via https");
638+
639+
assertTrue(verifyMonExpAppAccess("wls-exporter/metrics",
640+
"wls_servlet_invocation_total_count",
641+
domain8Uid,
642+
domain8Namespace,
643+
true, null),
644+
"monitoring exporter metrics page can't be accessed via https");
645+
646+
}
647+
609648
/**
610649
* Verify access to monitoring exporter WebLogic metrics via https.
611650
*/
@@ -617,7 +656,8 @@ public void testAccessExporterViaHttps() throws Exception {
617656
try {
618657
logger.info("create and verify WebLogic domain image using model in image with model files for norestport");
619658

620-
miiImage1 = createAndVerifyMiiImage(monitoringExporterAppDir + "/norestport");
659+
miiImage1 = createAndVerifyMiiImage(monitoringExporterAppDir + "/norestport",
660+
MODEL_DIR + "/" + MONEXP_MODEL_FILE);
621661

622662
// create and verify one cluster mii domain
623663
logger.info("Create domain and verify that it's running");
@@ -1509,14 +1549,14 @@ private static void deleteMonitoringExporterTempDir() {
15091549

15101550

15111551
/**
1512-
* Create mii image.
1552+
* Create mii image with SESSMIGR application.
15131553
*/
1514-
private static String createAndVerifyMiiImage(String appName, String modelFile) {
1554+
private static String createAndVerifyMiiImage(String modelFile) {
15151555
// create image with model files
15161556
logger.info("Create image with model file and verify");
15171557

15181558
List<String> appList = new ArrayList();
1519-
appList.add(appName);
1559+
appList.add(SESSMIGR_APP_NAME);
15201560

15211561
// build the model file list
15221562
final List<String> modelList = Collections.singletonList(modelFile);
@@ -1532,7 +1572,7 @@ private static String createAndVerifyMiiImage(String appName, String modelFile)
15321572
/**
15331573
* Create mii image with monitoring exporter webapp.
15341574
*/
1535-
private static String createAndVerifyMiiImage(String monexpAppDir) {
1575+
private static String createAndVerifyMiiImage(String monexpAppDir, String modelFilePath) {
15361576
// create image with model files
15371577
logger.info("Create image with model file with monitoring exporter app and verify");
15381578
String appPath = String.format("%s/wls-exporter.war", monexpAppDir);
@@ -1541,7 +1581,7 @@ private static String createAndVerifyMiiImage(String monexpAppDir) {
15411581
appList.add(SESSMIGR_APP_NAME);
15421582

15431583
// build the model file list
1544-
final List<String> modelList = Collections.singletonList(MODEL_DIR + "/" + MONEXP_MODEL_FILE);
1584+
final List<String> modelList = Collections.singletonList(modelFilePath);
15451585
String myImage =
15461586
createMiiImageAndVerify(MONEXP_IMAGE_NAME, modelList, appList);
15471587

@@ -1815,13 +1855,17 @@ private boolean verifyMonExpAppAccess(String uri, String searchKey, String domai
18151855
protocol = "https";
18161856
port = "8100";
18171857
}
1858+
String podName = domainUid + "-" + clusterName + "-managed-server1";
1859+
if (clusterName == null) {
1860+
podName = domainUid + "-managed-server1";
1861+
}
18181862
// access metrics
18191863
final String command = String.format(
1820-
"kubectl exec -n " + domainNS + " " + domainUid + "-" + clusterName + "-managed-server1 -- curl -k %s://"
1864+
"kubectl exec -n " + domainNS + " " + podName + " -- curl -k %s://"
18211865
+ ADMIN_USERNAME_DEFAULT
18221866
+ ":"
18231867
+ ADMIN_PASSWORD_DEFAULT
1824-
+ "@" + domainUid + "-" + clusterName + "-managed-server1:%s/%s", protocol, port, uri);
1868+
+ "@" + podName + ":%s/%s", protocol, port, uri);
18251869
logger.info("accessing managed server exporter via " + command);
18261870

18271871
boolean isFound = false;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright (c) 2021, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
domainInfo:
5+
AdminUserName: '@@SECRET:__weblogic-credentials__:username@@'
6+
AdminPassword: '@@SECRET:__weblogic-credentials__:password@@'
7+
ServerStartMode: 'prod'
8+
9+
topology:
10+
Name: "wls-monexp-domain-1"
11+
AdminServerName: "admin-server"
12+
AdministrationPortEnabled: true
13+
14+
Cluster:
15+
"cluster-1":
16+
DynamicServers:
17+
ServerTemplate: "cluster-1-template"
18+
ServerNamePrefix: "managed-server"
19+
DynamicClusterSize: 5
20+
MaxDynamicClusterSize: 5
21+
CalculatedListenPorts: false
22+
Server:
23+
"admin-server":
24+
ListenPort: 7001
25+
AdministrationPort: 7099
26+
SSL:
27+
Enabled: true
28+
ListenPort: 7002
29+
ServerTemplate:
30+
"cluster-1-template":
31+
Cluster: "cluster-1"
32+
ListenPort : 8001
33+
SSL:
34+
Enabled: true
35+
ListenPort: 8100
36+
HostnameVerificationIgnored: true
37+
38+
appDeployments:
39+
Application:
40+
"wls-exporter":
41+
SourcePath: "wlsdeploy/applications/wls-exporter.war"
42+
ModuleType: war
43+
Target: 'cluster-1'
44+
myear:
45+
SourcePath: "wlsdeploy/applications/sessmigr-app.ear"
46+
ModuleType: ear
47+
Target: 'cluster-1'

0 commit comments

Comments
 (0)