9
9
import java .util .Map ;
10
10
import java .util .Properties ;
11
11
import java .util .logging .FileHandler ;
12
+ import java .util .logging .Level ;
12
13
import java .util .logging .Logger ;
13
14
import java .util .logging .SimpleFormatter ;
14
15
import javax .jms .Connection ;
@@ -27,6 +28,25 @@ public class BaseTest {
27
28
public static final Logger logger = Logger .getLogger ("OperatorIT" , "OperatorIT" );
28
29
public static final String TESTWEBAPP = "testwebapp" ;
29
30
31
+ // property file used to customize operator properties for operator inputs yaml
32
+
33
+ public static final String OPERATOR1_YAML = "operator1.yaml" ;
34
+ public static final String OPERATOR2_YAML = "operator2.yaml" ;
35
+ public static final String OPERATORBC_YAML = "operator_bc.yaml" ;
36
+ public static final String OPERATOR_CHAIN_YAML = "operator_chain.yaml" ;
37
+
38
+ // file used to customize domain properties for domain, PV and LB inputs yaml
39
+ public static final String DOMAINONPV_WLST_YAML = "domainonpvwlst.yaml" ;
40
+ public static final String DOMAINONPV_WDT_YAML = "domainonpvwdt.yaml" ;
41
+ public static final String DOMAIN_ADMINONLY_YAML = "domainadminonly.yaml" ;
42
+ public static final String DOMAIN_RECYCLEPOLICY_YAML = "domainrecyclepolicy.yaml" ;
43
+ public static final String DOMAIN_SAMPLE_DEFAULTS_YAML = "domainsampledefaults.yaml" ;
44
+ public static final String DOMAININIMAGE_WLST_YAML = "domaininimagewlst.yaml" ;
45
+ public static final String DOMAININIMAGE_WDT_YAML = "domaininimagewdt.yaml" ;
46
+
47
+ // property file used to configure constants for integration tests
48
+ public static final String APP_PROPS_FILE = "OperatorIT.properties" ;
49
+
30
50
private static String resultRoot = "" ;
31
51
private static String pvRoot = "" ;
32
52
private static String resultDir = "" ;
@@ -41,6 +61,28 @@ public class BaseTest {
41
61
private static String appLocationInPod = "/u01/oracle/apps" ;
42
62
private static Properties appProps ;
43
63
64
+ public static boolean QUICKTEST ;
65
+ public static boolean SMOKETEST ;
66
+ public static boolean JENKINS ;
67
+ public static boolean INGRESSPERDOMAIN = true ;
68
+
69
+ // Set QUICKTEST env var to true to run a small subset of tests.
70
+ // Set SMOKETEST env var to true to run an even smaller subset of tests
71
+ // set INGRESSPERDOMAIN to false to create LB's ingress by kubectl yaml file
72
+ static {
73
+ QUICKTEST =
74
+ System .getenv ("QUICKTEST" ) != null && System .getenv ("QUICKTEST" ).equalsIgnoreCase ("true" );
75
+ SMOKETEST =
76
+ System .getenv ("SMOKETEST" ) != null && System .getenv ("SMOKETEST" ).equalsIgnoreCase ("true" );
77
+ if (SMOKETEST ) QUICKTEST = true ;
78
+ if (System .getenv ("JENKINS" ) != null ) {
79
+ JENKINS = new Boolean (System .getenv ("JENKINS" )).booleanValue ();
80
+ }
81
+ if (System .getenv ("INGRESSPERDOMAIN" ) != null ) {
82
+ INGRESSPERDOMAIN = new Boolean (System .getenv ("INGRESSPERDOMAIN" )).booleanValue ();
83
+ }
84
+ }
85
+
44
86
public static void initialize (String appPropsFile ) throws Exception {
45
87
46
88
// load app props defined
@@ -95,6 +137,28 @@ public static void initialize(String appPropsFile) throws Exception {
95
137
+ "\n "
96
138
+ clnResult .stderr ());
97
139
}
140
+
141
+ if (System .getenv ("JENKINS" ) != null ) {
142
+ logger .info ("Creating " + resultRoot + "/acceptance_test_tmp" );
143
+ TestUtils .exec (
144
+ "/usr/local/packages/aime/ias/run_as_root \" mkdir -p "
145
+ + resultRoot
146
+ + "/acceptance_test_tmp\" " );
147
+ TestUtils .exec (
148
+ "/usr/local/packages/aime/ias/run_as_root \" chmod 777 "
149
+ + resultRoot
150
+ + "/acceptance_test_tmp\" " );
151
+ logger .info ("Creating " + pvRoot + "/acceptance_test_pv" );
152
+ TestUtils .exec (
153
+ "/usr/local/packages/aime/ias/run_as_root \" mkdir -p "
154
+ + pvRoot
155
+ + "/acceptance_test_pv\" " );
156
+ TestUtils .exec (
157
+ "/usr/local/packages/aime/ias/run_as_root \" chmod 777 "
158
+ + pvRoot
159
+ + "/acceptance_test_pv\" " );
160
+ }
161
+
98
162
// create resultRoot, PVRoot, etc
99
163
Files .createDirectories (Paths .get (resultRoot ));
100
164
Files .createDirectories (Paths .get (resultDir ));
@@ -520,4 +584,43 @@ private void callWebAppAndVerifyScaling(Domain domain, int replicas) throws Exce
520
584
TestUtils .checkServiceCreated (podName , domainNS );
521
585
}
522
586
}
587
+
588
+ public static void tearDown () throws Exception {
589
+ logger .log (
590
+ Level .INFO ,
591
+ "TEARDOWN: Starting Test Run TearDown (cleanup and state-dump)."
592
+ + " Note that if the test failed previous to tearDown, "
593
+ + " the error that caused the test failure may be reported "
594
+ + "after the tearDown completes. Note that tearDown itself may report errors,"
595
+ + " but this won't affect the outcome of the test results." );
596
+ StringBuffer cmd =
597
+ new StringBuffer ("export RESULT_ROOT=$RESULT_ROOT && export PV_ROOT=$PV_ROOT && " );
598
+ cmd .append (BaseTest .getProjectRoot ())
599
+ .append ("/integration-tests/src/test/resources/statedump.sh" );
600
+ logger .info ("Running " + cmd );
601
+
602
+ // renew lease before callin statedump.sh
603
+ TestUtils .renewK8sClusterLease (getProjectRoot (), getLeaseId ());
604
+
605
+ ExecResult result = ExecCommand .exec (cmd .toString ());
606
+ if (result .exitValue () == 0 ) {
607
+ // logger.info("Executed statedump.sh " + result.stdout());
608
+ } else {
609
+ logger .info ("Execution of statedump.sh failed, " + result .stderr () + "\n " + result .stdout ());
610
+ }
611
+
612
+ TestUtils .renewK8sClusterLease (getProjectRoot (), getLeaseId ());
613
+
614
+ if (JENKINS ) {
615
+ result = cleanup ();
616
+ if (result .exitValue () != 0 ) {
617
+ logger .info ("cleanup result =" + result .stdout () + "\n " + result .stderr ());
618
+ }
619
+ }
620
+
621
+ if (getLeaseId () != "" ) {
622
+ logger .info ("Release the k8s cluster lease" );
623
+ TestUtils .releaseLease (getProjectRoot (), getLeaseId ());
624
+ }
625
+ }
523
626
}
0 commit comments