Skip to content

Commit 673800b

Browse files
authored
Merge pull request #907 from oracle/domainhomeinimage-tests
READY TO MERGE: Adding domain home in image tests
2 parents 91f9a29 + 6d8d0fc commit 673800b

File tree

10 files changed

+411
-44
lines changed

10 files changed

+411
-44
lines changed

integration-tests/README.md

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Wercker runs only Quick test use cases, Jenkins runs both Quick and Full test us
1616

1717
Java integration tests cover the below use cases:
1818

19-
Quick test use cases
19+
Quick test Configuration & Use Cases -
2020

2121
| | |
2222
| --- | --- |
@@ -42,25 +42,28 @@ Also the below use cases are covered for Quick test:
4242
9. Verify the liveness probe by killing managed server 1 process 3 times to kick pod auto-restart.
4343
10. Shutdown the domain by changing domain `serverStartPolicy` to `NEVER`.
4444

45-
Full test use cases
45+
46+
Full test Configuration & Use Cases - Runs Quick test Configuration & Use cases and the below
4647

4748
| | |
4849
| --- | --- |
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. |
50+
| Operator Configuration | operator2 deployed in weblogic-operator2 namespace and manages domains test2 namespace |
51+
| Domain Configuration | Domain on PV using WDT <p> Domain home in image using WLST <p> Domain home in image using WDT <p> Domain with serverStartPolicy ADMIN_ONLY <p> Domain with auto and custom situational configuration <p> Two domains managed by two operators <p> Domain with Recycle weblogicDomainStorageReclaimPolicy <p> Domain with default sample values |
5152

5253

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

5556
| Domain | Use Case |
5657
| --- | --- |
5758
| 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-
59+
| 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. |
60+
| 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 |
61+
| 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. |
62+
| Domain with Recycle policy | create domain with pvReclaimPolicy="Recycle" Verify that the PV is deleted once the domain and PVC are deleted |
63+
| Domain with default sample values | create domain using mostly default values for inputs |
64+
| Domain home in image using WLST | cluster scaling |
65+
| Domain home in image using WDT | cluster scaling |
66+
6467

6568
# Directory Configuration and Structure
6669

@@ -166,10 +169,21 @@ Certain properties like weblogicDomainStoragePath, image, externalOperatorCert a
166169

167170
# How does it work
168171

169-
When the tests are run manually with mvn command on hosted Linux, WebLogic image store/oracle/weblogic:12.2.1.3 is pulled from docker hub or uses local image if one exists. Server jre images are pulled from a local repository wlsldi-v2.docker.oraclecorp.com. Operator image is built with the git branch from where the mvn command is executed.
170-
All the tests that start with IT*.java are run. The test builds the operator, runs a series of tests and archives the results into tar.gz files upon completion.
171-
172-
Integration test classes:
172+
When the tests are run with mvn command,
173+
- cleanup the test tmp files, PV dir and k8s artifacts created for the test if any
174+
- creates the required secrets to pull the WL image from docker hub
175+
- Operator image is built with the git branch from where the mvn command is executed.
176+
- creates Operator and verifies operator is running
177+
- creates Domain crd using samples
178+
- verifies the domain is started and servers are ready, services are created
179+
- executes the basic and advanced use cases
180+
- shutdown the domain
181+
- archive logs and results
182+
- cleanup the tmp files, PV dir and k8s artifacts created for the test
183+
184+
All the tests that start with IT*.java in integration-tests/src/test/java are run.
185+
186+
**Integration test classes:**
173187

174188
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.
175189

@@ -179,27 +193,43 @@ staticUnPrepare() - releases the cluster lease on wercker env.
179193

180194
test methods - testDomainOnPVUsingWLST, testDomainOnPVUsingWDT, testTwoDomainsManagedByTwoOperators, testCreateDomainWithStartPolicyAdminOnly, testCreateDomainPVReclaimPolicyRecycle, testCreateDomainWithDefaultValuesInSampleInputs, testAutoAndCustomSitConfigOverrides, testOperatorRESTIdentityBackwardCompatibility, testOperatorRESTUsingCertificateChain
181195

182-
Utility classes:
196+
**Utility classes:**
183197

