Skip to content

Commit 5d85bc8

Browse files
committed
code refactoring to move common code to BaseTest.java
1 parent f1837a0 commit 5d85bc8

File tree

3 files changed

+65
-84
lines changed

3 files changed

+65
-84
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ public class BaseTest {
2727
public static final Logger logger = Logger.getLogger("OperatorIT", "OperatorIT");
2828
public static final String TESTWEBAPP = "testwebapp";
2929

30+
// property file used to customize operator properties for operator inputs yaml
31+
32+
public static final String OPERATOR1_YAML = "operator1.yaml";
33+
public static final String OPERATOR2_YAML = "operator2.yaml";
34+
public static final String OPERATORBC_YAML = "operator_bc.yaml";
35+
public static final String OPERATOR_CHAIN_YAML = "operator_chain.yaml";
36+
37+
// file used to customize domain properties for domain, PV and LB inputs yaml
38+
public static final String DOMAINONPV_WLST_YAML = "domainonpvwlst.yaml";
39+
public static final String DOMAINONPV_WDT_YAML = "domainonpvwdt.yaml";
40+
public static final String DOMAIN_ADMINONLY_YAML = "domainadminonly.yaml";
41+
public static final String DOMAIN_RECYCLEPOLICY_YAML = "domainrecyclepolicy.yaml";
42+
public static final String DOMAIN_SAMPLE_DEFAULTS_YAML = "domainsampledefaults.yaml";
43+
public static final String DOMAININIMAGE_WLST_YAML = "domaininimagewlst.yaml";
44+
public static final String DOMAININIMAGE_WDT_YAML = "domaininimagewdt.yaml";
45+
46+
// property file used to configure constants for integration tests
47+
public static final String APP_PROPS_FILE = "OperatorIT.properties";
48+
3049
private static String resultRoot = "";
3150
private static String pvRoot = "";
3251
private static String resultDir = "";
@@ -41,6 +60,28 @@ public class BaseTest {
4160
private static String appLocationInPod = "/u01/oracle/apps";
4261
private static Properties appProps;
4362

63+
public static boolean QUICKTEST;
64+
public static boolean SMOKETEST;
65+
public static boolean JENKINS;
66+
public static boolean INGRESSPERDOMAIN = true;
67+
68+
// Set QUICKTEST env var to true to run a small subset of tests.
69+
// Set SMOKETEST env var to true to run an even smaller subset of tests
70+
// set INGRESSPERDOMAIN to false to create LB's ingress by kubectl yaml file
71+
static {
72+
QUICKTEST =
73+
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true");
74+
SMOKETEST =
75+
System.getenv("SMOKETEST") != null && System.getenv("SMOKETEST").equalsIgnoreCase("true");
76+
if (SMOKETEST) QUICKTEST = true;
77+
if (System.getenv("JENKINS") != null) {
78+
JENKINS = new Boolean(System.getenv("JENKINS")).booleanValue();
79+
}
80+
if (System.getenv("INGRESSPERDOMAIN") != null) {
81+
INGRESSPERDOMAIN = new Boolean(System.getenv("INGRESSPERDOMAIN")).booleanValue();
82+
}
83+
}
84+
4485
public static void initialize(String appPropsFile) throws Exception {
4586

4687
// load app props defined

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

Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -27,48 +27,11 @@
2727
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
2828
public class ITOperator extends BaseTest {
2929

30-
// property file used to customize operator properties for operator inputs yaml
31-
32-
private static String operator1File = "operator1.yaml";
33-
private static String operator2File = "operator2.yaml";
34-
private static final String operator_bcFile = "operator_bc.yaml";
35-
private static final String operator_chainFile = "operator_chain.yaml";
36-
37-
// file used to customize domain properties for domain, PV and LB inputs yaml
38-
private static String domainonpvwlstFile = "domainonpvwlst.yaml";
39-
private static String domainonpvwdtFile = "domainonpvwdt.yaml";
40-
private static String domainadminonlyFile = "domainadminonly.yaml";
41-
private static String domainrecyclepolicyFile = "domainrecyclepolicy.yaml";
42-
private static String domainsampledefaultsFile = "domainsampledefaults.yaml";
43-
private static String domaininimagewlstFile = "domaininimagewlst.yaml";
44-
private static String domaininimagewdtFile = "domaininimagewdt.yaml";
45-
46-
// property file used to configure constants for integration tests
47-
private static String appPropsFile = "OperatorIT.properties";
48-
4930
private static Operator operator1, operator2;
5031

5132
private static Operator operatorForBackwardCompatibility;
5233
private static Operator operatorForRESTCertChain;
5334

54-
private static boolean QUICKTEST;
55-
private static boolean SMOKETEST;
56-
private static boolean JENKINS;
57-
58-
// Set QUICKTEST env var to true to run a small subset of tests.
59-
// Set SMOKETEST env var to true to run an even smaller subset
60-
// of tests, plus leave domain1 up and running when the test completes.
61-
static {
62-
QUICKTEST =
63-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true");
64-
SMOKETEST =
65-
System.getenv("SMOKETEST") != null && System.getenv("SMOKETEST").equalsIgnoreCase("true");
66-
if (SMOKETEST) QUICKTEST = true;
67-
if (System.getenv("JENKINS") != null) {
68-
JENKINS = new Boolean(System.getenv("JENKINS")).booleanValue();
69-
}
70-
}
71-
7235
/**
7336
* This method gets called only once before any of the test methods are executed. It does the
7437
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -79,7 +42,7 @@ public class ITOperator extends BaseTest {
7942
@BeforeClass
8043
public static void staticPrepare() throws Exception {
8144
// initialize test properties and create the directories
82-
initialize(appPropsFile);
45+
initialize(APP_PROPS_FILE);
8346
}
8447

8548
/**
@@ -136,12 +99,12 @@ public void testDomainOnPVUsingWLST() throws Exception {
13699
logger.info("Creating Operator & waiting for the script to complete execution");
137100
// create operator1
138101
if (operator1 == null) {
139-
operator1 = TestUtils.createOperator(operator1File);
102+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
140103
}
141104
Domain domain = null;
142105
boolean testCompletedSuccessfully = false;
143106
try {
144-
domain = TestUtils.createDomain(domainonpvwlstFile);
107+
domain = TestUtils.createDomain(DOMAINONPV_WLST_YAML);
145108
domain.verifyDomainCreated();
146109
testBasicUseCases(domain);
147110
testAdvancedUseCasesForADomain(operator1, domain);
@@ -175,13 +138,13 @@ public void testDomainOnPVUsingWDT() throws Exception {
175138
logger.info("Creating Domain using DomainOnPVUsingWDT & verifing the domain creation");
176139

177140
if (operator2 == null) {
178-
operator2 = TestUtils.createOperator(operator2File);
141+
operator2 = TestUtils.createOperator(OPERATOR2_YAML);
179142
}
180143
Domain domain = null;
181144
boolean testCompletedSuccessfully = false;
182145
try {
183146
// create domain
184-
domain = TestUtils.createDomain(domainonpvwdtFile);
147+
domain = TestUtils.createDomain(DOMAINONPV_WDT_YAML);
185148
domain.verifyDomainCreated();
186149
testBasicUseCases(domain);
187150
testWLDFScaling(operator2, domain);
@@ -220,14 +183,14 @@ public void testTwoDomainsManagedByTwoOperators() throws Exception {
220183

221184
logger.info("Checking if operator1 and domain1 are running, if not creating");
222185
if (operator1 == null) {
223-
operator1 = TestUtils.createOperator(operator1File);
186+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
224187
}
225188

226189
Domain domain1 = null, domain2 = null;
227190
boolean testCompletedSuccessfully = false;
228191
try {
229192
// load input yaml to map and add configOverrides
230-
Map<String, Object> wlstDomainMap = TestUtils.loadYaml(domainonpvwlstFile);
193+
Map<String, Object> wlstDomainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
231194
wlstDomainMap.put("domainUID", "domain1onpvwlst");
232195
wlstDomainMap.put("adminNodePort", new Integer("30702"));
233196
wlstDomainMap.put("t3ChannelPort", new Integer("30031"));
@@ -237,12 +200,12 @@ public void testTwoDomainsManagedByTwoOperators() throws Exception {
237200
testBasicUseCases(domain1);
238201
logger.info("Checking if operator2 is running, if not creating");
239202
if (operator2 == null) {
240-
operator2 = TestUtils.createOperator(operator2File);
203+
operator2 = TestUtils.createOperator(OPERATOR2_YAML);
241204
}
242205
// create domain2 with configured cluster
243206
// ToDo: configured cluster support is removed from samples, modify the test to create
244207
// configured cluster
245-
Map<String, Object> wdtDomainMap = TestUtils.loadYaml(domainonpvwdtFile);
208+
Map<String, Object> wdtDomainMap = TestUtils.loadYaml(DOMAINONPV_WDT_YAML);
246209
wdtDomainMap.put("domainUID", "domain2onpvwdt");
247210
wdtDomainMap.put("adminNodePort", new Integer("30703"));
248211
wdtDomainMap.put("t3ChannelPort", new Integer("30041"));
@@ -299,14 +262,14 @@ public void testCreateDomainWithStartPolicyAdminOnly() throws Exception {
299262
logTestBegin(testMethodName);
300263
logger.info("Checking if operator1 is running, if not creating");
301264
if (operator1 == null) {
302-
operator1 = TestUtils.createOperator(operator1File);
265+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
303266
}
304267
logger.info("Creating Domain domain6 & verifing the domain creation");
305268
// create domain
306269
Domain domain = null;
307270
boolean testCompletedSuccessfully = false;
308271
try {
309-
domain = TestUtils.createDomain(domainadminonlyFile);
272+
domain = TestUtils.createDomain(DOMAIN_ADMINONLY_YAML);
310273
domain.verifyDomainCreated();
311274
} finally {
312275
if (domain != null) {
@@ -332,14 +295,14 @@ public void testCreateDomainPVReclaimPolicyRecycle() throws Exception {
332295
logTestBegin(testMethodName);
333296
logger.info("Checking if operator1 is running, if not creating");
334297
if (operator1 == null) {
335-
operator1 = TestUtils.createOperator(operator1File);
298+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
336299
}
337300
logger.info("Creating Domain domain & verifing the domain creation");
338301
// create domain
339302
Domain domain = null;
340303

341304
try {
342-
domain = TestUtils.createDomain(domainrecyclepolicyFile);
305+
domain = TestUtils.createDomain(DOMAIN_RECYCLEPOLICY_YAML);
343306
domain.verifyDomainCreated();
344307
} finally {
345308
if (domain != null) domain.shutdown();
@@ -365,14 +328,14 @@ public void testCreateDomainWithDefaultValuesInSampleInputs() throws Exception {
365328
logTestBegin(testMethodName);
366329
logger.info("Creating Domain domain10 & verifing the domain creation");
367330
if (operator1 == null) {
368-
operator1 = TestUtils.createOperator(operator1File);
331+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
369332
}
370333

371334
// create domain10
372335
Domain domain = null;
373336
boolean testCompletedSuccessfully = false;
374337
try {
375-
domain = TestUtils.createDomain(domainsampledefaultsFile);
338+
domain = TestUtils.createDomain(DOMAIN_SAMPLE_DEFAULTS_YAML);
376339
domain.verifyDomainCreated();
377340
testBasicUseCases(domain);
378341
// testAdvancedUseCasesForADomain(operator1, domain10);
@@ -404,13 +367,13 @@ public void testAutoAndCustomSitConfigOverrides() throws Exception {
404367
logTestBegin(testMethod);
405368

406369
if (operator1 == null) {
407-
operator1 = TestUtils.createOperator(operator1File);
370+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
408371
}
409372
Domain domain11 = null;
410373
boolean testCompletedSuccessfully = false;
411374
try {
412375
// load input yaml to map and add configOverrides
413-
Map<String, Object> domainMap = TestUtils.loadYaml(domainonpvwlstFile);
376+
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
414377
domainMap.put("configOverrides", "sitconfigcm");
415378
domainMap.put(
416379
"configOverridesFile",
@@ -457,7 +420,7 @@ public void testOperatorRESTIdentityBackwardCompatibility() throws Exception {
457420
logger.info("Checking if operatorForBackwardCompatibility is running, if not creating");
458421
if (operatorForBackwardCompatibility == null) {
459422
operatorForBackwardCompatibility =
460-
TestUtils.createOperator(operator_bcFile, RESTCertType.LEGACY);
423+
TestUtils.createOperator(OPERATORBC_YAML, RESTCertType.LEGACY);
461424
}
462425
operatorForBackwardCompatibility.verifyOperatorExternalRESTEndpoint();
463426
logger.info("Operator using legacy REST identity created successfully");
@@ -478,7 +441,7 @@ public void testOperatorRESTUsingCertificateChain() throws Exception {
478441
logTestBegin("testOperatorRESTUsingCertificateChain");
479442
logger.info("Checking if operatorForBackwardCompatibility is running, if not creating");
480443
if (operatorForRESTCertChain == null) {
481-
operatorForRESTCertChain = TestUtils.createOperator(operator_chainFile, RESTCertType.CHAIN);
444+
operatorForRESTCertChain = TestUtils.createOperator(OPERATOR_CHAIN_YAML, RESTCertType.CHAIN);
482445
}
483446
operatorForRESTCertChain.verifyOperatorExternalRESTEndpoint();
484447
logger.info("Operator using legacy REST identity created successfully");
@@ -499,14 +462,14 @@ public void testDomainInImageUsingWLST() throws Exception {
499462

500463
logger.info("Checking if operator1 is running, if not creating");
501464
if (operator1 == null) {
502-
operator1 = TestUtils.createOperator(operator1File);
465+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
503466
}
504467
logger.info("Creating Domain & verifing the domain creation");
505468
// create domain
506469
Domain domain = null;
507470
boolean testCompletedSuccessfully = false;
508471
try {
509-
domain = TestUtils.createDomain(domaininimagewlstFile);
472+
domain = TestUtils.createDomain(DOMAININIMAGE_WLST_YAML);
510473
domain.verifyDomainCreated();
511474

512475
testBasicUseCases(domain);
@@ -531,14 +494,14 @@ public void testDomainInImageUsingWDT() throws Exception {
531494

532495
logger.info("Checking if operator1 is running, if not creating");
533496
if (operator1 == null) {
534-
operator1 = TestUtils.createOperator(operator1File);
497+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
535498
}
536499
logger.info("Creating Domain & verifing the domain creation");
537500
// create domain
538501
Domain domain = null;
539502
boolean testCompletedSuccessfully = false;
540503
try {
541-
domain = TestUtils.createDomain(domaininimagewdtFile);
504+
domain = TestUtils.createDomain(DOMAININIMAGE_WDT_YAML);
542505
domain.verifyDomainCreated();
543506

544507
testBasicUseCases(domain);

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

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,9 @@
2626
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
2727
public class ITUsabilityOperatorHelmChart extends BaseTest {
2828

29-
// property file used to configure constants for integration tests
30-
private static String appPropsFile = "OperatorIT.properties";
31-
private static boolean QUICKTEST;
32-
private static boolean SMOKETEST;
33-
private static boolean JENKINS;
34-
private static boolean INGRESSPERDOMAIN = true;
3529
private static int number = 3;
3630
String oprelease = "op" + number;
3731

38-
// Set QUICKTEST env var to true to run a small subset of tests.
39-
// Set SMOKETEST env var to true to run an even smaller subset of tests
40-
// set INGRESSPERDOMAIN to false to create LB's ingress by kubectl yaml file
41-
static {
42-
QUICKTEST =
43-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true");
44-
SMOKETEST =
45-
System.getenv("SMOKETEST") != null && System.getenv("SMOKETEST").equalsIgnoreCase("true");
46-
if (SMOKETEST) QUICKTEST = true;
47-
if (System.getenv("JENKINS") != null) {
48-
JENKINS = new Boolean(System.getenv("JENKINS")).booleanValue();
49-
}
50-
if (System.getenv("INGRESSPERDOMAIN") != null) {
51-
INGRESSPERDOMAIN = new Boolean(System.getenv("INGRESSPERDOMAIN")).booleanValue();
52-
}
53-
}
54-
5532
/**
5633
* This method gets called only once before any of the test methods are executed. It does the
5734
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -63,7 +40,7 @@ public class ITUsabilityOperatorHelmChart extends BaseTest {
6340
public static void staticPrepare() throws Exception {
6441
if (!QUICKTEST) {
6542
// initialize test properties and create the directories
66-
initialize(appPropsFile);
43+
initialize(APP_PROPS_FILE);
6744
}
6845
}
6946

0 commit comments

Comments
 (0)