Skip to content

Commit aca1b9c

Browse files
committed
merge from develop
2 parents ff26633 + 9c103fd commit aca1b9c

20 files changed

+1860
-1318
lines changed

integration-tests/USECASES.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Configuration Overrides Usecases
128128
| Replace/Append Configuration with corrupted yml file via exporter console| Try to replace/append monitoring exporter configuration with config file written in corrupted yml format, verify configuration has not changed |
129129
| Replace/Append Configuration with dublicated values in the config file via exporter console| Try to replace/append monitoring exporter configuration with dublicated values in the config file, verify configuration has not changed |
130130
| End to end test to demonstrate how to setup and run WebLogic Monitoring Exporter with operator and WebLogic domain| This is fully automated version of the sample, provided in the https://github.com/oracle/weblogic-monitoring-exporter/tree/alert/samples/kubernetes/end2end |
131-
131+
| Test to scale up cluster using Prometheus Alert Manager and webhook | Use webhook, prometheus, monitoring exporter to scale up WebLogic Cluster based on metrics condition |
132132

133133

134134
| Logging with Elastic Stack | Use Case |

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

Lines changed: 1441 additions & 1248 deletions
Large diffs are not rendered by default.

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,21 @@ public void undeployWebAppViaRest(
444444
}
445445
}
446446

447+
448+
/**
449+
* deploy webapp using t3 channel port for wlst.
450+
*
451+
* @param webappName webappName
452+
* @param appLocationInPod appLocation
453+
* @throws Exception exception
454+
*/
455+
public void undeployWebAppViaWlst(
456+
String webappName,
457+
String appLocationInPod)
458+
throws Exception {
459+
undeployWebAppViaWlst(webappName, appLocationInPod, false);
460+
}
461+
447462
/**
448463
* deploy webapp using t3 channel port for wlst.
449464
*
@@ -454,12 +469,12 @@ public void undeployWebAppViaRest(
454469
* @throws Exception exception
455470
*/
456471
public void deployWebAppViaWlst(
457-
String webappName,
458-
String webappLocation,
459-
String appLocationInPod,
460-
String username,
461-
String password)
462-
throws Exception {
472+
String webappName,
473+
String webappLocation,
474+
String appLocationInPod,
475+
String username,
476+
String password)
477+
throws Exception {
463478
deployWebAppViaWlst(webappName, webappLocation, appLocationInPod, username, password, false);
464479
}
465480

@@ -520,6 +535,52 @@ public void deployWebAppViaWlst(
520535
adminPod, domainNS, appLocationInPod, "callpyscript.sh", args);
521536
}
522537