184-
Operator - contains methods to create/destroy operator, verify operator created, scale using rest api, etc
185-
Domain - contains methods to create/destroy domain, verify domain created,deploy webapp, load balancing, etc
186-
PersistentVolume - to create PV
187-
LoadBalancer - to create load balancer
188-
Secret - to create secret
198+
Operator - constructor takes yaml file with operator properties and generates operator valus yaml with required properties and certs, creates service account, namespace and calls helm install using the generated values yaml file. Also contains methods to delete operator release, verify operator created and ready, scale using rest api, verify a given domain via rest, verify external rest service, etc <p>
199+
Domain - constructor takes Map with domain, LB, PV properties and creates domain crd, LB operator/ingress and PV artifacts using the sample scripts provided in the project. Also contains helper methods to destroy domain by deleting domain crd, verify domain created and servers are ready, deploy webapp, verify load balancing of http requests, etc <p>
200+
PersistentVolume - runs k8s job to create PV directory and creates PV and PVC using sample scripts <p>
201+
LoadBalancer - creates load balancer, currently TREFIK and VOYAGER are supported <p>
202+
Secret - creates a k8s secret <p>
203+
TestUtils - mostly runs kubectl commands. Contains utility methods to check if a pod is created, ready, deleted, service created, get pod restart cnt, get cluster replica, delete PVC, check PV released, create rbac policy, create wldf module, etc. <p>
204+
ExecCommand - Class for executing shell commands from java <p>
205+
ExecResult - Class that holds the results of using java to exec a command (i.e. exit value, stdout and stderr) <p>
206+
K8sTestUtils - uses k8s java client api, this is used only for delete domain use cases for now. <p>
189207

190208
# How to run the Java integration tests
191209

