14
14
import oracle .kubernetes .operator .utils .TestUtils ;
15
15
import org .junit .jupiter .api .AfterAll ;
16
16
import org .junit .jupiter .api .AfterEach ;
17
- import org .junit .jupiter .api .Assertions ;
18
17
import org .junit .jupiter .api .BeforeAll ;
19
18
import org .junit .jupiter .api .BeforeEach ;
20
19
import org .junit .jupiter .api .MethodOrderer .Alphanumeric ;
21
20
import org .junit .jupiter .api .Test ;
22
21
import org .junit .jupiter .api .TestMethodOrder ;
23
22
23
+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
24
+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
25
+
24
26
@ TestMethodOrder (Alphanumeric .class )
25
27
26
28
public class ItJrfPvWlst extends BaseTest {
27
29
private static String rcuSchemaPrefix = "jrfdomain" ;
28
- private static Operator operator1 ;
30
+ private static Operator operator ;
29
31
private static String domainNS ;
30
32
private static String domainUid = "" ;
31
33
private static String restartTmpDir = "" ;
32
34
private static boolean testCompletedSuccessfully ;
33
35
private static String testClassName ;
34
36
private static StringBuffer namespaceList ;
37
+ private static int dbPort ;
38
+ private static String dbrcuNamespace ;
39
+ private static String dbUrl ;
40
+ private static JrfDomain jrfdomain ;
35
41
36
42
/**
37
- * This method gets called only once before any of the test methods are executed. It does the
38
- * initialization of the integration test properties defined in OperatorIT.properties and setting
39
- * the resultRoot, pvRoot and projectRoot attributes. It also creates Oracle DB pod which used for
40
- * RCU.
41
- *
42
- * @throws Exception - if an error occurs when load property file or create DB pod
43
- */
43
+ * This method gets called only once before any of the test methods are executed. It does the
44
+ * initialization of the integration test properties defined in OperatorIT.properties and sets
45
+ * the resultRoot, pvRoot and projectRoot attributes.
46
+ */
44
47
@ BeforeAll
45
- public static void staticPrepare () throws Exception {
48
+ public static void staticPrepare () {
46
49
namespaceList = new StringBuffer ();
47
50
testClassName = new Object () {
48
51
}.getClass ().getEnclosingClass ().getSimpleName ();
49
- // initialize test properties
50
- initialize (APP_PROPS_FILE , testClassName );
52
+
53
+ LoggerHelper .getLocal ().log (Level .INFO , "setting up properties, directories for: {0}" ,
54
+ testClassName );
55
+ assertDoesNotThrow (() -> initialize (APP_PROPS_FILE , testClassName ),
56
+ "Failed: initial setup" );
51
57
}
52
58
53
59
/**
54
- * Prepare test.
55
- * @throws Exception on failure
60
+ * This method gets called before every test. It creates the result/pv root directories
61
+ * for the test. It also creates RCU schema, operator.
56
62
*/
57
63
@ BeforeEach
58
- public void prepare () throws Exception {
59
- if (QUICKTEST ) {
60
- createResultAndPvDirs (testClassName );
61
-
62
- TestUtils .execOrAbortProcess (
63
- "cp -rf "
64
- + BaseTest .getProjectRoot ()
65
- + "/kubernetes/samples/scripts "
66
- + getResultDir (),
67
- true );
68
- //delete leftover pods caused by test being aborted
69
- DbUtils .deleteRcuPod (getResultDir ());
70
- DbUtils .stopOracleDB (getResultDir ());
71
-
72
- DbUtils .startOracleDB (getResultDir ());
73
- DbUtils .createRcuSchema (getResultDir (),rcuSchemaPrefix );
74
-
75
- // create operator1
76
- if (operator1 == null ) {
77
- Map <String , Object > operatorMap = createOperatorMap (getNewSuffixCount (),
78
- true , testClassName );
79
- operator1 = TestUtils .createOperator (operatorMap , Operator .RestCertType .SELF_SIGNED );
80
- Assertions .assertNotNull (operator1 );
81
- domainNS = ((ArrayList <String >) operatorMap .get ("domainNamespaces" )).get (0 );
82
- namespaceList .append ((String )operatorMap .get ("namespace" ));
83
- namespaceList .append (" " ).append (domainNS );
84
- }
85
- }
64
+ public void prepare () {
65
+ LoggerHelper .getLocal ().log (Level .INFO , "Creating result/pv root directories" );
66
+ assertDoesNotThrow (() -> createResultAndPvDirs (testClassName ),
67
+ "Failed: createResultAndPvDirs" );
68
+
69
+ LoggerHelper .getLocal ().log (Level .INFO , "Copying sample dir to the result dir" );
70
+ assertDoesNotThrow (() -> TestUtils .execOrAbortProcess (
71
+ "cp -rf "
72
+ + BaseTest .getProjectRoot ()
73
+ + "/kubernetes/samples/scripts "
74
+ + getResultDir (),
75
+ true ),
76
+ "Failed: Copy sample dir to the result dir" );
77
+
78
+ //start DB and create RCU
79
+ dbrcuNamespace = "dbrcu" + String .valueOf (getNewSuffixCount ());
80
+ dbPort = 30011 + getNewSuffixCount ();
81
+ dbUrl = "oracle-db." + dbrcuNamespace + ".svc.cluster.local:1521/devpdb.k8s" ;
82
+ assertDoesNotThrow (() -> DbUtils .setupRcuDatabase (getResultDir (), dbPort , dbUrl ,
83
+ rcuSchemaPrefix , dbrcuNamespace ));
84
+
85
+ // create operator
86
+ if (operator == null ) {
87
+ Map <String , Object > operatorMap = createOperatorMap (getNewSuffixCount (),
88
+ true , testClassName );
89
+ operator = assertDoesNotThrow (() -> TestUtils .createOperator (operatorMap ,
90
+ Operator .RestCertType .SELF_SIGNED ));
91
+ assertNotNull (operator );
92
+ LoggerHelper .getLocal ().log (Level .INFO , "Operator is created for {0}" , testClassName );
93
+
94
+ domainNS = ((ArrayList <String >) operatorMap .get ("domainNamespaces" )).get (0 );
95
+ namespaceList .append ((String )operatorMap .get ("namespace" ));
96
+ namespaceList .append (" " ).append (domainNS );
97
+ }
86
98
}
87
-
99
+
100
+ /**
101
+ * This method will run once after every test method is finished. It delete both RCU and DB pods.
102
+ */
88
103
@ AfterEach
89
- public void unPrepare () throws Exception {
90
- DbUtils .deleteRcuPod (getResultDir ());
91
- DbUtils .stopOracleDB (getResultDir ());
104
+ public void unPrepare () {
105
+ LoggerHelper .getLocal ().log (Level .INFO , "Is going to drop RCU schema and stop DB for {0}" , testClassName );
106
+ assertDoesNotThrow (() -> DbUtils .deleteRcuPod (getResultDir ()),
107
+ "Failed: drop RCU schema" );
108
+ assertDoesNotThrow (() -> DbUtils .deleteDbPod (getResultDir ()),
109
+ "Failed: stop DB" );
92
110
}
93
-
111
+
94
112
/**
95
- * This method will run once after all test methods are finished. It Releases k8s cluster lease,
96
- * archives result, pv directories.
97
- *
98
- * @throws Exception - if any error occurs
99
- */
113
+ * Releases k8s cluster lease, archives result, pv directories.
114
+ */
100
115
@ AfterAll
101
- public static void staticUnPrepare () throws Exception {
102
- tearDown (new Object () {
103
- }.getClass ().getEnclosingClass ().getSimpleName (), namespaceList .toString ());
104
-
105
- LoggerHelper .getLocal ().log (Level .INFO ,"SUCCESS" );
116
+ public static void staticUnPrepare () {
117
+ assertDoesNotThrow (() -> tearDown (new Object () {
118
+ }.getClass ().getEnclosingClass ().getSimpleName (), namespaceList .toString ()),
119
+ "tearDown failed" );
106
120
}
107
-
121
+
122
+ /**
123
+ * Create and deploy a JRF domain. Verify the domain is created successfully.
124
+ */
108
125
@ Test
109
- public void testJrfDomainOnPvUsingWlst () throws Exception {
126
+ public void testJrfDomainOnPvUsingWlst () {
110
127
if (QUICKTEST ) {
111
128
String testMethodName = new Object () {
112
129
}.getClass ().getEnclosingMethod ().getName ();
113
- logTestBegin (testMethodName );
114
130
LoggerHelper .getLocal ().log (Level .INFO ,
115
- "Creating Operator & waiting for the script to complete execution " );
116
-
117
- JrfDomain jrfdomain = null ;
131
+ "+++++++++++++++++++++++++++++++++---------------------------------+ " );
132
+ LoggerHelper . getLocal (). log ( Level . INFO , "BEGIN " + testMethodName );
133
+
118
134
boolean testCompletedSuccessfully = false ;
119
135
120
136
try {
121
137
// create JRF domain
122
138
Map <String , Object > domainMap = createDomainMap (getNewSuffixCount (), testClassName );
123
139
domainMap .put ("namespace" , domainNS );
124
140
domainMap .put ("initialManagedServerReplicas" , new Integer ("2" ));
125
- domainMap .put ("image" , "container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.4" );
126
141
domainMap .put ("clusterName" , "infra-cluster" );
127
142
domainMap .put ("managedServerNameBase" , "infraserver" );
143
+ domainMap .put ("domainHomeSourceType" , "PersistentVolume" );
128
144
domainMap .put ("rcuSchemaPrefix" , "jrfdomain" );
129
- domainMap .put ("rcuDatabaseURL" , "oracle-db.default.svc.cluster.local:1521/devpdb.k8s" );
145
+ LoggerHelper .getLocal ().log (Level .INFO , "DEBUG " + testClassName + "domain: dbUrl: "
146
+ + dbUrl );
147
+ domainMap .put ("rcuDatabaseURL" , dbUrl );
130
148
domainUid = (String ) domainMap .get ("domainUID" );
131
149
LoggerHelper .getLocal ().log (Level .INFO ,
132
150
"Creating and verifying the domain creation with domainUid: " + domainUid );
133
151
134
- jrfdomain = new JrfDomain (domainMap );
135
- jrfdomain .verifyDomainCreated (80 );
136
-
152
+ jrfdomain = assertDoesNotThrow (() -> new JrfDomain (domainMap ),
153
+ "Failed: JRF domain creation" );
154
+ LoggerHelper .getLocal ().log (Level .INFO , "JRF domain is created for {0}" ,
155
+ testClassName );
156
+ assertDoesNotThrow (() -> jrfdomain .verifyDomainCreated (),
157
+ "Failed: domain verification" );
158
+ LoggerHelper .getLocal ().log (Level .INFO , "JRF domain verification succeeded for {0}" ,
159
+ testClassName );
160
+
137
161
// basic test cases
138
- testBasicUseCases (jrfdomain , false );
162
+ assertDoesNotThrow (() -> testBasicUseCases (jrfdomain , false ));
163
+ LoggerHelper .getLocal ().log (Level .INFO , "JRF domain BasicUseCases succeeded for {0}" ,
164
+ testClassName );
139
165
140
166
testCompletedSuccessfully = true ;
141
167
} finally {
142
168
if (jrfdomain != null && (JENKINS || testCompletedSuccessfully )) {
143
- jrfdomain .shutdownUsingServerStartPolicy ();
169
+ assertDoesNotThrow (() -> jrfdomain .shutdownUsingServerStartPolicy () );
144
170
}
145
171
}
146
172
147
173
LoggerHelper .getLocal ().log (Level .INFO , "SUCCESS - " + testMethodName );
148
174
}
149
175
}
150
- }
176
+ }
0 commit comments