Skip to content

Commit d4ff61a

Browse files
remove docker tag/remove methods instead direcly use TestUtils.exec(cmd)
1 parent 90a1f8b commit d4ff61a

File tree

2 files changed

+25
-39
lines changed

2 files changed

+25
-39
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public void testServerPodsRestartByChangingEnvProperty() throws Exception {
8383
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
8484
logTestBegin(testMethodName);
8585

86-
boolean testCompletedSuccessfully = false;
8786
logger.info(
8887
"About to testDomainServerPodRestart for Domain: "
8988
+ domain.getDomainUid()
@@ -107,8 +106,6 @@ public void testServerPodsRestartByChangingLogHomeEnabled() throws Exception {
107106
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
108107
logTestBegin(testMethodName);
109108

110-
boolean testCompletedSuccessfully = false;
111-
112109
logger.info(
113110
"About to testDomainServerPodRestart for Domain: "
114111
+ domain.getDomainUid()
@@ -131,8 +128,6 @@ public void testServerPodsRestartByChangingImagePullPolicy() throws Exception {
131128
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
132129
logTestBegin(testMethodName);
133130

134-
boolean testCompletedSuccessfully = false;
135-
136131
logger.info(
137132
"About to testDomainServerPodRestart for Domain: "
138133
+ domain.getDomainUid()
@@ -156,8 +151,6 @@ public void testServerPodsRestartByChangingIncludeServerOutInPodLog() throws Exc
156151
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
157152
logTestBegin(testMethodName);
158153

159-
boolean testCompletedSuccessfully = false;
160-
161154
logger.info(
162155
"About to testDomainServerPodRestart for Domain: "
163156
+ domain.getDomainUid()
@@ -176,22 +169,22 @@ public void testServerPodsRestartByChangingIncludeServerOutInPodLog() throws Exc
176169
* @throws Exception
177170
*/
178171
@Test
179-
public void testServerPodsRestartByChangingImage() throws Exception {
172+
public void testServerPodsRestartByChangingZImage() throws Exception {
180173
Assume.assumeFalse(QUICKTEST);
181174
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
182175
logTestBegin(testMethodName);
183176

184-
boolean testCompletedSuccessfully = false;
185177
try {
186178
logger.info(
187179
"About to testDomainServerPodRestart for Domain: "
188180
+ domain.getDomainUid()
189181
+ " Image property: store/oracle/weblogic:12.2.1.3 to store/oracle/weblogic:duplicate");
190-
TestUtils.dockerTagImage("store/oracle/weblogic:12.2.1.3", "store/oracle/weblogic:duplicate");
182+
183+
TestUtils.exec("docker tag store/oracle/weblogic:12.2.1.3 store/oracle/weblogic:duplicate");
191184
domain.testDomainServerPodRestart(
192185
"\"store/oracle/weblogic:12.2.1.3\"", "\"store/oracle/weblogic:duplicate\"");
193186
} finally {
194-
TestUtils.dockerRemoveImage("store/oracle/weblogic:duplicate");
187+
TestUtils.exec("docker rmi -f store/oracle/weblogic:duplicate");
195188
}
196189

197190
logger.info("SUCCESS - " + testMethodName);

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

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ public static void checkPodCreated(String podName, String domainNS) throws Excep
6060
checkCmdInLoop(cmd.toString(), "Running", podName);
6161
}
6262

63-
/** @param cmd - kubectl get pod <podname> -n namespace */
63+
/**
64+
* check pod is in Terminating state
65+
*
66+
* @param cmd - kubectl get pod <podname> -n namespace
67+
* @throws Exception
68+
*/
6469
public static void checkPodTerminating(String podName, String domainNS) throws Exception {
6570

6671
StringBuffer cmd = new StringBuffer();
@@ -1067,7 +1072,15 @@ private static void checkCmdInLoopForDelete(String cmd, String matchStr, String
10671072
}
10681073
}
10691074

1070-
// create yaml file with changed property
1075+
/**
1076+
* create yaml file with changed property
1077+
*
1078+
* @param inputYamlFile
1079+
* @param generatedYamlFile
1080+
* @param oldString
1081+
* @paramnewString
1082+
* @throws Exception
1083+
*/
10711084
public static void createNewYamlFile(
10721085
String inputYamlFile, String generatedYamlFile, String oldString, String newString)
10731086
throws Exception {
@@ -1101,35 +1114,15 @@ public static void createNewYamlFile(
11011114
logger.info("Done - generate the new yaml file ");
11021115
}
11031116

1104-
public static void copyFile(String fromFile, String toFile) throws Exception {
1105-
logger.info("Copying file from " + fromFile + " to " + toFile);
1106-
1107-
Files.copy(new File(fromFile).toPath(), Paths.get(toFile), StandardCopyOption.REPLACE_EXISTING);
1108-
}
1109-
/**
1110-
* tag image with docker cmd: docker tage sourceImageName targetImageName
1111-
*
1112-
* @param sourceImage
1113-
* @param targetImage
1114-
* @throws Exception
1115-
*/
1116-
public static void dockerTagImage(String sourceImage, String targetImage) throws Exception {
1117-
logger.info("Tagging souceImage: " + sourceImage + " to " + targetImage);
1118-
String dockerCmd = "docker tag " + sourceImage + " " + targetImage;
1119-
logger.info("Executing cmd " + dockerCmd);
1120-
exec(dockerCmd);
1121-
}
1122-
11231117
/**
1124-
* remove image with docker cmd: docker rmi -f imageName
1118+
* copy file from source to target
11251119
*
1126-
* @param imageName
1120+
* @param fromFile
1121+
* @param toFile
11271122
* @throws Exception
11281123
*/
1129-
public static void dockerRemoveImage(String imageName) throws Exception {
1130-
logger.info("Removing image: " + imageName);
1131-
String dockerCmd = "docker rmi -f " + imageName;
1132-
logger.info("Executing cmd " + dockerCmd);
1133-
exec(dockerCmd);
1124+
public static void copyFile(String fromFile, String toFile) throws Exception {
1125+
logger.info("Copying file from " + fromFile + " to " + toFile);
1126+
Files.copy(new File(fromFile).toPath(), Paths.get(toFile), StandardCopyOption.REPLACE_EXISTING);
11341127
}
11351128
}

0 commit comments

Comments
 (0)