Skip to content

Commit 8f3f336

Browse files
committed
add more cleanup
1 parent 9dc93a7 commit 8f3f336

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,13 @@ public void test19_EndToEndViaChart() throws Exception {
809809
domain.destroy();
810810
domain = null;
811811
}
812-
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
813812
gitCloneMonitoringExporter();
814-
setupPVMYSQL();
813+
try {
814+
setupPVMYSQL();
815+
} catch (Exception ex) {
816+
deletePvDir();
817+
throw new RuntimeException("FAILURE: failed to install database ");
818+
}
815819
createWLSImageAndDeploy();
816820
installPrometheusGrafanaViaChart();
817821
} finally {
@@ -928,10 +932,7 @@ private static void setupPVMYSQL() throws Exception {
928932
if (new File(pvDir).exists()) {
929933
logger.info(" PV dir already exists , cleaning ");
930934
if (!pvDir.isEmpty()) {
931-
StringBuffer removeDir = new StringBuffer();
932-
logger.info("Cleaning PV dir " + pvDir);
933-
934-
removeDir.append("rm -rf ").append(pvDir).append(" && ");
935+
deletePvDir();
935936
}
936937
} else {
937938
Files.createDirectories(Paths.get(pvDir));
@@ -943,8 +944,12 @@ private static void setupPVMYSQL() throws Exception {
943944
replaceStringInFile(
944945
monitoringExporterEndToEndDir + "/grafana/persistence.yaml", "%PV_ROOT%", pvDir);
945946
// deploy PV and PVC
946-
String crdCmd =
947-
" kubectl apply -f " + monitoringExporterEndToEndDir + "/mysql/persistence.yaml";
947+
// clean mysql processes
948+
String crdCmd = "sudo pkill mysql";
949+
ExecCommand.exec("crdCmd");
950+
crdCmd = "sudo pkill mysqlp";
951+
ExecCommand.exec("crdCmd");
952+
crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/mysql/persistence.yaml";
948953
TestUtils.exec(crdCmd);
949954
crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/mysql/mysql.yaml";
950955
TestUtils.exec(crdCmd);
@@ -1010,6 +1015,7 @@ private static void setupPVMYSQL() throws Exception {
10101015
+ result.stdout());
10111016
}
10121017
}
1018+
10131019
/**
10141020
* Install wls image tool and update wls pods
10151021
*
@@ -1040,12 +1046,7 @@ private static void createWLSImageAndDeploy() throws Exception {
10401046
TestUtils.checkPodReady("domain1-admin-server", "default");
10411047
TestUtils.checkPodReady("domain1-managed-server-1", "default");
10421048
TestUtils.checkPodReady("domain1-managed-server-2", "default");
1043-
/*
1044-
domain.verifyDomainServerPodRestart(
1045-
"\"" + getWeblogicImageName() + ":" + getWeblogicImageTag() + "\""
1046-
"\"" + newImage + "\"");
10471049

1048-
*/
10491050
// apply curl to the pod
10501051
crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/util/curl.yaml";
10511052
TestUtils.exec(crdCmd);
@@ -1160,13 +1161,29 @@ private static void uninstallMySQL() throws Exception {
11601161

11611162
crdCmd = " kubectl delete -f " + monitoringExporterEndToEndDir + "mysql/persistence.yaml";
11621163
ExecCommand.exec(crdCmd);
1163-
crdCmd =
1164+
deletePvDir();
1165+
}
1166+
1167+
/**
1168+
* Delete PvDir via docker
1169+
*
1170+
* @throws Exception if could not run the command successfully to clone from github
1171+
*/
1172+
private static void deletePvDir() throws Exception {
1173+
String monitoringExporterEndToEndDir =
1174+
monitoringExporterDir + "/src/samples/kubernetes/end2end/";
1175+
String pvDir = monitoringExporterEndToEndDir + "pvDir";
1176+
String crdCmd =
11641177
"cd "
11651178
+ monitoringExporterEndToEndDir
11661179
+ " && docker run --rm -v "
11671180
+ monitoringExporterEndToEndDir
11681181
+ "pvDir:/tt -v $PWD/util:/util nginx /util/clean-pv.sh";
11691182
ExecCommand.exec(crdCmd);
1183+
StringBuffer removeDir = new StringBuffer();
1184+
logger.info("Cleaning PV dir " + pvDir);
1185+
1186+
removeDir.append("rm -rf ").append(pvDir).append(" && ");
11701187
}
11711188

11721189
/**

0 commit comments

Comments
 (0)