538+
/**
539+
* undeploy webapp using adminPort or t3 channel port.
540+
*
541+
* @param webappName webappName
542+
* @param appLocationInPod appLocationInPod
543+
* @param useAdminPortToDeploy useAdminPortToDeploy
544+
* @throws Exception exception
545+
*/
546+
public void undeployWebAppViaWlst(
547+
String webappName,
548+
String appLocationInPod,
549+
boolean useAdminPortToDeploy)
550+
throws Exception {
551+
String adminPod = domainUid + "-" + adminServerName;
552+
553+
TestUtils.copyFileViaCat(
554+
projectRoot + "/integration-tests/src/test/resources/undeploywebapp.py",
555+
appLocationInPod + "/undeploywebapp.py",
556+
adminPod,
557+
domainNS);
558+
559+
TestUtils.copyFileViaCat(
560+
projectRoot + "/integration-tests/src/test/resources/callpyscript.sh",
561+
appLocationInPod + "/callpyscript.sh",
562+
adminPod,
563+
domainNS);
564+
565+
String t3Url = "t3://" + adminPod + ":";
566+
if (useAdminPortToDeploy) {
567+
t3Url = t3Url + domainMap.getOrDefault("adminPort", 7001);
568+
} else {
569+
t3Url = t3Url + t3ChannelPort;
570+
}
571+
572+
String[] args = {
573+
appLocationInPod + "/undeploywebapp.py",
574+
BaseTest.getUsername(),
575+
BaseTest.getPassword(),
576+
t3Url,
577+
webappName
578+
};
579+
580+
TestUtils.callShellScriptByExecToPod(
581+
adminPod, domainNS, appLocationInPod, "callpyscript.sh", args);
582+
}
583+
523584
/**
524585
* Creates a Connection Factory using JMS.
525586
*

integration-tests/src/test/java/oracle/kubernetes/operator/utils/TestUtils.java

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,60 +1304,24 @@ private static KeyStore createKeyStore(Operator operator) throws Exception {
13041304
return myKeyStore;
13051305
}
13061306

1307-
/**
1307+
1308+
/**
13081309
* @param cmd command to run in the loop
13091310
* @param matchStr expected string to match in the output
1310-
* @return ExecResult object containing command output info
13111311
* @throws Exception exception if fails to execute
13121312
*/
1313-
public static ExecResult checkAnyCmdInLoop(String cmd, String matchStr) throws Exception {
1314-
int i = 0;
1315-
ExecResult result = null;
1316-
while (i < BaseTest.getMaxIterationsPod()) {
1317-
result = ExecCommand.exec(cmd);
1318-
1319-
if (result.exitValue() != 0
1320-
|| (result.exitValue() == 0 && !result.stdout().contains(matchStr))) {
1321-
logger.info("Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());
1322-
// check for last iteration
1323-
if (i == (BaseTest.getMaxIterationsPod() - 1)) {
1324-
throw new RuntimeException(
1325-
"FAILURE: expected output "
1326-
+ matchStr
1327-
+ " from command "
1328-
+ cmd
1329-
+ " is not receieved, exiting!");
1330-
}
1331-
logger.info(
1332-
"did not receive the expected output "
1333-
+ matchStr
1334-
+ "from command "
1335-
+ cmd
1336-
+ " Ite ["
1337-
+ i
1338-
+ "/"
1339-
+ BaseTest.getMaxIterationsPod()
1340-
+ "], sleeping "
1341-
+ BaseTest.getWaitTimePod()
1342-
+ " seconds more");
1343-
1344-
Thread.sleep(BaseTest.getWaitTimePod() * 1000);
1345-
i++;
1346-
} else {
1347-
logger.info("Command " + cmd + " is successful");
1348-
break;
1349-
}
1350-
}
1351-
return result;
1313+
public static void checkAnyCmdInLoop(String cmd, String matchStr)
1314+
throws Exception {
1315+
checkCmdInLoop(cmd,matchStr, "");
13521316
}
13531317

13541318
public static void checkCmdInLoop(String cmd, String matchStr, String k8sObjName)
1355-
throws Exception {
1319+
throws Exception {
13561320
int i = 0;
13571321
while (i < BaseTest.getMaxIterationsPod()) {
13581322
ExecResult result = ExecCommand.exec(cmd);
13591323

1360-
// pod might not have been created or if created loop till condition
1324+
// loop command till condition
13611325
if (result.exitValue() != 0
13621326
|| (result.exitValue() == 0 && !result.stdout().contains(matchStr))) {
13631327
logger.info("Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash -x
2+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upload
4+
monitoringExporterDir=$1
5+
resourceExporterDir=$2
6+
monitoringExporterSrcDir=${monitoringExporterDir}/src
7+
monitoringExporterWar=${monitoringExporterDir}/apps/monitoringexporter/wls-exporter.war
8+
9+
10+
if [ -d "$monitoringExporterDir" ]; then
11+
rm -rf $monitoringExporterDir
12+
fi
13+
mkdir $monitoringExporterDir
14+
echo "Installing monitoring exporter files to ${monitoringExporterDir}..."
15+
cd ${monitoringExporterDir}
16+
git clone https://github.com/oracle/weblogic-monitoring-exporter.git $monitoringExporterSrcDir
17+
18+
echo "Building monitoring exporter files to ${monitoringExporterDir}..."
19+
cd ${monitoringExporterSrcDir}
20+
mvn clean install --log-file output.txt
21+
cd ${monitoringExporterSrcDir}/webapp
22+
mvn package -Dconfiguration=${resourceExporterDir}/rest_webapp.yml
23+
cd ${monitoringExporterSrcDir}/config_coordinator
24+
docker build -t config_coordinator .
25+
mkdir ${monitoringExporterDir}/apps
26+
mkdir ${monitoringExporterDir}/apps/monitoringexporter
27+
cp ${monitoringExporterSrcDir}/webapp/target/wls-exporter.war ${monitoringExporterWar}
28+
echo "Run the script [buildMonitoringExporter.sh] ..."
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash -x
2+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upload
4+
monitoringExporterDir=$1
5+
domainNS=$2
6+
samplesDir=${monitoringExporterDir}/src/samples/kubernetes/deployments
7+
8+
9+
kubectl delete -f ${samplesDir}/coordinator_${domainNS}.yaml
10+
kubectl delete -f ${samplesDir}/prometheus-deployment.yaml
11+
kubectl delete -f ${samplesDir}/grafana-deployment.yaml
12+
sleep 30
13+
14+
echo "Run the script [deletePromGrafana.sh] ..."
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash -x
2+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upload
4+
monitoringExporterDir=$1
5+
samplesDir=${monitoringExporterDir}/src/samples/kubernetes/deployments
6+
7+
kubectl delete -f ${samplesDir}/alertmanager-deployment.yaml
8+
kubectl delete -f ${monitoringExporterDir}/webhook/webhook-deployment.yaml
9+
kubectl delete -f ${monitoringExporterDir}/webhook/crossrbac_monitoring.yaml
10+
11+
12+
echo "Run the script [deleteWebHookAlertManager.sh] ..."
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upload
3+
monitoringExporterDir=$1
4+
domainNS=$2
5+
operatorNS=$3
6+
samplesDir=${monitoringExporterDir}/src/samples/kubernetes/deployments
7+
kubectl apply -f ${samplesDir}/monitoring-namespace.yaml
8+
kubectl apply -f ${samplesDir}/prometheus-deployment.yaml
9+
kubectl apply -f ${samplesDir}/alertmanager-deployment.yaml
10+
kubectl apply -f ${samplesDir}/crossnsrbac_${domainNS}_${operatorNS}.yaml
11+
kubectl apply -f ${samplesDir}/coordinator_${domainNS}.yaml
12+
kubectl apply -f ${samplesDir}/grafana-deployment.yaml
13+
14+
echo "Run the script [deployPromGrafana.sh] ..."
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
import time as systime
5+
connect(sys.argv[1],sys.argv[2],sys.argv[3])
6+
undeploy(sys.argv[4],timeout=60000)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upload
3+
FROM openjdk:11-oracle
4+
COPY webhook /bin/webhook
5+
RUN chmod +x /bin/webhook
6+
COPY hooks.json /etc/webhook/
7+
COPY scalingAction.sh /var/scripts/
8+
COPY scaleUpAction.sh /var/scripts/
9+
COPY scaleDnAction.sh /var/scripts/
10+
CMD ["-verbose", "-hooks=/etc/webhook/hooks.json", "-hotreload"]
11+
ENTRYPOINT ["/bin/webhook"]

0 commit comments

Comments
 (0)