1111# introspector is working correctly, and for quickly testing changes to
1212# its overall flow.
1313#
14- # See the README in this directory for overall flow and usage.
15- #
16- # Notes:
14+ # The test calls the integration test 'cleanup.sh' when it starts, which
15+ # will delete all test resources and the domain_home that might
16+ # have been left over from a previous run.
1717#
18- # The test can optionally work with any arbitrary existing domain home, or
19- # it can create a domain_home for you. See CREATE_DOMAIN in the implementation
20- # below, (default true).
21- #
22- # The test calls the integration test 'cleanup.sh' when it starts. It
23- # passes a special parameter to cleanup.sh to skip domain_home deletion if
24- # the test's CREATE_DOMAIN parameter is set to false.
18+ # See the README in this directory for overall flow and usage.
2519#
2620# Internal design:
2721#
@@ -62,31 +56,7 @@ export PV_ROOT=${PV_ROOT:-/scratch/$USER/wl_k8s_test_results}
6256
6357# ############################################################################
6458#
65- # Set CREATE_DOMAIN to false to use an existing domain instead
66- # of creating a new one.
67- # - If setting to true (the default), see "extra env var" section below
68- # for additional related env vars.
69- # - If setting to false, remember to also set PVCOMMENT if the
70- # pre-existing domain is not in a PV.
71- #
72-
73- CREATE_DOMAIN=${CREATE_DOMAIN:- true}
74-
75- # ############################################################################
76- #
77- # Set PVCOMMENT to "#" to remove PV from wl-job/wl-pod yaml.
78- # - Do this when the introspector job or wl-pod already has
79- # the domain home burned into the image and so doesn't need
80- # to mount a PV.
81- # - Do not do this when CREATE_DOMAIN is true (create domain
82- # depends on the PV).
83- #
84-
85- export PVCOMMENT=${PVCOMMENT:- " " }
86-
87- # ############################################################################
88- #
89- # Set env vars for an existing domain and/or a to-be-created domain:
59+ # Set env vars for to-be-created domain:
9060#
9161
9262export WEBLOGIC_IMAGE_NAME=${WEBLOGIC_IMAGE_NAME:- store/ oracle/ weblogic}
@@ -111,11 +81,6 @@ export MANAGED_SERVER_NAME_BASE=${MANAGED_SERVER_NAME_BASE:-"managed-server"}
11181export DOMAIN_NAME=${DOMAIN_NAME:- " base_domain" }
11282export ADMINISTRATION_PORT=${ADMINISTRATION_PORT:- 7099}
11383
114- # ############################################################################
115- #
116- # Set extra env vars needed when CREATE_DOMAIN == true
117- #
118-
11984# publicip="`kubectl cluster-info | grep KubeDNS | sed 's;.*//\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\):.*;\1;'`"
12085# export TEST_HOST="`nslookup $publicip | grep 'name =' | sed 's/.*name = \(.*\)./\1/'`"
12186export TEST_HOST=" mycustompublicaddress"
@@ -159,12 +124,10 @@ function cleanupMajor() {
159124 #
160125 # 1 - delete all operator related k8s artifacts
161126 # 2 - delete contents of k8s weblogic domain PV/PVC
162- # (if CREATE_DOMAIN has been set to "true")
163127
164128 tracen " Info: Waiting for cleanup.sh to complete."
165129 printdots_start
166130 FAST_DELETE=" --grace-period=1 --timeout=1s" \
167- DELETE_FILES=${CREATE_DOMAIN:- false} \
168131 ${SOURCEPATH} /src/integration-tests/bash/cleanup.sh 2>&1 > \
169132 ${test_home} /cleanup.out
170133 status=$?
@@ -341,14 +304,12 @@ function deployTestScriptConfigMap() {
341304 mkdir -p ${test_home} /test-scripts
342305
343306 cp ${SOURCEPATH} /operator/src/main/resources/scripts/traceUtils* ${test_home} /test-scripts || exit 1
344- cp ${SCRIPTPATH} /createDomain .sh ${test_home} /test-scripts || exit 1
307+ cp ${SCRIPTPATH} /wl-create-domain-pod .sh ${test_home} /test-scripts || exit 1
345308 cp ${SCRIPTPATH} /createTestRoot.sh ${test_home} /test-scripts || exit 1
346- cp ${SCRIPTPATH} /introspectDomainProxy .sh ${test_home} /test-scripts || exit 1
309+ cp ${SCRIPTPATH} /wl-introspect-pod .sh ${test_home} /test-scripts || exit 1
347310
348- if [ " $CREATE_DOMAIN " = " true" ]; then
349- rm -f ${test_home} /test-scripts/createDomain.py
350- ${SCRIPTPATH} /util_subst.sh -g createDomain.pyt ${test_home} /test-scripts/createDomain.py || exit 1
351- fi
311+ rm -f ${test_home} /test-scripts/wl-create-domain-pod.py
312+ ${SCRIPTPATH} /util_subst.sh -g wl-create-domain-pod.pyt ${test_home} /test-scripts/wl-create-domain-pod.py || exit 1
352313
353314 kubectl -n $NAMESPACE delete cm test-script-cm \
354315 --ignore-not-found \
@@ -395,13 +356,10 @@ function deployCustomOverridesConfigMap() {
395356# ############################################################################
396357#
397358# Create base directory for PV (uses a job)
398- # (Skip if PVCOMMENT="#".)
399359#
400360
401361function createTestRootPVDir() {
402362
403- [ " $PVCOMMENT " = " #" ] && return
404-
405363 trace " Info: Creating k8s cluster physical directory 'PV_ROOT/acceptance_test_pv/domain-${DOMAIN_UID} -storage'."
406364 trace " Info: PV_ROOT='$PV_ROOT '"
407365 trace " Info: Test k8s resources use this physical directory via a PV/PVC '/shared' logical directory."
@@ -425,14 +383,13 @@ function createTestRootPVDir() {
425383# ############################################################################
426384#
427385# Deploy WebLogic pv, pvc, & admin user/pass secret
428- # (Skip pv/pvc if PVCOMMENT="#".)
429386#
430387
431388function deployWebLogic_PV_PVC_and_Secret() {
432389 trace " Info: Deploying WebLogic domain's pv, pvc, & secret."
433390
434- [ " $PVCOMMENT " = " # " ] || deployYamlTemplate wl-pv.yamlt wl-pv.yaml
435- [ " $PVCOMMENT " = " # " ] || deployYamlTemplate wl-pvc.yamlt wl-pvc.yaml
391+ deployYamlTemplate wl-pv.yamlt wl-pv.yaml
392+ deployYamlTemplate wl-pvc.yamlt wl-pvc.yaml
436393 deployYamlTemplate wl-secret.yamlt wl-secret.yaml
437394}
438395
@@ -453,22 +410,56 @@ function deployMySQL() {
453410
454411# ############################################################################
455412#
456- # Run create domain job if CREATE_DOMAIN is true
413+ # Run create domain "JobPod" - This is a pod that acts somewhat like a job
457414#
458415
459- function deployCreateDomainJob() {
460- [ ! " $CREATE_DOMAIN " = " true" ] && return 0
416+ function deployCreateDomainJobPod() {
417+ trace " Info: Run create domain pod."
418+
419+ local target_yaml=${test_home} /wl-create-domain-pod.yaml
420+ local pod_name=${DOMAIN_UID} -create-domain-pod
421+
422+ # delete anything left over from a previous invocation of this function, assume all pods
423+ # have already been cleaned up
424+
425+ rm -f ${target_yaml}
426+
427+ trace " Info: Deploying job pod '$pod_name ' and waiting for it to be ready."
428+
429+ (
430+ export JOB_SCRIPT=/test-scripts/wl-create-domain-pod.sh
431+ ${SCRIPTPATH} /util_subst.sh -g wl-create-domain-pod.yamlt ${target_yaml} || exit 1
432+ ) || exit 1
433+
434+ kubectl create -f ${target_yaml} \
435+ 2>&1 | tracePipe " Info: kubectl output: " || exit 1
461436
462- trace " Info: Run create domain job. "
437+ # Wait for pod to come up successfully
463438
464- [ " $PVCOMMENT " = " #" ] \
465- && trace " Error: Cannot run create domain job, PV is disabled via PVCOMMENT." \
466- && exit 1
439+ waitForPod $pod_name
440+
441+ # TODO: We can eliminate the following code if we (1) have job pod script touch
442+ # a file upon completion, and (2) have job pod ready check look for this file
443+
444+ local startSecs=$SECONDS
445+ local maxsecs=30
446+ local exitString=" "
447+ tracen " Info: Waiting up to $maxsecs seconds for pod '$pod_name ' to run the wl-create-domain-pod.py script."
448+ printdots_start
449+ while [ $(( SECONDS - startSecs)) -lt $maxsecs ] && [ " $exitString " = " " ]; do
450+ exitString=" ` kubectl -n $NAMESPACE logs $pod_name 2>&1 | grep CREATE_DOMAIN_EXIT` "
451+ sleep 1
452+ done
453+ printdots_end
454+ if [ " $exitString " = " " ]; then
455+ trace " Error: Timed out, see 'kubectl -n $NAMESPACE logs $pod_name '."
456+ exit 1
457+ fi
458+ if [ ! " $exitString " = " CREATE_DOMAIN_EXIT=0" ]; then
459+ trace " Error: Pod script failed, see 'kubectl -n $NAMESPACE logs $pod_name '."
460+ exit 1
461+ fi
467462
468- runJob ${DOMAIN_UID} -create-domain-job \
469- /test-scripts/createDomain.sh \
470- wl-job.yamlt \
471- wl-create-domain-job.yaml
472463}
473464
474465# ############################################################################
@@ -484,7 +475,6 @@ function deployIntrospectJobPod() {
484475 local introspect_output_cm_name=${DOMAIN_UID} -weblogic-domain-introspect-cm
485476 local target_yaml=${test_home} /wl-introspect-pod.yaml
486477 local pod_name=${DOMAIN_UID} --introspect-domain-pod
487- local job_name=$pod_name
488478
489479 trace " Info: Run introspection job, parse its output to files, and put files in configmap '$introspect_output_cm_name '."
490480
@@ -502,7 +492,7 @@ function deployIntrospectJobPod() {
502492 (
503493 export SERVER_NAME=introspect
504494 export JOB_NAME=${DOMAIN_UID} --introspect-domain-pod
505- export JOB_SCRIPT=/test-scripts/introspectDomainProxy .sh
495+ export JOB_SCRIPT=/test-scripts/wl-introspect-pod .sh
506496 export SERVICE_NAME=` toDNS1123Legal ${DOMAIN_UID} -${server_name} `
507497 export AS_SERVICE_NAME=` toDNS1123Legal ${DOMAIN_UID} -${ADMIN_NAME} `
508498 if [ " ${SERVER_NAME} " = " ${ADMIN_NAME} " ]; then
@@ -747,9 +737,6 @@ function checkDataSource() {
747737#
748738# Main
749739#
750- # Some of the following calls will be a partial or complete no-op if
751- # PVCOMMENT is set, or if CREATE_DOMAIN is set to false.
752- #
753740
754741if [ ! " $RERUN_INTROSPECT_ONLY " = " true" ]; then
755742 cleanupMajor
@@ -768,7 +755,7 @@ if [ ! "$RERUN_INTROSPECT_ONLY" = "true" ]; then
768755 createTestRootPVDir
769756 deployMySQL
770757 deployWebLogic_PV_PVC_and_Secret
771- deployCreateDomainJob
758+ deployCreateDomainJobPod
772759fi
773760
774761kubectl -n $NAMESPACE delete secret my-secret > /dev/null 2>&1
0 commit comments