Skip to content

Commit 5326945

Browse files
committed
Merge remote-tracking branch 'origin/develop' into voyager-java-integ-test
merge to the latest develop branch
2 parents 3c4c90b + da4c876 commit 5326945

File tree

30 files changed

+694
-567
lines changed

30 files changed

+694
-567
lines changed

integration-tests/README.md

Lines changed: 60 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
11
# Integration Tests for Oracle WebLogic Server Kubernetes Operator
22

3-
This documentation describes the functional use cases that are covered in integration testing for the Oracle WebLogic Server Kubernetes Operator. The tests are written in Java (JUnit tests) and driven by Maven profile.
3+
This documentation describes the functional use cases that are covered in integration testing for the Oracle WebLogic Server Kubernetes Operator. The tests are written in Java (JUnit tests) and driven by Maven profile.
44

55
# Environments
66

7-
The tests currently run in three modes: "Wercker", "Jenkins", and "standalone" Oracle Linux, where the mode is controlled by the WERCKER and JENKINS environment variables described below. The default is "standalone".
7+
The tests currently run in three modes: "Wercker", "Jenkins", and "standalone" Oracle Linux, where the mode is controlled by the `WERCKER` and `JENKINS` environment variables described below. The default is "standalone".
88

9-
* "Standalone" Oracle Linux, i.e, run the tests manually with mvn command.
10-
* Wercker - https://app.wercker.com/Oracle/weblogic-kubernetes-operator/runs - integration-test-java is the pipeline name
11-
* Jenkins - http://wls-jenkins.us.oracle.com/view/weblogic-operator/job/weblogic-kubernetes-operator-javatest/ - Jenkins Run is restricted to Oracle Internal development Process
9+
* "Standalone" Oracle Linux, i.e, run the tests manually with the `mvn` command.
10+
* Wercker - https://app.wercker.com/Oracle/weblogic-kubernetes-operator/runs - `integration-test-java` is the pipeline name.
11+
* Jenkins - http://wls-jenkins.us.oracle.com/view/weblogic-operator/job/weblogic-kubernetes-operator-javatest/ - Jenkins Run is restricted to Oracle Internal development process.
1212

13-
Wercker runs only Quick test use cases, Jenkins run both Quick and Full test use cases.
13+
Wercker runs only Quick test use cases, Jenkins runs both Quick and Full test use cases.
1414

1515
# Use Cases
1616

1717
Java integration tests cover the below use cases:
1818

19-
Quick test use cases -
19+
Quick test use cases
2020

2121
| | |
2222
| --- | --- |
23-
| Operator Configuration | operator1 deployed in weblogic-operator1 namespace and manages domains in default and test1 namespaces |
24-
| Domain Configuration | Domain on PV using WLST, traefik load balancer |
23+
| Operator Configuration | operator1 deployed in `weblogic-operator1` namespace and manages domains in `default` and `test1` namespaces |
24+
| Domain Configuration | Domain on PV using WLST, Traefik load balancer |
2525

2626
Basic Use Cases
2727

28-
1. create operator operator1 which manages default and test1 namespaces, verify its deployed successfully, pod created, operator Ready and verify external REST service if configured
29-
2. create domain domain1 in default namespace and verify the pods, services are created and servers are in Ready
30-
3. verify admin external service by accessing admin REST endpoint with nodeport in URL
31-
4. verify admin t3 channel port by exec into the admin pod and deploying webapp using the channel port for WLST
32-
5. verify web app load balancing by accessing the webapp using loadBalancerWebPort
28+
1. Create operator `operator1` which manages `default` and `test1` namespaces, verify it's deployed successfully, pods created, operator ready and verify external REST service, if configured.
29+
2. Create domain `domain1` in `default` namespace and verify the pods, services are created and servers are in ready state.
30+
3. Verify the admin external service by accessing the admin REST endpoint with `nodeport` in URL.
31+
4. Verify admin t3 channel port by exec into the admin pod and deploying webapp using the channel port for WLST.
32+
5. Verify web app load balancing by accessing the webapp using `loadBalancerWebPort`.
3333

3434
Advanced Use Cases
3535

