Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,15 @@ 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";
private static String domain4Uid = "monexp-domain-4";
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;
Expand Down Expand Up @@ -247,7 +249,7 @@ class ItMonitoringExporter {
*/
@BeforeAll

public static void initAll(@Namespaces(11) List<String> namespaces) {
public static void initAll(@Namespaces(12) List<String> namespaces) {

logger = getLogger();
// create standard, reusable retry/backoff policy
Expand Down Expand Up @@ -299,9 +301,13 @@ public static void initAll(@Namespaces(11) List<String> 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();
Expand All @@ -312,7 +318,7 @@ public static void initAll(@Namespaces(11) List<String> 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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -606,6 +612,39 @@ public void testBasicFunctionality() throws Exception {
replaceMetricsNoRestPortConfiguration();
}


/**
* 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.
*/
//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 {

// 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 wls 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.
*/
Expand All @@ -617,7 +656,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");
Expand Down Expand Up @@ -1509,14 +1549,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<String> appList = new ArrayList();
appList.add(appName);
appList.add(SESSMIGR_APP_NAME);

// build the model file list
final List<String> modelList = Collections.singletonList(modelFile);
Expand All @@ -1532,7 +1572,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);
Expand All @@ -1541,7 +1581,7 @@ private static String createAndVerifyMiiImage(String monexpAppDir) {
appList.add(SESSMIGR_APP_NAME);

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

Expand Down Expand Up @@ -1815,13 +1855,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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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'