Skip to content

Commit f8df06a

Browse files
committed
Merge remote-tracking branch 'origin/develop' into affinity
2 parents c77121c + 9c103fd commit f8df06a

16 files changed

+848
-274
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: 461 additions & 214 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
@@ -441,6 +441,67 @@ public void undeployWebAppViaRest(
441441
}
442442
}
443443

444+
445+
/**
446+
* deploy webapp using t3 channel port for wlst.
447+
*
448+
* @param webappName webappName
449+
* @param appLocationInPod appLocation
450+
* @throws Exception exception
451+
*/
452+
public void undeployWebAppViaWlst(
453+
String webappName,
454+
String appLocationInPod)
455+
throws Exception {
456+
undeployWebAppViaWlst(webappName, appLocationInPod, false);
457+
}
458+
459+
/**
460+
* undeploy webapp using adminPort or t3 channel port.
461+
*
462+
* @param webappName webappName
463+
* @param appLocationInPod appLocationInPod
464+
* @param useAdminPortToDeploy useAdminPortToDeploy
465+
* @throws Exception exception
466+
*/
467+
public void undeployWebAppViaWlst(
468+
String webappName,
469+
String appLocationInPod,
470+
boolean useAdminPortToDeploy)
471+
throws Exception {
472+
String adminPod = domainUid + "-" + adminServerName;
473+
474+
TestUtils.copyFileViaCat(
475+
projectRoot + "/integration-tests/src/test/resources/undeploywebapp.py",
476+
appLocationInPod + "/undeploywebapp.py",
477+
adminPod,
478+
domainNS);
479+
480+
TestUtils.copyFileViaCat(
481+
projectRoot + "/integration-tests/src/test/resources/callpyscript.sh",
482+
appLocationInPod + "/callpyscript.sh",
483+
adminPod,
484+
domainNS);
485+
486+
String t3Url = "t3://" + adminPod + ":";
487+
if (useAdminPortToDeploy) {
488+
t3Url = t3Url + domainMap.getOrDefault("adminPort", 7001);
489+
} else {
490+
t3Url = t3Url + t3ChannelPort;
491+
}
492+
493+
String[] args = {
494+
appLocationInPod + "/undeploywebapp.py",
495+
BaseTest.getUsername(),
496+
BaseTest.getPassword(),
497+
t3Url,
498+
webappName
499+
};
500+
501+
TestUtils.callShellScriptByExecToPod(
502+
adminPod, domainNS, appLocationInPod, "callpyscript.sh", args);
503+
}
504+
444505
/**
445506
* deploy webapp using t3 channel port for wlst.
446507
*
@@ -451,12 +512,12 @@ public void undeployWebAppViaRest(
451512
* @throws Exception exception
452513
*/
453514
public void deployWebAppViaWlst(
454-
String webappName,
455-
String webappLocation,
456-
String appLocationInPod,
457-
String username,
458-
String password)
459-
throws Exception {
515+
String webappName,
516+
String webappLocation,
517+
String appLocationInPod,
518+
String username,
519+
String password)
520+
throws Exception {
460521
deployWebAppViaWlst(webappName, webappLocation, appLocationInPod, username, password, false);
461522
}
462523

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

Lines changed: 23 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,80 +1247,50 @@ private static KeyStore createKeyStore(Operator operator) throws Exception {
12471247
* Checks command in a loop.
12481248
* @param cmd command to run in the loop
12491249
* @param matchStr expected string to match in the output
1250-
* @return ExecResult object containing command output info
12511250
* @throws Exception exception if fails to execute
12521251
*/
1253-
public static ExecResult checkAnyCmdInLoop(String cmd, String matchStr) throws Exception {
1254-
int i = 0;
1255-
ExecResult result = null;
1256-
while (i < BaseTest.getMaxIterationsPod()) {
1257-
result = ExecCommand.exec(cmd);
1258-
1259-
if (result.exitValue() != 0
1260-
|| (result.exitValue() == 0 && !result.stdout().contains(matchStr))) {
1261-
logger.info("Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());
1262-
// check for last iteration
1263-
if (i == (BaseTest.getMaxIterationsPod() - 1)) {
1264-
throw new RuntimeException(
1265-
"FAILURE: expected output "
1266-
+ matchStr
1267-
+ " from command "
1268-
+ cmd
1269-
+ " is not receieved, exiting!");
1270-
}
1271-
logger.info(
1272-
"did not receive the expected output "
1273-
+ matchStr
1274-
+ "from command "
1275-
+ cmd
1276-
+ " Ite ["
1277-
+ i
1278-
+ "/"
1279-
+ BaseTest.getMaxIterationsPod()
1280-
+ "], sleeping "
1281-
+ BaseTest.getWaitTimePod()
1282-
+ " seconds more");
1283-
1284-
Thread.sleep(BaseTest.getWaitTimePod() * 1000);
1285-
i++;
1286-
} else {
1287-
logger.info("Command " + cmd + " is successful");
1288-
break;
1289-
}
1290-
}
1291-
return result;
1252+
public static void checkAnyCmdInLoop(String cmd, String matchStr)
1253+
throws Exception {
1254+
checkCmdInLoop(cmd,matchStr, "");
12921255
}
12931256

12941257
public static void checkCmdInLoop(String cmd, String matchStr, String k8sObjName)
1295-
throws Exception {
1258+
throws Exception {
12961259
int i = 0;
12971260
while (i < BaseTest.getMaxIterationsPod()) {
12981261
ExecResult result = ExecCommand.exec(cmd);
12991262

1300-
// pod might not have been created or if created loop till condition
1263+
// loop command till condition
13011264
if (result.exitValue() != 0
13021265
|| (result.exitValue() == 0 && !result.stdout().contains(matchStr))) {
13031266
logger.info("Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());
13041267
// check for last iteration
13051268
if (i == (BaseTest.getMaxIterationsPod() - 1)) {
13061269
throw new RuntimeException(
1307-
"FAILURE: pod " + k8sObjName + " is not running/ready, exiting!");
1270+
"FAILURE: command " + cmd + " failed to execute or does not match the expected output "
1271+
+ matchStr + " , exiting!");
13081272
}
13091273
logger.info(
1310-
"Pod "
1311-
+ k8sObjName
1312-
+ " is not Running/Ready Ite ["
1313-
+ i
1314-
+ "/"
1315-
+ BaseTest.getMaxIterationsPod()
1316-
+ "], sleeping "
1317-
+ BaseTest.getWaitTimePod()
1318-
+ " seconds more");
1274+
"did not receive the expected output "
1275+
+ matchStr
1276+
+ " from command "
1277+
+ cmd
1278+
+ " Ite ["
1279+
+ i
1280+
+ "/"
1281+
+ BaseTest.getMaxIterationsPod()
1282+
+ "], sleeping "
1283+
+ BaseTest.getWaitTimePod()
1284+
+ " seconds more");
1285+
13191286

13201287
Thread.sleep(BaseTest.getWaitTimePod() * 1000);
13211288
i++;
13221289
} else {
1323-
logger.info("Pod " + k8sObjName + " is Running");
1290+
logger.info("Found expected output ");
1291+
if (!k8sObjName.equals("")) {
1292+
logger.info("Pod " + k8sObjName + " is Running");
1293+
}
13241294
break;
13251295
}
13261296
}
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)