10
10
import java .util .logging .FileHandler ;
11
11
import java .util .logging .Logger ;
12
12
import java .util .logging .SimpleFormatter ;
13
+ import oracle .kubernetes .operator .utils .Domain ;
13
14
import oracle .kubernetes .operator .utils .ExecCommand ;
14
15
import oracle .kubernetes .operator .utils .ExecResult ;
16
+ import oracle .kubernetes .operator .utils .Operator ;
15
17
import oracle .kubernetes .operator .utils .TestUtils ;
16
18
17
19
/**
20
22
*/
21
23
public class BaseTest {
22
24
public static final Logger logger = Logger .getLogger ("OperatorIT" , "OperatorIT" );
25
+ public static final String TESTWEBAPP = "testwebapp" ;
23
26
24
27
private static String resultRoot = "" ;
25
28
private static String pvRoot = "" ;
@@ -112,6 +115,11 @@ public static void initialize(String appPropsFile) throws Exception {
112
115
}
113
116
}
114
117
118
+ logger .info ("appProps = " + appProps );
119
+ logger .info ("maxIterationPod = " + appProps .getProperty ("maxIterationsPod" ));
120
+ logger .info (
121
+ "maxIterationPod with default= "
122
+ + appProps .getProperty ("maxIterationsPod" , "" + maxIterationsPod ));
115
123
logger .info ("RESULT_ROOT =" + resultRoot );
116
124
logger .info ("PV_ROOT =" + pvRoot );
117
125
logger .info ("userProjectsDir =" + userProjectsDir );
@@ -132,6 +140,135 @@ public static void initialize(String appPropsFile) throws Exception {
132
140
logger .info ("Env var BRANCH_NAME " + System .getenv ("BRANCH_NAME" ));
133
141
}
134
142
143
+ /**
144
+ * Access Operator REST endpoint using admin node host and node port
145
+ *
146
+ * @throws Exception
147
+ */
148
+ public void testAdminServerExternalService (Domain domain ) throws Exception {
149
+ logTestBegin ("testAdminServerExternalService" );
150
+ domain .verifyAdminServerExternalService (getUsername (), getPassword ());
151
+ logger .info ("SUCCESS" );
152
+ }
153
+
154
+ /**
155
+ * Verify t3channel port by deploying webapp using the port
156
+ *
157
+ * @throws Exception
158
+ */
159
+ public void testAdminT3Channel (Domain domain ) throws Exception {
160
+ logTestBegin ("testAdminT3Channel" );
161
+ Properties domainProps = domain .getDomainProps ();
162
+ // check if the property is set to true
163
+ Boolean exposeAdmint3Channel = new Boolean (domainProps .getProperty ("exposeAdminT3Channel" ));
164
+
165
+ if (exposeAdmint3Channel != null && exposeAdmint3Channel .booleanValue ()) {
166
+ domain .deployWebAppViaWLST (
167
+ TESTWEBAPP ,
168
+ getProjectRoot () + "/src/integration-tests/apps/testwebapp.war" ,
169
+ getUsername (),
170
+ getPassword ());
171
+ } else {
172
+ throw new RuntimeException ("FAILURE: exposeAdminT3Channel is not set or false" );
173
+ }
174
+ domain .verifyWebAppLoadBalancing (TESTWEBAPP );
175
+ logger .info ("SUCCESS" );
176
+ }
177
+
178
+ /**
179
+ * Restarting the domain should not have any impact on Operator managing the domain, web app load
180
+ * balancing and node port service
181
+ *
182
+ * @throws Exception
183
+ */
184
+ public void testDomainLifecyle (Operator operator , Domain domain ) throws Exception {
185
+ logTestBegin ("testDomainLifecyle" );
186
+ domain .destroy ();
187
+ domain .create ();
188
+ operator .verifyExternalRESTService ();
189
+ operator .verifyDomainExists (domain .getDomainUid ());
190
+ domain .verifyDomainCreated ();
191
+ domain .verifyWebAppLoadBalancing (TESTWEBAPP );
192
+ domain .verifyAdminServerExternalService (getUsername (), getPassword ());
193
+ logger .info ("SUCCESS" );
194
+ }
195
+
196
+ /**
197
+ * Scale the cluster up/down using Operator REST endpoint, load balancing should adjust
198
+ * accordingly.
199
+ *
200
+ * @throws Exception
201
+ */
202
+ public void testClusterScaling (Operator operator , Domain domain ) throws Exception {
203
+ logTestBegin ("testClusterScaling" );
204
+ Properties domainProps = domain .getDomainProps ();
205
+ String domainUid = domain .getDomainUid ();
206
+ String domainNS = domainProps .getProperty ("namespace" );
207
+ String managedServerNameBase = domainProps .getProperty ("managedServerNameBase" );
208
+ int replicas = 3 ;
209
+ String podName = domain .getDomainUid () + "-" + managedServerNameBase + replicas ;
210
+ String clusterName = domainProps .getProperty ("clusterName" );
211
+
212
+ logger .info (
213
+ "Scale domain " + domain .getDomainUid () + " Up to " + replicas + " managed servers" );
214
+ operator .scale (domainUid , domainProps .getProperty ("clusterName" ), replicas );
215
+
216
+ logger .info ("Checking if managed pod(" + podName + ") is Running" );
217
+ TestUtils .checkPodCreated (podName , domainNS );
218
+
219
+ logger .info ("Checking if managed server (" + podName + ") is Running" );
220
+ TestUtils .checkPodReady (podName , domainNS );
221
+
222
+ logger .info ("Checking if managed service(" + podName + ") is created" );
223
+ TestUtils .checkServiceCreated (podName , domainNS );
224
+
225
+ int replicaCnt = TestUtils .getClusterReplicas (domainUid , clusterName , domainNS );
226
+ if (replicaCnt != replicas ) {
227
+ throw new RuntimeException (
228
+ "FAILURE: Cluster replica doesn't match with scaled up size "
229
+ + replicaCnt
230
+ + "/"
231
+ + replicas );
232
+ }
233
+
234
+ domain .verifyWebAppLoadBalancing (TESTWEBAPP );
235
+
236
+ replicas = 2 ;
237
+ podName = domainUid + "-" + managedServerNameBase + (replicas + 1 );
238
+ logger .info ("Scale down to " + replicas + " managed servers" );
239
+ operator .scale (domainUid , clusterName , replicas );
240
+
241
+ logger .info ("Checking if managed pod(" + podName + ") is deleted" );
242
+ TestUtils .checkPodDeleted (podName , domainNS );
243
+
244
+ replicaCnt = TestUtils .getClusterReplicas (domainUid , clusterName , domainNS );
245
+ if (replicaCnt != replicas ) {
246
+ throw new RuntimeException (
247
+ "FAILURE: Cluster replica doesn't match with scaled down size "
248
+ + replicaCnt
249
+ + "/"
250
+ + replicas );
251
+ }
252
+
253
+ domain .verifyWebAppLoadBalancing (TESTWEBAPP );
254
+ logger .info ("SUCCESS" );
255
+ }
256
+
257
+ /**
258
+ * Restarting Operator should not impact the running domain
259
+ *
260
+ * @throws Exception
261
+ */
262
+ public void testOperatorLifecycle (Operator operator , Domain domain ) throws Exception {
263
+ logTestBegin ("testOperatorLifecycle" );
264
+ operator .destroy ();
265
+ operator .create ();
266
+ operator .verifyExternalRESTService ();
267
+ operator .verifyDomainExists (domain .getDomainUid ());
268
+ domain .verifyDomainCreated ();
269
+ logger .info ("SUCCESS" );
270
+ }
271
+
135
272
public static String getResultRoot () {
136
273
return resultRoot ;
137
274
}
0 commit comments