1
1
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2
2
// Licensed under the Universal Permissive License v 1.0 as shown at
3
3
// http://oss.oracle.com/licenses/upl.
4
-
5
4
package oracle .kubernetes .operator ;
6
5
7
6
import java .nio .file .Files ;
25
24
* extend this class.
26
25
*/
27
26
public class BaseTest {
27
+
28
28
public static final Logger logger = Logger .getLogger ("OperatorIT" , "OperatorIT" );
29
29
public static final String TESTWEBAPP = "testwebapp" ;
30
30
31
+ // property file used to customize operator properties for operator inputs yaml
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
+
31
49
private static String resultRoot = "" ;
32
50
private static String pvRoot = "" ;
33
51
private static String resultDir = "" ;
@@ -42,6 +60,30 @@ public class BaseTest {
42
60
private static String appLocationInPod = "/u01/oracle/apps" ;
43
61
private static Properties appProps ;
44
62
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 ) {
77
+ QUICKTEST = true ;
78
+ }
79
+ if (System .getenv ("JENKINS" ) != null ) {
80
+ JENKINS = new Boolean (System .getenv ("JENKINS" )).booleanValue ();
81
+ }
82
+ if (System .getenv ("INGRESSPERDOMAIN" ) != null ) {
83
+ INGRESSPERDOMAIN = new Boolean (System .getenv ("INGRESSPERDOMAIN" )).booleanValue ();
84
+ }
85
+ }
86
+
45
87
public static void initialize (String appPropsFile ) throws Exception {
46
88
47
89
// load app props defined
@@ -96,6 +138,28 @@ public static void initialize(String appPropsFile) throws Exception {
96
138
+ "\n "
97
139
+ clnResult .stderr ());
98
140
}
141
+
142
+ if (System .getenv ("JENKINS" ) != null ) {
143
+ logger .info ("Creating " + resultRoot + "/acceptance_test_tmp" );
144
+ TestUtils .exec (
145
+ "/usr/local/packages/aime/ias/run_as_root \" mkdir -p "
146
+ + resultRoot
147
+ + "/acceptance_test_tmp\" " );
148
+ TestUtils .exec (
149
+ "/usr/local/packages/aime/ias/run_as_root \" chmod 777 "
150
+ + resultRoot
151
+ + "/acceptance_test_tmp\" " );
152
+ logger .info ("Creating " + pvRoot + "/acceptance_test_pv" );
153
+ TestUtils .exec (
154
+ "/usr/local/packages/aime/ias/run_as_root \" mkdir -p "
155
+ + pvRoot
156
+ + "/acceptance_test_pv\" " );
157
+ TestUtils .exec (
158
+ "/usr/local/packages/aime/ias/run_as_root \" chmod 777 "
159
+ + pvRoot
160
+ + "/acceptance_test_pv\" " );
161
+ }
162
+
99
163
// create resultRoot, PVRoot, etc
100
164
Files .createDirectories (Paths .get (resultRoot ));
101
165
Files .createDirectories (Paths .get (resultDir ));
@@ -543,23 +607,37 @@ private void callWebAppAndVerifyScaling(Domain domain, int replicas) throws Exce
543
607
}
544
608
545
609
public static void tearDown () throws Exception {
610
+ logger .log (
611
+ Level .INFO ,
612
+ "TEARDOWN: Starting Test Run TearDown (cleanup and state-dump)."
613
+ + " Note that if the test failed previous to tearDown, "
614
+ + " the error that caused the test failure may be reported "
615
+ + "after the tearDown completes. Note that tearDown itself may report errors,"
616
+ + " but this won't affect the outcome of the test results." );
546
617
StringBuffer cmd =
547
618
new StringBuffer ("export RESULT_ROOT=$RESULT_ROOT && export PV_ROOT=$PV_ROOT && " );
548
619
cmd .append (BaseTest .getProjectRoot ())
549
620
.append ("/integration-tests/src/test/resources/statedump.sh" );
550
621
logger .info ("Running " + cmd );
551
622
623
+ // renew lease before callin statedump.sh
624
+ TestUtils .renewK8sClusterLease (getProjectRoot (), getLeaseId ());
625
+
552
626
ExecResult result = ExecCommand .exec (cmd .toString ());
553
627
if (result .exitValue () == 0 ) {
554
- logger .info ("Executed statedump.sh " + result .stdout ());
628
+ // logger.info("Executed statedump.sh " + result.stdout());
555
629
} else {
556
630
logger .info ("Execution of statedump.sh failed, " + result .stderr () + "\n " + result .stdout ());
557
631
}
558
632
559
- // if (JENKINS) {
560
- result = cleanup ();
561
- logger .info ("cleanup result =" + result .stdout () + "\n " + result .stderr ());
562
- // }
633
+ TestUtils .renewK8sClusterLease (getProjectRoot (), getLeaseId ());
634
+
635
+ if (JENKINS ) {
636
+ result = cleanup ();
637
+ if (result .exitValue () != 0 ) {
638
+ logger .info ("cleanup result =" + result .stdout () + "\n " + result .stderr ());
639
+ }
640
+ }
563
641
564
642
if (getLeaseId () != "" ) {
565
643
logger .info ("Release the k8s cluster lease" );
0 commit comments