99import java .util .Map ;
1010import java .util .Properties ;
1111import java .util .logging .FileHandler ;
12+ import java .util .logging .Level ;
1213import java .util .logging .Logger ;
1314import java .util .logging .SimpleFormatter ;
1415import javax .jms .Connection ;
@@ -27,6 +28,25 @@ public class BaseTest {
2728 public static final Logger logger = Logger .getLogger ("OperatorIT" , "OperatorIT" );
2829 public static final String TESTWEBAPP = "testwebapp" ;
2930
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+
3050 private static String resultRoot = "" ;
3151 private static String pvRoot = "" ;
3252 private static String resultDir = "" ;
@@ -41,6 +61,28 @@ public class BaseTest {
4161 private static String appLocationInPod = "/u01/oracle/apps" ;
4262 private static Properties appProps ;
4363
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+
4486 public static void initialize (String appPropsFile ) throws Exception {
4587
4688 // load app props defined
@@ -95,6 +137,28 @@ public static void initialize(String appPropsFile) throws Exception {
95137 + "\n "
96138 + clnResult .stderr ());
97139 }
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+
98162 // create resultRoot, PVRoot, etc
99163 Files .createDirectories (Paths .get (resultRoot ));
100164 Files .createDirectories (Paths .get (resultDir ));
@@ -520,4 +584,43 @@ private void callWebAppAndVerifyScaling(Domain domain, int replicas) throws Exce
520584 TestUtils .checkServiceCreated (podName , domainNS );
521585 }
522586 }
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+ }
523626}
0 commit comments