Skip to content

Commit 6fcb36e

Browse files
authored
Merge pull request #542 from oracle/feature/java-integration-tests
Changes to create and start a domain for each test and others
2 parents 0a3299c + 0368108 commit 6fcb36e

File tree

11 files changed

+151
-87
lines changed

11 files changed

+151
-87
lines changed

integration-tests/README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,29 @@ Quick test use cases.
2626
6. verify domain life cycle(destroy and create) should not any impact on Operator managing the domain and web app load balancing and admin external service
2727
7. cluster scale up/down using Operator REST endpoint, webapp load balancing should adjust accordingly. (run.sh does scaling by editing the replicas in domain-custom-resource.yaml.)
2828
8. Operator life cycle(destroy and create) should not impact the running domain
29+
9. verify liveness probe by killing managed server 1 process 3 times to kick pod auto-restart
30+
10. shutdown the domain by changing domain serverStartPolicy to NEVER
2931

3032
Full test use cases
3133

32-
* keep the first domain and operator running
34+
* keep the first operator running
3335
* create another domain domain2 in default namespace and verify the domain by doing the checks 2 - 5 listed in quick test
34-
* destroy domain domain2
36+
* shutdown and delete domain domain2
3537
* create another domain domain3 with dynamic cluster using WDT in test1 namespace and verify the domain by doing the checks 2 - 5 listed in quick test
3638
* verify cluster scaling by doing scale up for domain3 using WLDF scaling
37-
* destroy domain domain3
39+
* shutdown and delete domain domain3
3840
* create another operator operator2 which manages test2 namespace and verify domain1 is not affected
39-
* create another domain domain4 with Configured cluster using WDT in test2 namespace and verify the domain by doing the checks 2 - 5 listed in quick test
40-
* verify scaling for domain4 cluster from 2 to 3 servers and back to 2, plus verify no impact on domain1
41-
* cycle domain1 down and back up, plus verify no impact on domain4
42-
* create domain5 in the default namespace with serverStartPolicy="ADMIN_ONLY", and verify that only admin server is created. on Jenkins, this domain will also test NFS instead of HOSTPATH PV storage
43-
* create domain6 in the default namespace with pvReclaimPolicy="Recycle", and verify that the PV is deleted once the domain and PVC are deleted
44-
* test managed server 1 pod auto-restart in domain1
45-
* destroy domain1
46-
* test that create domain fails when its pv is already populated by a shutdown domain
47-
* create another domain domain7 with APACHE load balancer and access admin console via LB port.
48-
* create another domain domain8 with mostly default values from sample domain inputs, mainly exposeAdminT3Channel and exposeAdminNodePort which are false by default and verify domain startup and cluster scaling using operator rest endpoint works.
41+
* create another domain domain4 with dynamic cluster in default namespace and domain domain5 with Configured cluster using WDT in test2 namespace and verify the domain by doing the checks 2 - 5 listed in quick test
42+
* verify scaling for domain5 cluster from 2 to 3 servers and back to 2, plus verify no impact on domain4
43+
* cycle domain4 down and back up, plus verify no impact on domain5
44+
* shutdown and delete both domain4 and domain5
45+
* create domain6 in the default namespace with serverStartPolicy="ADMIN_ONLY", and verify that only admin server is created. on Jenkins, this domain will also test NFS instead of HOSTPATH PV storage
46+
* shutdown and delete domain6
47+
* create domain7 in the default namespace with pvReclaimPolicy="Recycle", and verify that the PV is deleted once the domain and PVC are deleted
48+
* shutdown and delete domain7
49+
* create domain domain8 and test that create domain fails when its pv is already populated by a shutdown domain
50+
* create another domain domain9 with APACHE load balancer and access admin console via LB port. shutdown domain.
51+
* create another domain domain10 with mostly default values from sample domain inputs, mainly exposeAdminT3Channel and exposeAdminNodePort which are false by default and verify domain startup and cluster scaling using operator rest endpoint works.
4952