36-
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
37-
7. cluster scale up/down using Operator REST endpoint, webapp load balancing should adjust accordingly.
38-
8. Operator life cycle(destroy and create) should not impact the running domain
36+
6. Verify domain life cycle (destroy and create) should not have any impact on operator managing the domain and web app load balancing and admin external service.
37+
7. Cluster scale up/down using operator REST endpoint, webapp load balancing should adjust accordingly.
38+
8. Operator life cycle (destroy and create) should not impact the running domain.
3939

40-
Also the below use cases are covered for Quick test
40+
Also the below use cases are covered for Quick test:
4141

42-
9. verify liveness probe by killing managed server 1 process 3 times to kick pod auto-restart
43-
10. shutdown the domain by changing domain serverStartPolicy to NEVER
42+
9. Verify the liveness probe by killing managed server 1 process 3 times to kick pod auto-restart.
43+
10. Shutdown the domain by changing domain `serverStartPolicy` to `NEVER`.
4444

45-
Full test use cases -
45+
Full test use cases
4646

4747
| | |
4848
| --- | --- |
49-
| Operator Configuration | operator2 deployed in weblogic-operator2 namespace and manages domains test2 namespace |
50-
| Domain Configuration | Domain on PV using WDT, Domain with serverStartPolicy ADMIN_ONLY, Domain with auto and custom situational configuration, Two domains managed by two operators, Domain with Recycle weblogicDomainStorageReclaimPolicy, Domain with default sample values |
49+
| Operator Configuration | operator2 deployed in `weblogic-operator2` namespace and manages domains `test2` namespace. |
50+
| Domain Configuration | Domain on PV using WDT; domain with `serverStartPolicy` `ADMIN_ONLY`; domain with auto and custom situational configuration; two domains managed by two operators; domain with recycle `weblogicDomainStorageReclaimPolicy`; domain with default sample values. |
5151

5252

5353
Basic Use Cases described above are verified in all the domain configurations. Also the below use cases are covered:
5454

5555
| Domain | Use Case |
5656
| --- | --- |
5757
| Domain on PV using WDT | WLDF scaling |
58-
| Domain with ADMIN_ONLY | making sure only admin server is started and managed servers are not started. Shutdown domain by deleting domain CRD. Create domain on existing PV dir, pv is already populated by a shutdown domain. |
59-
| Domain with situational config | create domain with listen address not set for admin server and t3 channel/NAP and incorrect file for admin server log location. Introspector should override these with sit-config automatically. Also, with some junk value for t3 channel public address and using custom situational config override replace with valid public address using secret. Also, on Jenkins this domain uses NFS instead of HOSTPATH PV storage |
60-
| Two domains managed by two operators | verify scaling and restart of one domain doesn't impact another domain. Delete domain resources using delete script from samples. |
61-
| Domain with Recycle policy | create domain with pvReclaimPolicy="Recycle" Verify that the PV is deleted once the domain and PVC are deleted |
62-
| Domain with default sample values | create domain using mostly default values for inputs |
63-
58+
| Domain with ADMIN_ONLY | Making sure only admin server is started and managed servers are not started. Shutdown domain by deleting domain CRD. Create domain on existing PV dir, pv is already populated by a shutdown domain. |
59+
| Domain with situational config | Create domain with listen address not set for admin server and t3 channel/NAP and incorrect file for admin server log location. Introspector should override these with sit-config automatically. Also, with some junk value for t3 channel public address and using custom situational config override replace with valid public address using secret. Also, on Jenkins this domain uses NFS instead of HOSTPATH PV storage. |
60+
| Two domains managed by two operators | Verify scaling and restart of one domain doesn't impact another domain. Delete domain resources using delete script from samples. |
61+
| Domain with Recycle policy | Create domain with pvReclaimPolicy="Recycle" Verify that the PV is deleted once the domain and PVC are deleted. |
62+
| Domain with default sample values | Create domain using mostly default values for inputs. |
63+
6464

6565
# Directory Configuration and Structure
6666

6767
Directory structure of source code:
6868

69-
A new module "integration-tests" is added to the Maven project weblogic-kubernetes-operator.
69+
A new module "integration-tests" is added to the Maven project `weblogic-kubernetes-operator`.
7070

