Skip to content

Commit 7cb717d

Browse files
put removing the testing/temp image logic into finally block
1 parent b468845 commit 7cb717d

File tree

2 files changed

+22
-53
lines changed

2 files changed

+22
-53
lines changed

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

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,9 @@
2424
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
2525
public class ITPodsRestart extends BaseTest {
2626

27-
// property file used to customize operator properties for operator inputs yaml
28-
private static String operator1File = "operator1.yaml";
29-
30-
// file used to customize domain properties for domain, PV and LB inputs yaml
3127
private static Domain domain = null;
32-
private static String domainonpvwlstFile = "domainonpvwlst.yaml";
33-
34-
// property file used to configure constants for integration tests
35-
private static String appPropsFile = "OperatorIT.properties";
36-
3728
private static Operator operator1;
3829

39-
private static boolean QUICKTEST;
40-
private static boolean SMOKETEST;
41-
private static boolean JENKINS;
42-
private static boolean INGRESSPERDOMAIN = true;
43-
44-
// Set QUICKTEST env var to true to run a small subset of tests.
45-
// Set SMOKETEST env var to true to run an even smaller subset
46-
// of tests, plus leave domain1 up and running when the test completes.
47-
// set INGRESSPERDOMAIN to false to create LB's ingress by kubectl yaml file
48-
static {
49-
QUICKTEST =
50-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true");
51-
SMOKETEST =
52-
System.getenv("SMOKETEST") != null && System.getenv("SMOKETEST").equalsIgnoreCase("true");
53-
if (SMOKETEST) QUICKTEST = true;
54-
if (System.getenv("JENKINS") != null) {
55-
JENKINS = new Boolean(System.getenv("JENKINS")).booleanValue();
56-
}
57-
if (System.getenv("INGRESSPERDOMAIN") != null) {
58-
INGRESSPERDOMAIN = new Boolean(System.getenv("INGRESSPERDOMAIN")).booleanValue();
59-
}
60-
}
61-
6230
/**
6331
* This method gets called only once before any of the test methods are executed. It does the
6432
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -71,11 +39,11 @@ public class ITPodsRestart extends BaseTest {
7139
public static void staticPrepare() throws Exception {
7240
// initialize test properties and create the directories
7341
if (!QUICKTEST) {
74-
initialize(appPropsFile);
42+
initialize(APP_PROPS_FILE);
7543

7644
logger.info("Checking if operator1 and domain are running, if not creating");
7745
if (operator1 == null) {
78-
operator1 = TestUtils.createOperator(operator1File);
46+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
7947
}
8048

8149
domain = createPodsRestartdomain();
@@ -95,13 +63,8 @@ public static void staticUnPrepare() throws Exception {
9563
logger.info("BEGIN");
9664
logger.info("Run once, release cluster lease");
9765

98-
// destroyPodsRestartdomain();
99-
// tearDown();
100-
101-
if (!"".equals(getLeaseId())) {
102-
logger.info("Release the k8s cluster lease");
103-
TestUtils.releaseLease(getProjectRoot(), getLeaseId());
104-
}
66+
destroyPodsRestartdomain();
67+
tearDown();
10568

10669
logger.info("SUCCESS");
10770
}
@@ -211,22 +174,24 @@ public void testServerRestartByChangingImage() throws Exception {
211174
logTestBegin(testMethodName);
212175

213176
boolean testCompletedSuccessfully = false;
214-
215-
logger.info(
216-
"About to testDomainServerRestart for Domain: "
217-
+ domain.getDomainUid()
218-
+ " Image property: store/oracle/weblogic:12.2.1.3 to store/oracle/weblogic:duplicate");
219-
TestUtils.dockerTagImage("store/oracle/weblogic:12.2.1.3", "store/oracle/weblogic:duplicate");
220-
domain.testDomainServerRestart(
221-
"\"store/oracle/weblogic:12.2.1.3\"", "\"store/oracle/weblogic:duplicate\"");
222-
TestUtils.dockerRemoveImage("store/oracle/weblogic:duplicate");
177+
try {
178+
logger.info(
179+
"About to testDomainServerRestart for Domain: "
180+
+ domain.getDomainUid()
181+
+ " Image property: store/oracle/weblogic:12.2.1.3 to store/oracle/weblogic:duplicate");
182+
TestUtils.dockerTagImage("store/oracle/weblogic:12.2.1.3", "store/oracle/weblogic:duplicate");
183+
domain.testDomainServerRestart(
184+
"\"store/oracle/weblogic:12.2.1.3\"", "\"store/oracle/weblogic:duplicate\"");
185+
} finally {
186+
TestUtils.dockerRemoveImage("store/oracle/weblogic:duplicate");
187+
}
223188

224189
logger.info("SUCCESS - " + testMethodName);
225190
}
226191

227192
private static Domain createPodsRestartdomain() throws Exception {
228193

229-
Map<String, Object> domainMap = TestUtils.loadYaml(domainonpvwlstFile);
194+
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
230195
domainMap.put("domainUID", "domainpodsrestart");
231196
domainMap.put("adminNodePort", new Integer("30707"));
232197
domainMap.put("t3ChannelPort", new Integer("30081"));

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
package oracle.kubernetes.operator.utils;
66

7-
import java.io.*;
7+
import java.io.BufferedReader;
8+
import java.io.File;
9+
import java.io.FileInputStream;
10+
import java.io.FileReader;
11+
import java.io.FileWriter;
12+
import java.io.InputStream;
813
import java.nio.file.Files;
914
import java.nio.file.Paths;
1015
import java.nio.file.StandardCopyOption;
@@ -1067,7 +1072,6 @@ public static void createNewYamlFile(
10671072
throws Exception {
10681073
logger.info("Creating new " + generatedYamlFile);
10691074

1070-
// copy input template file and modify it
10711075
Files.copy(
10721076
new File(inputYamlFile).toPath(),
10731077
Paths.get(generatedYamlFile),

0 commit comments

Comments
 (0)