192210
* Maven and latest Git should be in PATH
193211
* export JAVA_HOME
194-
195-
Command to run the tests:
212+
* export WEBLOGIC_IMAGE_NAME and WEBLOGIC_IMAGE_TAG if different from store/oracle/weblogic and 12.2.1.3
213+
* Setup docker access to WebLogic 12c Images
214+
215+
Method 1
216+
- Setup a personal account on hub.docker.com
217+
- Then sign in to hub.docker.com and signup for access to WebLogic 12c Images via https://hub.docker.com/_/oracle-weblogic-server-12c
218+
- Then export the following before running the tests:
219+
```
220+
export DOCKER_USERNAME=<docker_username>
221+
export DOCKER_PASSWORD=<docker_password>
222+
export DOCKER_EMAIL=<docker_email>
223+
```
224+
225+
Method 2
226+
- Make sure the weblogic image i.e. store/oracle/weblogic:12.2.1.3 already exists locally in a docker repository the k8s cluster can access
227+
- Make sure the weblogic image has patch p29135930 (required for the WebLogic Kubernetes Operator).
228+
- If not, see [https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-patch-wls-for-k8s].
229+
230+
231+
* Command to run the tests:
196232
```
197-
export DOCKER_USERNAME=<docker_username>
198-
export DOCKER_PASSWORD=<docker_password>
199-
export DOCKER_EMAIL=<docker_email>
200-
or
201-
make sure the weblogic image i.e. store/oracle/weblogic:12.2.1.3 already exists locally
202-
203233
mvn clean verify -P java-integration-tests 2>&1 | tee log.txt
204234
```
205235

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ public void testOperatorRESTUsingCertificateChain() throws Exception {
521521
*
522522
* @throws Exception
523523
*/
524-
// @Test
524+
@Test
525525
public void testDomainInImageUsingWLST() throws Exception {
526526
Assume.assumeFalse(QUICKTEST);
527527
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
@@ -553,7 +553,7 @@ public void testDomainInImageUsingWLST() throws Exception {
553553
*
554554
* @throws Exception
555555
*/
556-
// @Test
556+
@Test
557557
public void testDomainInImageUsingWDT() throws Exception {
558558
Assume.assumeFalse(QUICKTEST);
559559
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class Domain {
5757
private int loadBalancerWebPort = 30305;
5858
private String userProjectsDir = "";
5959
private String projectRoot = "";
60-
private boolean ingressPerDomain = false;
60+
private boolean ingressPerDomain = true;
6161

6262
private String createDomainScript = "";
6363
private String inputTemplateFile = "";

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ private void generateInputYaml() throws Exception {
314314
sb.append(generatedInputYamlFile);
315315
logger.info("Invoking " + sb.toString());
316316
ExecCommand.exec(sb.toString());
317+
318+
/* String content = new String(Files.readAllBytes(Paths.get(generatedInputYamlFile)));
319+
logger.info("Content of weblogic-operator-values.yaml \n" + content); */
317320
}
318321

319322
private void runCommandInLoop(String command) throws Exception {
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

4+
import time as systime
5+
46
connect(sys.argv[1],sys.argv[2],sys.argv[3])
5-
deploy(sys.argv[4],sys.argv[5],sys.argv[6],upload='false',remote='false')
7+
deploy(sys.argv[4],sys.argv[5],sys.argv[6],upload='false',remote='false')
8+
#systime.sleep(15)
9+
10+
#cd ('AppDeployments')
11+
#myapps=cmo.getAppDeployments()
12+
13+
#for appName in myapps:
14+
# domainConfig()
15+
# cd ('/AppDeployments/'+appName.getName()+'/Targets')
16+
# mytargets = ls(returnMap='true')
17+
# domainRuntime()
18+
# cd('AppRuntimeStateRuntime')
19+
# cd('AppRuntimeStateRuntime')
20+
# for targetinst in mytargets:
21+
# curstate4=cmo.getCurrentState(appName.getName(),targetinst)
22+
# print '-----------', curstate4, '-----------', appName.getName()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ initialManagedServerReplicas: 2
88
exposeAdminT3Channel: true
99
exposeAdminNodePort: true
1010
domainHomeImageBuildPath: ./docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt
11-
domainHomeImageBase: "store/oracle/weblogic:12.2.1.3"
11+
domainHomeImageBase: "store/oracle/weblogic:12.2.1.3"
12+
logHomeOnPV: true

integration-tests/src/test/resources/setupenv.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ function pull_tag_images {
8787
echo "secret $IMAGE_PULL_SECRET_WEBLOGIC was not created successfully"
8888
exit 1
8989
fi
90-
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
91-
docker pull $IMAGE_NAME_WEBLOGIC:$IMAGE_TAG_WEBLOGIC
90+
# docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
91+
# docker pull $IMAGE_NAME_WEBLOGIC:$IMAGE_TAG_WEBLOGIC
9292
fi
9393
set -x
9494
echo "Pull and tag the images we need"

integration-tests/src/test/resources/statedump.sh

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ function state_dump {
1616
local PROJECT_ROOT="$PROJECT_ROOT"
1717
local SCRIPTPATH="$PROJECT_ROOT/src/integration-tests/bash"
1818
local LEASE_ID="$LEASE_ID"
19+
local ARCHIVE_DIR="$RESULT_ROOT/acceptance_test_pv_archive"
20+
local ARCHIVE_FILE="IntSuite.`date '+%Y%m%d%H%M%S'`.jar"
21+
local ARCHIVE="$ARCHIVE_DIR/$ARCHIVE_FILE"
1922

2023
if [ ! -d "$RESULT_DIR" ]; then
2124
echo State dump exiting early. RESULT_DIR \"$RESULT_DIR\" does not exist or is not a directory.
@@ -60,6 +63,8 @@ function state_dump {
6063
done
6164
done
6265

66+
mkdir -p $ARCHIVE_DIR || fail Could not archive, could not create target directory \'$ARCHIVE_DIR\'.
67+
6368
# Get various k8s resource describes and redirect/copy to files
6469

6570
set +x
@@ -85,17 +90,44 @@ function state_dump {
8590
done
8691
done
8792
set -x
88-
93+
8994
# use a job to archive PV, /scratch mounts to PV_ROOT in the K8S cluster
9095
echo "Archiving pv directory using a kubernetes job. Look for it on k8s cluster in $PV_ROOT/acceptance_test_pv_archive"
9196
local outfile=${DUMP_DIR}/archive_pv_job.out
92-
$SCRIPTPATH/job.sh "/scripts/archive.sh /scratch/acceptance_test_pv /scratch/acceptance_test_pv_archive" 2>&1 | tee ${outfile}
93-
if [ "$?" = "0" ]; then
94-
echo Job complete.
97+
98+
if [ "$WERCKER" = "true" ]; then
99+
$SCRIPTPATH/job.sh "/scripts/archive.sh /scratch/acceptance_test_pv /scratch/acceptance_test_pv_archive" 2>&1 | tee ${outfile}
100+
if [ "$?" = "0" ]; then
101+
echo Job complete.
102+
else
103+
echo Job failed. See ${outfile}.
104+
fi
95105
else
96-
echo Job failed. See ${outfile}.
106+
107+
$SCRIPTPATH/krun.sh -t 300 -d ${RESULT_DIR} -m "${PV_ROOT}:/sharedparent" -c 'jar cf /sharedparent/pvarchive.jar /sharedparent/acceptance_test_pv' 2>&1 | tee ${outfile}
108+
if [ "$?" = "0" ]; then
109+
$SCRIPTPATH/krun.sh -t 300 -d ${RESULT_DIR} -m "${PV_ROOT}:/sharedparent" -c 'base64 /sharedparent/pvarchive.jar' > $RESULT_DIR/pvarchive.b64 2>&1
110+
if [ "$?" = "0" ]; then
111+
base64 -di $RESULT_DIR/pvarchive.b64 > $ARCHIVE
112+
if [ "$?" = "0" ]; then
113+
echo Run complete. Archived to $ARCHIVE
114+
else
115+
echo Run failed.
116+
fi
117+
else
118+
# command failed
119+
cat $RESULT_DIR/pvarchive.b64 | head -100
120+
fi
121+
# rm $RESULT_DIR/pvarchive.b64
122+
else
123+
echo Job failed. See ${outfile}.
124+
fi
97125
fi
126+
127+
128+
98129

130+
99131
if [ ! "$LEASE_ID" = "" ]; then
100132
# release the lease if we own it
101133
${SCRIPTPATH}/lease.sh -d "$LEASE_ID" 2>&1 | tee ${RESULT_DIR}/release_lease.out
@@ -112,7 +144,7 @@ function state_dump {
112144

113145
# now archive all the local test files
114146
$SCRIPTPATH/archive.sh "${RESULT_DIR}" "${RESULT_DIR}_archive"
115-
147+
116148
echo Done with state dump
117149
}
118150

src/integration-tests/bash/cleanup.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ USER_PROJECTS_DIR="$RESULT_DIR/user-projects"
6161
TMP_DIR="$RESULT_DIR/cleanup_tmp"
6262
JOB_NAME="weblogic-command-job"
6363

64+
6465
function fail {
6566
echo @@ cleanup.sh: Error "$@"
6667
exit 1
@@ -346,17 +347,24 @@ SUCCESS="$?"
346347

347348
if [ "${DELETE_FILES:-true}" = "true" ]; then
348349

349-
# Delete pv directories using a job (/scratch maps to PV_ROOT on the k8s cluster machines).
350+
# Delete pv directories using a run (/sharedparent maps to PV_ROOT on the k8s cluster machines).
350351

351-
echo @@ Launching job to delete all pv contents. This runs in the k8s cluster, /scratch mounts PV_ROOT.
352-
$SCRIPTPATH/job.sh "rm -fr /scratch/acceptance_test_pv"
352+
echo @@ Launching run to delete all pv contents. This runs in the k8s cluster, /sharedparent mounts PV_ROOT.
353+
# $SCRIPTPATH/job.sh "rm -fr /scratch/acceptance_test_pv"
354+
if [ "$WERCKER" = "true" ]; then
355+
$SCRIPTPATH/job.sh "rm -fr /scratch/acceptance_test_pv"
356+
else
357+
$SCRIPTPATH/krun.sh -m "${PV_ROOT}:/sharedparent" -c 'rm -fr /sharedparent/acceptance_test_pv'
358+
fi
353359
[ "$?" = "0" ] || SUCCESS="1"
360+
echo @@ SUCCESS=$SUCCESS
354361

355362
# Delete old test files owned by the current user.
356363

357364
echo @@ Deleting local $RESULT_DIR contents.
358365
rm -fr $RESULT_ROOT/acceptance_test_tmp
359366
[ "$?" = "0" ] || SUCCESS="1"
367+
echo @@ SUCCESS=$SUCCESS
360368

361369
echo @@ Deleting /tmp/test_suite.\* files.
362370
rm -f /tmp/test_suite.*

0 commit comments

Comments
 (0)