71-
weblogic-kubernetes-operator/integration-tests - location of module pom.xml
72-
weblogic-kubernetes-operator/integration-tests/src/test/java - integration test(JUnit) classes and utility classes
73-
weblogic-kubernetes-operator/integration-tests/src/test/resources - properties, yaml files(see Configuration Files section) and other scripts
71+
`weblogic-kubernetes-operator/integration-tests` - location of module pom.xml
72+
`weblogic-kubernetes-operator/integration-tests/src/test/java` - integration test(JUnit) classes and utility classes
73+
`weblogic-kubernetes-operator/integration-tests/src/test/resources` - properties, YAML files (see Configuration Files section) and other scripts.
7474

7575
Directory structure used for the test run:
7676

77-
Main external env vars:
77+
Main external `env vars`:
7878

7979
| Variable | Description |
8080
| --- | --- |
8181
| RESULT_ROOT | Root path for local test files. |
8282
| PV_ROOT | Root NFS path behind PV/C directories. This must have permissions suitable for WL pods to add files |
8383

84-
Defaults for RESULT_ROOT & PV_ROOT:
84+
Defaults for `RESULT_ROOT` & `PV_ROOT`:
8585

8686
| Test Mode | RESULT_ROOT | PV_ROOT | Where initialized |
8787
| --- | --- | --- | --- |
@@ -173,7 +173,7 @@ Integration test classes:
173173

174174
When the integration test class ITOperator is executed, staticPrepare() method is called once before any of the test methods in the class and staticUnPrepare() method once at the end.
175175

176-
staticPrepare() - initializes the application properties from OperatorIT.properties and creates resultRoot, pvRoot, userprojectsDir directories by calling initialize() method from the base class BaseTest.
176+
staticPrepare() - initializes the application properties from OperatorIT.properties and creates resultRoot, pvRoot, userprojectsDir directories by calling initialize() method from the base class BaseTest.
177177

178178
staticUnPrepare() - releases the cluster lease on wercker env.
179179

@@ -233,7 +233,7 @@ WERCKER=true:
233233
Successful run will have the output like below:
234234
```
235235
[INFO] Reactor Summary:
236-
[INFO]
236+
[INFO]
237237
[INFO] weblogic-kubernetes-operator ....................... SUCCESS [ 0.305 s]
238238
[INFO] operator-model ..................................... SUCCESS [ 10.274 s]
239239
[INFO] operator-swagger ................................... SUCCESS [ 0.436 s]
@@ -251,19 +251,19 @@ Successful run will have the output like below:
251251
Failed run will have the output like
252252
```
253253
254-
[INFO]
254+
[INFO]
255255
[INFO] Results:
256-
[INFO]
257-
[ERROR] Errors:
256+
[INFO]
257+
[ERROR] Errors:
258258
[ERROR] ITOperator.testDomainOnPVUsingWLST:145 ? Runtime FAILURE: Couldn't create serv...
259-
[INFO]
259+
[INFO]
260260
[ERROR] Tests run: 9, Failures: 0, Errors: 1, Skipped: 0
261-
[INFO]
262-
[INFO]
261+
[INFO]
262+
[INFO]
263263
[INFO] --- maven-failsafe-plugin:2.20.1:verify (integration-tests) @ operator-integration-tests ---
264264
[INFO] ------------------------------------------------------------------------
265265
[INFO] Reactor Summary:
266-
[INFO]
266+
[INFO]
267267
[INFO] Build Tools ........................................ SUCCESS [ 1.193 s]
268268
[INFO] weblogic-kubernetes-operator ....................... SUCCESS [ 2.671 s]
269269
[INFO] json-schema ........................................ SUCCESS [ 14.917 s]
@@ -306,7 +306,7 @@ $RESULT_ROOT/acceptance_test_tmp is archived under $RESULT_ROOT/acceptance_test_
306306

307307
$PV_ROOT/acceptance_test_pv is archived under $PV_ROOT/acceptance_test_pv_archive
308308

309-
On Wercker, these logs can be downloaded by clicking "Download artifact" on cleanup and store step.
309+
On Wercker, these logs can be downloaded by clicking "Download artifact" on cleanup and store step.
310310

311311
# How to add a new test
312312

@@ -319,3 +319,18 @@ ITOperator.java - take a look at this test for reference
319319
# Future enhancement
320320