5053

5154
# Directory Configuration and Structure

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ public class ITOperator extends BaseTest {
3838
private static String domain6YamlFile = "domain6.yaml";
3939
private static String domain7YamlFile = "domain7.yaml";
4040
private static String domain8YamlFile = "domain8.yaml";
41+
private static String domain9YamlFile = "domain9.yaml";
42+
private static String domain10YamlFile = "domain10.yaml";
4143

4244
// property file used to configure constants for integration tests
4345
private static String appPropsFile = "OperatorIT.properties";
4446

4547
private static Operator operator1, operator2;
46-
private static Domain domain1;
4748

4849
/**
4950
* This method gets called only once before any of the test methods are executed. It does the
@@ -93,9 +94,9 @@ public void test1CreateFirstOperatorAndDomain() throws Exception {
9394

9495
logTestBegin("test1CreateFirstOperatorAndDomain");
9596
testCreateOperatorManagingDefaultAndTest1NS();
96-
domain1 = testAllUseCasesForADomain(operator1, domain1YamlFile);
97+
Domain domain1 = testAllUseCasesForADomain(operator1, domain1YamlFile);
9798
domain1.testWlsLivenessProbe();
98-
domain1.destroy();
99+
domain1.shutdownUsingServerStartPolicy();
99100

100101
logger.info("SUCCESS - test1CreateFirstOperatorAndDomain");
101102
}
@@ -159,34 +160,31 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
159160
if (operator1 == null) {
160161
operator1 = TestUtils.createOperator(op1YamlFile);
161162
}
162-
if (domain1 == null) {
163-
domain1 = TestUtils.createDomain(domain1YamlFile);
164-
} else {
165-
domain1.create();
166-
}
163+
Domain domain4 = TestUtils.createDomain(domain4YamlFile);
164+
167165
logger.info("Checking if operator2 is running, if not creating");
168166
if (operator2 == null) {
169167
operator2 = TestUtils.createOperator(op2YamlFile);
170168
}
171-
// create domain4
172-
Domain domain4 = testDomainCreation(domain4YamlFile);
169+
// create domain5 with configured cluster
170+
Domain domain5 = testDomainCreation(domain5YamlFile);
173171

174-
logger.info("Verify the only remaining running domain domain1 is unaffected");
175-
domain1.verifyDomainCreated();
172+
logger.info("Verify the only remaining running domain domain4 is unaffected");
173+
domain4.verifyDomainCreated();
176174

177-
testClusterScaling(operator2, domain4);
175+
testClusterScaling(operator2, domain5);
178176

179-
logger.info("Verify the only remaining running domain domain1 is unaffected");
180-
domain1.verifyDomainCreated();
177+
logger.info("Verify the only remaining running domain domain4 is unaffected");
178+
domain4.verifyDomainCreated();
181179

182-
logger.info("Destroy and create domain1 and verify no impact on domain4");
183-
domain1.destroy();
184-
domain1.create();
180+
logger.info("Destroy and create domain4 and verify no impact on domain5");
181+
domain4.destroy();
182+
domain4.create();
185183

186-
logger.info("Verify no impact on domain4");
187-
domain4.verifyDomainCreated();
184+
logger.info("Verify no impact on domain5");
185+
domain5.verifyDomainCreated();
186+
domain5.destroy();
188187
domain4.destroy();
189-
domain1.destroy();
190188
logger.info("SUCCESS - test5CreateConfiguredDomainInTest2NS");
191189
}
192190

@@ -200,10 +198,10 @@ public void test6CreateDomainWithStartPolicyAdminOnly() throws Exception {
200198
if (operator1 == null) {
201199
operator1 = TestUtils.createOperator(op1YamlFile);
202200
}
203-
logger.info("Creating Domain domain5 & verifing the domain creation");
204-
// create domain5
205-
Domain domain5 = TestUtils.createDomain(domain5YamlFile);
206-
domain5.destroy();
201+
logger.info("Creating Domain domain6 & verifing the domain creation");
202+
// create domain6
203+
Domain domain6 = TestUtils.createDomain(domain6YamlFile);
204+
domain6.destroy();
207205
logger.info("SUCCESS - test6CreateDomainWithStartPolicyAdminOnly");
208206
}
209207

@@ -217,47 +215,46 @@ public void test7CreateDomainPVReclaimPolicyRecycle() throws Exception {
217215
if (operator1 == null) {
218216
operator1 = TestUtils.createOperator(op1YamlFile);
219217
}
220-
logger.info("Creating Domain domain6 & verifing the domain creation");
221-
// create domain6
222-
Domain domain6 = TestUtils.createDomain(domain6YamlFile);
223-
domain6.shutdown();
224-
domain6.deletePVCAndCheckPVReleased();
218+
logger.info("Creating Domain domain7 & verifing the domain creation");
219+
// create domain7
220+
Domain domain7 = TestUtils.createDomain(domain7YamlFile);
221+
domain7.shutdown();
222+
domain7.deletePVCAndCheckPVReleased();
225223
logger.info("SUCCESS - test7CreateDomainPVReclaimPolicyRecycle");
226224
}
227225

228226
@Test
229-
public void test9CreateDomainOnExistingDir() throws Exception {
227+
public void test8CreateDomainOnExistingDir() throws Exception {
230228
Assume.assumeFalse(
231229
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
232230

233-
logTestBegin("test9CreateDomainOnExistingDir");
231+
logTestBegin("test8CreateDomainOnExistingDir");
234232
if (operator1 == null) {
235233
operator1 = TestUtils.createOperator(op1YamlFile);
236234
}
237-
if (domain1 == null) {
238-
domain1 = TestUtils.createDomain(domain1YamlFile);
239-
// create domain on existing dir
240-
domain1.destroy();
241-
}
242-
logger.info("domain1 " + domain1);
243-
domain1.createDomainOnExistingDirectory();
244-
logger.info("SUCCESS - test9CreateDomainOnExistingDir");
235+
236+
Domain domain8 = TestUtils.createDomain(domain8YamlFile);
237+
// create domain on existing dir
238+
domain8.destroy();
239+
240+
domain8.createDomainOnExistingDirectory();
241+
logger.info("SUCCESS - test8CreateDomainOnExistingDir");
245242
}
246243

247244
// @Test
248245
public void testACreateDomainApacheLB() throws Exception {
249246
Assume.assumeFalse(
250247
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
251248
logTestBegin("testACreateDomainApacheLB");
252-
logger.info("Creating Domain domain7 & verifing the domain creation");
249+
logger.info("Creating Domain domain9 & verifing the domain creation");
253250
if (operator1 == null) {
254251
operator1 = TestUtils.createOperator(op1YamlFile);
255252
}
256253

257254
// create domain7
258-
Domain domain7 = TestUtils.createDomain(domain7YamlFile);
259-
domain7.verifyAdminConsoleViaLB();
260-
domain7.destroy();
255+
Domain domain9 = TestUtils.createDomain(domain9YamlFile);
256+
domain9.verifyAdminConsoleViaLB();
257+
domain9.destroy();
261258
logger.info("SUCCESS - testACreateDomainApacheLB");
262259
}
263260

@@ -266,14 +263,14 @@ public void testBCreateDomainWithDefaultValuesInSampleInputs() throws Exception
266263
Assume.assumeFalse(
267264
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
268265
logTestBegin("testBCreateDomainWithDefaultValuesInSampleInputs");
269-
logger.info("Creating Domain domain8 & verifing the domain creation");
266+
logger.info("Creating Domain domain10 & verifing the domain creation");
270267
if (operator1 == null) {
271268
operator1 = TestUtils.createOperator(op1YamlFile);
272269
}
273270

274-
// create domain8
275-
Domain domain8 = testAllUseCasesForADomain(operator1, domain8YamlFile);
276-
domain8.destroy();
271+
// create domain10
272+
Domain domain10 = testAllUseCasesForADomain(operator1, domain10YamlFile);
273+
domain10.destroy();
277274
logger.info("SUCCESS - testBCreateDomainWithDefaultValuesInSampleInputs");
278275
}
279276

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,26 @@ public void verifyServersReady() throws Exception {
170170
TestUtils.checkPodReady(domainUid + "-" + managedServerNameBase + i, domainNS);
171171
}
172172
}
173+
// check no additional servers are started
174+
if (domainMap.get("serverStartPolicy").toString().trim().equals("ADMIN_ONLY")) {
175+
initialManagedServerReplicas = 0;
176+
}
177+
String additionalManagedServer =
178+
domainUid + "-" + managedServerNameBase + (initialManagedServerReplicas + 1);
179+
logger.info(
180+
"Checking if managed server " + additionalManagedServer + " is started, it should not be");
181+
StringBuffer cmd = new StringBuffer();
182+
cmd.append("kubectl get pod ").append(additionalManagedServer).append(" -n ").append(domainNS);
183+
ExecResult result = ExecCommand.exec(cmd.toString());
184+
185+
if (result.exitValue() == 0 && result.stdout().contains("1/1")) {
186+
throw new RuntimeException(
187+
"FAILURE: Managed Server "
188+
+ additionalManagedServer
189+
+ " is started, but its not expected.");
190+
} else {
191+
logger.info(additionalManagedServer + " is not running, which is expected behaviour");
192+
}
173193
}
174194
/**
175195
* verify nodeport by accessing admin REST endpoint
@@ -391,6 +411,7 @@ public void destroy() throws Exception {
391411
}
392412

393413
public void shutdown() throws Exception {
414+
int replicas = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
394415
String cmd = "kubectl delete domain " + domainUid + " -n " + domainNS;
395416
ExecResult result = ExecCommand.exec(cmd);
396417
if (result.exitValue() != 0) {
@@ -399,7 +420,27 @@ public void shutdown() throws Exception {
399420
}
400421
String output = result.stdout().trim();
401422
logger.info("command to delete domain " + cmd + " \n returned " + output);
423+
verifyDomainDeleted(replicas);
402424
}
425+
426+
public void shutdownUsingServerStartPolicy() throws Exception {
427+
int replicas = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
428+
String cmd =
429+
"kubectl patch domain "
430+
+ domainUid
431+
+ " -n "
432+
+ domainNS
433+
+ " -p '{\"spec\":{\"serverStartPolicy\":\"NEVER\"}}' --type merge";
434+
ExecResult result = ExecCommand.exec(cmd);
435+
if (result.exitValue() != 0) {
436+
throw new RuntimeException(
437+
"FAILURE: command " + cmd + " failed, returned " + result.stderr());
438+
}
439+
String output = result.stdout().trim();
440+
logger.info("command to shutdown domain " + cmd + " \n returned " + output);
441+
verifyServerPodsDeleted(replicas);
442+
}
443+
403444
/**
404445
* verify domain is deleted
405446
*
@@ -409,8 +450,11 @@ public void shutdown() throws Exception {
409450
public void verifyDomainDeleted(int replicas) throws Exception {
410451
logger.info("Inside verifyDomainDeleted, replicas " + replicas);
411452
TestUtils.checkDomainDeleted(domainUid, domainNS);
412-
TestUtils.checkPodDeleted(domainUid + "-" + adminServerName, domainNS);
453+
verifyServerPodsDeleted(replicas);
454+
}
413455

456+
public void verifyServerPodsDeleted(int replicas) throws Exception {
457+
TestUtils.checkPodDeleted(domainUid + "-" + adminServerName, domainNS);
414458
for (int i = 1; i <= replicas; i++) {
415459
TestUtils.checkPodDeleted(domainUid + "-" + managedServerNameBase + i, domainNS);
416460
}

integration-tests/src/test/java/oracle/kubernetes/operator/utils/TestUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,13 @@ private static int makeOperatorRestCall(
357357
logger.info("Sleeping 5 more seconds and try again");
358358
Thread.sleep(5 * 1000);
359359
continue;
360+
} else {
361+
throw ex;
360362
}
361363
}
362364
break;
363365
}
364-
logger.info("response: " + response.toString());
366+
logger.info("response: " + response);
365367

366368
int returnCode = response.getStatus();
367369
// Verify
@@ -371,10 +373,8 @@ private static int makeOperatorRestCall(
371373
} else {
372374
throw new RuntimeException("Response " + response.readEntity(String.class));
373375
}
374-
375376
response.close();
376377
// javaClient.close();
377-
378378
return returnCode;
379379
}
380380

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
domainUID: domain10
5+
configuredManagedServerCount: 4

integration-tests/src/test/resources/domain4.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,7 @@
44
adminServerName: admin-server
55
domainUID: domain4
66
clusterName: cluster-1
7-
clusterType: CONFIGURED
87
configuredManagedServerCount: 4
98
initialManagedServerReplicas: 2
109
managedServerNameBase: managed-server
11-
#weblogicDomainStoragePath will be ignored, PV dir will be created at /<baseDir>/<USER>/acceptance_test_pv
12-
#weblogicDomainStoragePath: /scratch/external-domain-home/pv001/
13-
exposeAdminT3Channel: true
14-
t3ChannelPort: 30051
15-
exposeAdminNodePort: true
16-
adminNodePort: 30704
17-
namespace: test2
18-
createDomainFilesDir: wdt
10+
namespace: default

integration-tests/src/test/resources/domain5.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
adminServerName: admin-server
55
domainUID: domain5
66
clusterName: cluster-1
7-
clusterType: DYNAMIC
7+
clusterType: CONFIGURED
88
configuredManagedServerCount: 4
99
initialManagedServerReplicas: 2
1010
managedServerNameBase: managed-server
1111
#weblogicDomainStoragePath will be ignored, PV dir will be created at /<baseDir>/<USER>/acceptance_test_pv
1212
#weblogicDomainStoragePath: /scratch/external-domain-home/pv001/
1313
exposeAdminT3Channel: true
14-
t3ChannelPort: 30061
14+
t3ChannelPort: 30051
1515
exposeAdminNodePort: true
16-
adminNodePort: 30705
17-
namespace: default
18-
serverStartPolicy: ADMIN_ONLY
16+
adminNodePort: 30704
17+
namespace: test2
18+
createDomainFilesDir: wdt

integration-tests/src/test/resources/domain6.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ managedServerNameBase: managed-server
1111
#weblogicDomainStoragePath will be ignored, PV dir will be created at /<baseDir>/<USER>/acceptance_test_pv
1212
#weblogicDomainStoragePath: /scratch/external-domain-home/pv001/
1313
exposeAdminT3Channel: true
14-
t3ChannelPort: 30071
14+
t3ChannelPort: 30061
1515
exposeAdminNodePort: true
16-
adminNodePort: 30706
16+
adminNodePort: 30705
1717
namespace: default
18-
weblogicDomainStorageReclaimPolicy: Recycle
18+
serverStartPolicy: ADMIN_ONLY

integration-tests/src/test/resources/domain7.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ managedServerNameBase: managed-server
1111
#weblogicDomainStoragePath will be ignored, PV dir will be created at /<baseDir>/<USER>/acceptance_test_pv
1212
#weblogicDomainStoragePath: /scratch/external-domain-home/pv001/
1313
exposeAdminT3Channel: true
14-
t3ChannelPort: 30081
14+
t3ChannelPort: 30071
1515
exposeAdminNodePort: true
16-
adminNodePort: 30707
16+
adminNodePort: 30706
1717
namespace: default
18-
loadBalancer: APACHE
19-
loadBalancerWebPort: 30311
20-
loadBalancerDashboardPort: 30321
18+
weblogicDomainStorageReclaimPolicy: Recycle

0 commit comments

Comments
 (0)