Skip to content

Commit 0076ec5

Browse files
adding readme.md
1 parent 38584db commit 0076ec5

File tree

1 file changed

+319
-0
lines changed

1 file changed

+319
-0
lines changed

integration-tests/README.md

Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
# Integration Tests for Operator
2+
3+
This documentation describes the functional use cases that are covered in integration testing for Weblogic Operator. The tests are written in java(Junit tests) and driven by maven profile. Currently, run.sh is used to run integration tests for Operator. All the use cases covered in run.sh will be covered in java integration tests. Currently, QUICK_TEST use cases and some of non-quick test(till domain4) use cases are covered in java tests.
4+
5+
# Environments
6+
7+
The tests currently runs 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".
8+
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/
12+
13+
# Use Cases
14+
15+
Currently java integration tests cover only QUICK_TEST use cases from run.sh. The below are the use cases:
16+
17+
create operator operator1 which manages default and test1 namespaces, verify its deployed successfully, pod created, operator Ready and verify external REST service if configured
18+
create domain domain1 in default namespace and verify the pods, services are created and servers are in Ready
19+
verify admin external service by accessing admin REST endpoint with nodeport in URL
20+
verify admin t3 channel port by exec into the admin pod and deploying webapp using the channel port for WLST
21+
verify web app load balancing – TO DO, Apache, Voyager
22+
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
23+
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.)
24+
Operator life cycle(destroy and create) should not impact the running domain
25+
26+
Non-quick test use cases
27+
28+
keep the first domain and operator running
29+
create another domain domain2 in default namespace and verify the domain by doing the checks 2 - 5 listed in quick test
30+
destroy domain domain2
31+
create another domain domain3 in test1 namespace and verify the domain by doing the checks 2 - 5 listed in quick test
32+
destroy domain domain3
33+
create another operator operator2 which manages test2 namespace and verify domain1 is not affected
34+
create another domain domain4 in test2 namespace and verify the domain by doing the checks 2 - 5 listed in quick test
35+
verify scaling for domain4 cluster from 2 to 3 servers and back to 2, plus verify no impact on domain1
36+
cycle domain1 down and back up, plus verify no impact on domain4
37+
38+
create domain5 in the default namespace with startupControl="ADMIN", and verify that only admin server is created. on Jenkins, this domain will also test NFS instead of HOSTPATH PV storage – all the remaining use cases are covered in QA functional tests, so not adding these tests or will be added later.
39+
40+
create domain6 in the default namespace with pvReclaimPolicy="Recycle", and verify that the PV is deleted once the domain and PVC are deleted
41+
42+
test managed server 1 pod auto-restart in domain1
43+
44+
destroy domain1
45+
46+
test that create domain fails when its pv is already populated by a shutdown domain
47+
48+
49+
# Directory Configuration and Structure
50+
51+
java integration tests are in feature/java-integration-tests branch on weblogic-kubernetes-operator project. Merged to develop branch.
52+
53+
Directory structure of source code:
54+
55+
A new module "integration-tests" is added to the maven project weblogic-kubernetes-operator.
56+
57+
weblogic-kubernetes-operator/integration-tests - location of module pom.xml
58+
weblogic-kubernetes-operator/integration-tests/src/test/java - integration test(junit) classes and utility classes
59+
weblogic-kubernetes-operator/integration-tests/src/test/resources - properties files(see Configuration Files section) and other scripts
60+
61+
Directory structure used for the test run:
62+
63+
Main external env vars:
64+
65+
RESULT_ROOT Root path for local test files.
66+
PV_ROOT Root NFS path behind PV/C directories. This must have permissions suitable for WL pods to add files (default UID 1000 group ???)
67+
68+
Defaults for RESULT_ROOT & PV_ROOT:
69+
70+
| Test Mode | RESULT_ROOT | PV_ROOT | Where initialized |
71+
| --- | --- | --- | --- |
72+
| stand-alone | /scratch/$USER/wl_k8s_test_results | <--same | test defaults |
73+
| Jenkins | /scratch/k8s_dir | <--same | jenkins configuration |
74+
| Wercker | /pipeline/output/k8s_dir | /scratch | wercker.yml |
75+
76+
77+
'Physical' subdirectories created by test:
78+
Local tmp files: RESULT_ROOT/acceptance_test_tmp/...
79+
80+
PV dirs K8S NFS: PV_ROOT/acceptance_test_pv/persistentVolume-${domain_uid}/...
81+
82+
Archives of above: PV_ROOT/acceptance_test_pv_archive/...
83+
RESULT_ROOT/acceptance_test_tmp_archive/...
84+
85+
'Logical' to 'Physical' K8S PV/PVC mappings:
86+
'Logical' 'Actual'
87+
job.sh job: /scratch <--> PV_ROOT on K8S machines
88+
domain pod: /shared <--> PV_ROOT/acceptance_test_pv/persistentVolume-${domain_uid} on K8S machines
89+
90+
# Configuration Files
91+
92+
A module "integration-tests" is added in maven weblogic-kubernetes-operator project.
93+
94+
Below configuration files are used:
95+
src/integration-tests/resources/OperatorIT.properties - This file is used for configuring common attributes for all integration tests
96+
baseDir=/scratch
97+
#wls admin user
98+
username=weblogic
99+
password=welcome1
100+
maxIterationsPod=50
101+
waitTimePod=5
102+
103+
src/integration-tests/resources/ITFirstOperator.properties - customized properties for operator
104+
#any property can be provided here from create-weblogic-operator-inputs.yaml
105+
#for all the properties that are not defined here, the default values in create-weblogic-operator-inputs.yaml
106+
# used while generating the operator inputs yaml file
107+
108+
serviceAccount= weblogic-operator
109+
namespace= weblogic-operator1
110+
targetNamespaces= default
111+
#if SELF_SIGNED_CERT, externalSans value is set to the local host name if not provided here
112+
externalRestOption= SELF_SIGNED_CERT
113+
elkIntegrationEnabled= false
114+
115+
src/integration-tests/resources/ITFirstDomain.properties - customized properties for domain
116+
#any property can be provided here from create-weblogic-domain-inputs.yaml
117+
#for all the properties that are not defined here, the default values in create-weblogic-domain-inputs.yaml are
118+
# used while generating the domain inputs yaml file
119+
120+
adminServerName= admin-server
121+
domainName= base_domain
122+
domainUID= domain1
123+
startupControl= AUTO
124+
clusterName= cluster-1
125+
configuredManagedServerCount= 4
126+
initialManagedServerReplicas= 2
127+
managedServerNameBase= managed-server
128+
#weblogicDomainStoragePath will be ignored, PV dir will be created at /<baseDir>/<USER>/acceptance_test_pv
129+
#weblogicDomainStoragePath= /scratch/external-domain-home/pv001/
130+
secretName= domain1-weblogic-credentials
131+
exposeAdminT3Channel= true
132+
exposeAdminNodePort= true
133+
namespace= default
134+
javaOptions= -Dweblogic.StdoutDebugEnabled=false
135+
136+
Certain properties like weblogicDomainStoragePath, weblogicOperatorImage, externalSans are populated at run time.
137+
138+
139+
# How does it work
140+
141+
When the tests are run manually with mvn command on hosted linux, weblogic image and server jre images are pulled from a local repository. Operator image is built with the git branch from where the mvn command is executed.
142+
All the tests that start with IT*.java are ran. The test builds the operator, runs a series of tests and archives the results into tar.gz files upon completion.
143+
144+
Integration test classes:
145+
146+
When the integration test class ITFirstDomain is executed, staticPrepare() method is called once before any of the test methods in the class and staticUnPrepare() method once at the end.
147+
148+
staticPrepare() - initializes the application properties from OperatorIT.properties and creates resultRoot, pvRoot, userprojectsDir directories by calling initialize() method from the base class BaseTest. It also creates the operator and domain objects which are used later in the test methods.
149+
150+
staticUnPrepare() - releases the cluster lease on wercker env.
151+
152+
test methods - testAdminServerExternalService, testAdminT3Channel, testDomainLifecyle, testClusterScaling, testOperatorLifecycle
153+
154+
Utility classes:
155+
156+
Operator - contains methods to create/destroy operator, verify operator created, scale using rest api, etc
157+
158+
Domain - contains methods to create/destroy domain, verify domain created,deploy webapp, load balancing, etc
159+
PersistentVolume - to create PV
160+
Secret - to create secret
161+
162+
# How to run the java integration tests
163+
164+
Maven and latest Git should be in PATH
165+
166+
export JAVA_HOME
167+
168+
set the optional env vars described below
169+
170+
The tests accepts optional env var overrides:
171+
172+
RESULT_ROOT The root directory to use for the tests temporary files.
173+
See "Directory Configuration and Structure" below for
174+
defaults and a detailed description of test directories.
175+
176+
PV_ROOT The root directory on the kubernetes cluster
177+
used for persistent volumes.
178+
See "Directory Configuration and Structure" below for
179+
defaults and a detailed description of test directories.
180+
181+
QUICKTEST When set to "true", limits testing to a subset of
182+
of the tests.
183+
184+
WERCKER Set to true if invoking from Wercker, set
185+
to false or "" if running stand-alone or from Jenkins.
186+
Default is "".
187+
188+
JENKINS Set to true if invoking from Jenkins, set
189+
to false or "" if running stand-alone or from Wercker.
190+
Default is "".
191+
192+
NODEPORT_HOST DNS name of a Kubernetes worker node.
193+
Default is the local host's hostname.
194+
195+
BRANCH_NAME Git branch name.
196+
Default is determined by calling 'git branch'.
197+
198+
LEASE_ID Set to a unique value to (A) periodically renew a lease on
199+
the k8s cluster that indicates that no other test run
200+
should attempt to use the cluster, and (B)
201+
delete this lease when the test completes.
202+
203+
The following additional overrides are currently only used when
204+
WERCKER=true:
205+
206+
IMAGE_TAG_OPERATOR Docker image tag for operator.
207+
Default generated based off the BRANCH_NAME.
208+
209+
IMAGE_NAME_OPERATOR Docker image name for operator.
210+
Default is wlsldi-v2.docker.oraclecorp.com/weblogic-operator
211+
212+
IMAGE_PULL_POLICY_OPERATOR Default 'Never'.
213+
IMAGE_PULL_SECRET_OPERATOR Default ''.
214+
IMAGE_PULL_SECRET_WEBLOGIC Default ''.
215+
216+
mvn clean verify -P java-integration-tests 2>&1 | tee log.txt
217+
218+
Successful run will have the output like below:
219+
220+
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 970.765 s - in oracle.kubernetes.operator.ITSingleDomain
221+
[INFO]
222+
[INFO] Results:
223+
[INFO]
224+
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
225+
[INFO]
226+
[INFO]
227+
[INFO] --- maven-failsafe-plugin:2.20.1:verify (integration-tests) @ operator-integration-tests ---
228+
[INFO]
229+
[INFO] --- maven-failsafe-plugin:2.20.1:integration-test (acceptance-test) @ operator-integration-tests ---
230+
[INFO]
231+
[INFO] --- maven-failsafe-plugin:2.20.1:verify (acceptance-test) @ operator-integration-tests ---
232+
[INFO] ------------------------------------------------------------------------
233+
[INFO] Reactor Summary:
234+
[INFO]
235+
[INFO] weblogic-kubernetes-operator ....................... SUCCESS [ 0.472 s]
236+
[INFO] operator-model ..................................... SUCCESS [ 9.696 s]
237+
[INFO] operator-swagger ................................... SUCCESS [ 2.300 s]
238+
[INFO] operator-runtime ................................... SUCCESS [ 52.737 s]
239+
[INFO] operator-integration-tests ......................... SUCCESS [16:33 min]
240+
[INFO] ------------------------------------------------------------------------
241+
[INFO] BUILD SUCCESS
242+
[INFO] ------------------------------------------------------------------------
243+
[INFO] Total time: 17:39 min
244+
[INFO] Finished at: 2018-05-16T14:25:30-07:00
245+
[INFO] Final Memory: 54M/871M
246+
[INFO] ------------------------------------------------------------------------
247+
bash-4.2$
248+
249+
250+
Failed run will have the output
251+
252+
[ERROR] Tests run: 5, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 1,271.204 s <<< FAILURE! - in oracle.kubernetes.operator.ITSingleDomain
253+
[ERROR] testAdminT3Channel(oracle.kubernetes.operator.ITSingleDomain) Time elapsed: 145.59 s <<< ERROR!
254+
java.lang.RuntimeException: FAILURE: testwebapp did not return 200 status code, got 404
255+
at oracle.kubernetes.operator.ITSingleDomain.testAdminT3Channel(ITSingleDomain.java:84)
256+
257+
[ERROR] testDomainLifecyle(oracle.kubernetes.operator.ITSingleDomain) Time elapsed: 378.096 s <<< ERROR!
258+
java.lang.RuntimeException: FAILURE: testwebapp did not return 200 status code, got 404
259+
at oracle.kubernetes.operator.ITSingleDomain.testDomainLifecyle(ITSingleDomain.java:103)
260+
261+
[ERROR] testClusterScaling(oracle.kubernetes.operator.ITSingleDomain) Time elapsed: 223.707 s <<< ERROR!
262+
java.lang.RuntimeException: FAILURE: testwebapp did not return 200 status code, got 404
263+
at oracle.kubernetes.operator.ITSingleDomain.testClusterScaling(ITSingleDomain.java:144)
264+
265+
[INFO]
266+
[INFO] Results:
267+
[INFO]
268+
[ERROR] Errors:
269+
[ERROR] ITSingleDomain.testAdminT3Channel:84 » Runtime FAILURE: testwebapp did not ret...
270+
[ERROR] ITSingleDomain.testClusterScaling:144 » Runtime FAILURE: testwebapp did not re...
271+
[ERROR] ITSingleDomain.testDomainLifecyle:103 » Runtime FAILURE: testwebapp did not re...
272+
[INFO]
273+
[ERROR] Tests run: 5, Failures: 0, Errors: 3, Skipped: 0
274+
[INFO]
275+
[INFO]
276+
[INFO] --- maven-failsafe-plugin:2.20.1:verify (integration-tests) @ operator-integration-tests ---
277+
[INFO] ------------------------------------------------------------------------
278+
[INFO] Reactor Summary:
279+
[INFO]
280+
[INFO] weblogic-kubernetes-operator ....................... SUCCESS [ 0.756 s]
281+
[INFO] operator-model ..................................... SUCCESS [ 12.394 s]
282+
[INFO] operator-swagger ................................... SUCCESS [ 2.014 s]
283+
[INFO] operator-runtime ................................... SUCCESS [ 53.771 s]
284+
[INFO] operator-integration-tests ......................... FAILURE [21:35 min]
285+
[INFO] ------------------------------------------------------------------------
286+
[INFO] BUILD FAILURE
287+
[INFO] ------------------------------------------------------------------------
288+
[INFO] Total time: 22:44 min
289+
[INFO] Finished at: 2018-05-17T06:42:35-07:00
290+
[INFO] Final Memory: 55M/933M
291+
[INFO] ------------------------------------------------------------------------
292+
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:verify (integration-tests) on project operator-integration-tests: There are test failures.
293+
[ERROR]
294+
[ERROR] Please refer to /scratch/vmukkara/mychanges/weblogic-kubernetes-operator/integration-tests/target/failsafe-reports for the individual test results.
295+
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream
296+
297+
298+
Junit test results can be seen at "integration-tests/target/failsafe-reports/TEST-oracle.kubernetes.operator.ITSingleDomain.xml". This file shows how much time each test case took to run and the failed test results if any.
299+
300+
# Logging/Archiving
301+
302+
java utils logging is used, writes all the messages to console and java_test_suite.out in $RESULT_ROOT/acceptance_test_tmp directory.
303+
At the end of the test run, all pods logs, describes are logged in individual files and are written to state-dump-logs directory in $RESULT_ROOT/acceptance_test_tmp.
304+
305+
$RESULT_ROOT/acceptance_test_tmp is archived under $RESULT_ROOT/acceptance_test_tmp_archive
306+
307+
$PV_ROOT/acceptance_test_pv is archived under $PV_ROOT/acceptance_test_pv_archive
308+
309+
# How to add a new test
310+
311+
Add a new Junit test under integration-tests/src/test/java/oracle/kubernetes/operator.
312+
313+
class name must start with IT(Integration Test), IT*.java
314+
315+
ITFirstDomain.java - take a look at this test for reference
316+
317+
# Future enhancement
318+
319+
Add non-quick test use cases - part1 done.

0 commit comments

Comments
 (0)