321321
Add functional tests
322+
323+
## Troubleshooting
324+
325+
The integration tests are not completely independent of the environment.
326+
327+
You may run into one or more of the following errors when you attempt to execute the command:
328+
```
329+
mvn clean verify -P java-integration-tests 2>&1 | tee log.txt
330+
```
331+
1. `[ERROR] No permision to create directory /scratch/...`
332+
333+
There are a couple ways to resolve this issue:
334+
335+
* Create a world writable directory named `/scratch`.
336+
* Create some other world writable directory and then define the environment variables `RESULT_ROOT` and `PV_ROOT` to point to that directory. If you want, you can create two directories to keep things separated. See [Directory Configuration and Structure](#directory-configuration-and-structure) for more details.

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public void testAdminT3ChannelWithJMS(Domain domain) throws Exception {
251251
c.close();
252252
logger.info("Done - testAdminT3ChannelWithJMS");
253253
}
254+
254255
/**
255256
* Restarting the domain should not have any impact on Operator managing the domain, web app load
256257
* balancing and node port service
@@ -271,6 +272,7 @@ public void testDomainLifecyle(Operator operator, Domain domain) throws Exceptio
271272
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
272273
}
273274
domain.verifyAdminServerExternalService(getUsername(), getPassword());
275+
domain.verifyHasClusterServiceChannelPort("TCP", 8011, TESTWEBAPP + "/");
274276
logger.info("Done - testDomainLifecyle");
275277
}
276278

@@ -315,22 +317,23 @@ public void testClusterScaling(Operator operator, Domain domain) throws Exceptio
315317

316318
// make sure cluster service endpoint is updated with the scaled up servers before verifying
317319
// load balancing
318-
int i = 0;
319-
while (i < BaseTest.getMaxIterationsPod()) {
320-
int numberOfServersInEndpoint =
321-
domain.getNumberOfServersInClusterServiceEndpoint((String) domainMap.get("clusterName"));
322-
if (replicaCnt != numberOfServersInEndpoint) {
323-
// check for last iteration
324-
if (i == (BaseTest.getMaxIterationsPod() - 1)) {
325-
throw new RuntimeException("FAILURE: Cluster Serice Endpoint is not updated");
326-
}
327-
Thread.sleep(BaseTest.getWaitTimePod() * 1000);
328-
i++;
329-
} else {
330-
logger.info("Number of servers addresses in endpoint is same as replica count ");
331-
break;
332-
}
333-
}
320+
// int i = 0;
321+
// while (i < BaseTest.getMaxIterationsPod()) {
322+
// int numberOfServersInEndpoint =
323+
// domain.getNumberOfServersInClusterServiceEndpoint((String)
324+
// domainMap.get("clusterName"));
325+
// if (replicaCnt != numberOfServersInEndpoint) {
326+
// // check for last iteration
327+
// if (i == (BaseTest.getMaxIterationsPod() - 1)) {
328+
// throw new RuntimeException("FAILURE: Cluster Serice Endpoint is not updated");
329+
// }
330+
// Thread.sleep(BaseTest.getWaitTimePod() * 1000);
331+
// i++;
332+
// } else {
333+
// logger.info("Number of servers addresses in endpoint is same as replica count ");
334+
// break;
335+
// }
336+
// }
334337
// commenting the load balance check, bug 29325139
335338
// domain.verifyWebAppLoadBalancing(TESTWEBAPP);
336339

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ public void testAutoAndCustomSitConfigOverrides() throws Exception {
417417
// load input yaml to map and add configOverrides
418418
Map<String, Object> domainMap = TestUtils.loadYaml(domainonpvwlstFile);
419419
domainMap.put("configOverrides", "sitconfigcm");
420+
domainMap.put(
421+
"configOverridesFile",
422+
"/integration-tests/src/test/resources/domain-home-on-pv/customsitconfig");
420423
domainMap.put("domainUID", "customsitdomain");
421424
domainMap.put("adminNodePort", new Integer("30704"));
422425
domainMap.put("t3ChannelPort", new Integer("30051"));

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

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ public void verifyServersReady() throws Exception {
240240
}
241241
}
242242
}
243+
243244
/**
244245
* verify nodeport by accessing admin REST endpoint
245246
*
@@ -286,6 +287,73 @@ public void verifyAdminServerExternalService(String username, String password) t
286287
}
287288
}
288289

290+
/**
291+
* Verify that we have the channel set for the cluster
292+
*
293+
* @param protocol
294+
* @param port
295+
* @param path
296+
* @throws Exception
297+
*/
298+
public void verifyHasClusterServiceChannelPort(String protocol, int port, String path)
299+
throws Exception {
300+
301+
/* Make sure the service exists in k8s */
302+
if (!TestUtils.checkHasServiceChannelPort(
303+
this.getDomainUid() + "-cluster-" + this.clusterName, domainNS, protocol, port)) {
304+
throw new RuntimeException(
305+
"FAILURE: Cannot find channel port in cluster, but expecting one: "
306+
+ port
307+
+ "/"
308+
+ protocol);
309+
}
310+
311+
/*
312+
* Construct a curl command that will be run via kubectl exec on the admin server
313+
*/
314+
StringBuffer curlCmd =
315+
new StringBuffer(
316+
"kubectl exec " + this.getDomainUid() + "-" + this.adminServerName + " /usr/bin/curl ");
317+
318+
/*
319+
* Make sure we can reach the port,
320+
* first via each managed server URL
321+
*/
322+
for (int i = 1; i <= TestUtils.getClusterReplicas(domainUid, clusterName, domainNS); i++) {
323+
StringBuffer serverAppUrl = new StringBuffer("http://");
324+
serverAppUrl
325+
.append(this.getDomainUid() + "-" + managedServerNameBase + i)
326+
.append(":")
327+
.append(port)
328+
.append("/");
329+
serverAppUrl.append(path);
330+
331+
callWebAppAndWaitTillReady(
332+
new StringBuffer(curlCmd.toString())
333+
.append(serverAppUrl.toString())
334+
.append(" -- --write-out %{http_code} -o /dev/null")
335+
.toString());
336+
}
337+
338+
/*
339+
* Make sure we can reach the port,
340+
* second via cluster URL which should round robin through each managed server.
341+
* Use the callWebAppAndCheckForServerNameInResponse method with verifyLoadBalancing
342+
* enabled to verify each managed server is responding.
343+
*/
344+
StringBuffer clusterAppUrl = new StringBuffer("http://");
345+
clusterAppUrl
346+
.append(this.getDomainUid() + "-cluster-" + this.clusterName)
347+
.append(":")
348+
.append(port)
349+
.append("/");
350+
clusterAppUrl.append(path);
351+
352+
// execute curl and look for each managed server name in response
353+
callWebAppAndCheckForServerNameInResponse(
354+
new StringBuffer(curlCmd.toString()).append(clusterAppUrl.toString()).toString(), true);
355+
}
356+
289357
/**
290358
* deploy webapp using nodehost and nodeport
291359
*
@@ -422,8 +490,8 @@ public void callWebAppAndVerifyLoadBalancing(String webappName, boolean verifyLo
422490
StringBuffer curlCmdResCode = new StringBuffer(curlCmd.toString());
423491
curlCmdResCode.append(" --write-out %{http_code} -o /dev/null");
424492

425-
logger.info("Curd cmd with response code " + curlCmdResCode);
426-
logger.info("Curd cmd " + curlCmd);
493+
logger.info("Curl cmd with response code " + curlCmdResCode);
494+
logger.info("Curl cmd " + curlCmd);
427495

428496
// call webapp iteratively till its deployed/ready
429497
callWebAppAndWaitTillReady(curlCmdResCode.toString());
@@ -1135,9 +1203,12 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
11351203
domainMap.values().removeIf(Objects::isNull);
11361204

11371205
// create config map and secret for custom sit config
1138-
if (domainMap.get("configOverrides") != null) {
1206+
if ((domainMap.get("configOverrides") != null)
1207+
&& (domainMap.get("configOverridesFile") != null)) {
11391208
// write hostname in config file for public address
11401209

1210+
String configOverridesFile = domainMap.get("configOverridesFile").toString();
1211+
11411212
String cmd =
11421213
"kubectl -n "
11431214
+ domainNS
@@ -1147,7 +1218,7 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
11471218
+ domainMap.get("configOverrides")
11481219
+ " --from-file "
11491220
+ BaseTest.getProjectRoot()
1150-
+ "/integration-tests/src/test/resources/domain-home-on-pv/customsitconfig";
1221+
+ configOverridesFile;
11511222
ExecResult result = ExecCommand.exec(cmd);
11521223
if (result.exitValue() != 0) {
11531224
throw new RuntimeException(

0 commit comments

Comments
 (0)