Skip to content

Commit 74ddf87

Browse files
committed
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernetes-operator into owls75969
2 parents 5a1099e + 9c103fd commit 74ddf87

16 files changed

+1829
-1309
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
@@ -441,6 +441,21 @@ 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+
444459
/**
445460
* deploy webapp using t3 channel port for wlst.
446461
*
@@ -451,12 +466,12 @@ public void undeployWebAppViaRest(
451466
* @throws Exception exception
452467
*/
453468
public void deployWebAppViaWlst(
454-
String webappName,
455-
String webappLocation,
456-
String appLocationInPod,
457-
String username,
458-
String password)
459-
throws Exception {
469+
String webappName,
470+
String webappLocation,
471+
String appLocationInPod,
472+
String username,
473+
String password)
474+
throws Exception {
460475
deployWebAppViaWlst(webappName, webappLocation, appLocationInPod, username, password, false);
461476
}
462477

@@ -517,6 +532,52 @@ public void deployWebAppViaWlst(
517532
adminPod, domainNS, appLocationInPod, "callpyscript.sh", args);
518533
}
519534

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

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

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,83 +1242,53 @@ private static KeyStore createKeyStore(Operator operator) throws Exception {
12421242
return myKeyStore;
12431243
}
12441244

1245-
/**
1245+
1246+
/**
12461247
* @param cmd command to run in the loop
12471248
* @param matchStr expected string to match in the output
1248-
* @return ExecResult object containing command output info
12491249
* @throws Exception exception if fails to execute
12501250
*/
1251-
public static ExecResult checkAnyCmdInLoop(String cmd, String matchStr) throws Exception {
1252-
int i = 0;
1253-
ExecResult result = null;
1254-
while (i < BaseTest.getMaxIterationsPod()) {
1255-
result = ExecCommand.exec(cmd);
1256-
1257-
if (result.exitValue() != 0
1258-
|| (result.exitValue() == 0 && !result.stdout().contains(matchStr))) {
1259-
logger.info("Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());
1260-
// check for last iteration
1261-
if (i == (BaseTest.getMaxIterationsPod() - 1)) {
1262-
throw new RuntimeException(
1263-
"FAILURE: expected output "
1264-
+ matchStr
1265-
+ " from command "
1266-
+ cmd
1267-
+ " is not receieved, exiting!");
1268-
}
1269-
logger.info(
1270-
"did not receive the expected output "
1271-
+ matchStr
1272-
+ "from command "
1273-
+ cmd
1274-
+ " Ite ["
1275-
+ i
1276-
+ "/"
1277-
+ BaseTest.getMaxIterationsPod()
1278-
+ "], sleeping "
1279-
+ BaseTest.getWaitTimePod()
1280-
+ " seconds more");
1281-
1282-
Thread.sleep(BaseTest.getWaitTimePod() * 1000);
1283-
i++;
1284-
} else {
1285-
logger.info("Command " + cmd + " is successful");
1286-
break;
1287-
}
1288-
}
1289-
return result;
1251+
public static void checkAnyCmdInLoop(String cmd, String matchStr)
1252+
throws Exception {
1253+
checkCmdInLoop(cmd,matchStr, "");
12901254
}
12911255

12921256
public static void checkCmdInLoop(String cmd, String matchStr, String k8sObjName)
1293-
throws Exception {
1257+
throws Exception {
12941258
int i = 0;
12951259
while (i < BaseTest.getMaxIterationsPod()) {
12961260
ExecResult result = ExecCommand.exec(cmd);
12971261

1298-
// pod might not have been created or if created loop till condition
1262+
// loop command till condition
12991263
if (result.exitValue() != 0
13001264
|| (result.exitValue() == 0 && !result.stdout().contains(matchStr))) {
13011265
logger.info("Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());
13021266
// check for last iteration
13031267
if (i == (BaseTest.getMaxIterationsPod() - 1)) {
13041268
throw new RuntimeException(
1305-
"FAILURE: pod " + k8sObjName + " is not running/ready, exiting!");
1269+
"FAILURE: command " + cmd + " failed to execute or does not match the expected output " + matchStr + " , exiting!");
13061270
}
13071271
logger.info(
1308-
"Pod "
1309-
+ k8sObjName
1310-
+ " is not Running/Ready Ite ["
1311-
+ i
1312-
+ "/"
1313-
+ BaseTest.getMaxIterationsPod()
1314-
+ "], sleeping "
1315-
+ BaseTest.getWaitTimePod()
1316-
+ " seconds more");
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+
13171284

13181285
Thread.sleep(BaseTest.getWaitTimePod() * 1000);
13191286
i++;
13201287
} else {
1321-
logger.info("Pod " + k8sObjName + " is Running");
1288+
logger.info("Found expected output ");
1289+
if(!k8sObjName.equals("")) {
1290+
logger.info("Pod " + k8sObjName + " is Running");
1291+
}
13221292
break;
13231293
}
13241294
}
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)