Skip to content

Commit b850c8e

Browse files
authored
Merge pull request #903 from oracle/kubernetes-run-script-example
ready to merge: introspect test update
2 parents b76e790 + 1e21ef6 commit b850c8e

File tree

10 files changed

+298
-462
lines changed

10 files changed

+298
-462
lines changed

src/integration-tests/introspector/README

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ Internal Test Flow:
3737

3838
<operator-src>/src/integration-tests/bash/cleanup.sh
3939

40-
() Create a test directory in the k8s cluster via a k8s pv, pvc, and a job.
40+
() Create a test directory in the k8s cluster via kubectl run.
4141

42-
create-test-root-pv.yamlt, create-test-root-pvc.yamlt
43-
create-test-root.sh, create-test-root-job.yamlt
42+
See createTestRoot.sh
4443

45-
() Deploy pv/pvc for use by introspector job, the domain create step, and wl pods. (If PV_COMMENT != "#").
44+
() Deploy pv/pvc for use by introspector job pod, the domain create step, and wl pods. (If PV_COMMENT != "#").
4645

4746
wl-pv.yamlt, wl-pvc.yamlt
4847

@@ -54,15 +53,15 @@ Internal Test Flow:
5453

5554
wl-create-domain-pod.yamlt, wl-create-domain-pod.sh, wl-create-domain-pod.pyt
5655

57-
() Run the introspector job (as a direct pod instead of a job)
56+
() Run the introspector job pod (as a direct pod instead of a job)
5857

5958
wl-instrospect-pod.yamlt
6059
wl-instrospect-pod.sh
6160
<operator-src>/operator/src/main/resources/scripts/introspectDomain.sh
6261
<operator-src>/operator/src/main/resources/scripts/startNodeManager.sh
6362
<operator-src>/operator/src/main/resources/scripts/introspectDomain.py
6463

65-
() Parse the introspector job's output into files and deploy them in a configmap.
64+
() Parse the introspector job pod's output into files and deploy them in a configmap.
6665

6766
() Start the admin server pod. The startServer.sh and start-server.py
6867
scripts will use files from the configmap for situational config and login

src/integration-tests/introspector/create-test-root-job.yamlt

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/integration-tests/introspector/create-test-root-pv.yamlt

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/integration-tests/introspector/create-test-root-pvc.yamlt

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#!/bin/sh
22

3-
# This script runs inside a job (create-test-root-job.yamlt), it sets up the top
3+
# This script runs in a pod via krun.sh, it sets up the top
44
# level directory for this test that in turn is mounted as /shared by the
5-
# test's wl-pvc, wl-pv, wl-job, and wl-pod yamlt (plus similar 'mysql' yamlt).
5+
# test's wl-pvc, wl-pv, and wl-pod yamlt (plus similar 'mysql' yamlt).
66

77
# The 'acceptance_test_pv' directory it creates matches the directory
88
# expected by the integration test 'cleanup.sh' script.
99

10-
# The 'pv-root' directory is mounted via the create-test-root-job.yamlt,
11-
# create-test-root-pv.yamlt, and create-test-root-pvc.yamlt. It physically
10+
# The 'pv-root' directory is mounted in the krun.sh command line. It physically
1211
# corresponds to the PV_ROOT env var path specified as an input to the test.
1312

14-
mkdir -p /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage/domains || exit 1
15-
mkdir -p /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage/mysql || exit 1
13+
DOMAIN_UID=${1?}
14+
15+
mkdir -p /pv-root/acceptance_test_pv/domain-${DOMAIN_UID}-storage/domains || exit 1
16+
mkdir -p /pv-root/acceptance_test_pv/domain-${DOMAIN_UID}-storage/mysql || exit 1
1617
chmod 777 /pv-root/acceptance_test_pv || exit 1
17-
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage || exit 1
18-
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage/domains || exit 1
19-
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage/mysql || exit 1
18+
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID}-storage || exit 1
19+
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID}-storage/domains || exit 1
20+
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID}-storage/mysql || exit 1

src/integration-tests/introspector/introspectTest.sh

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -162,54 +162,6 @@ function cleanupMinor() {
162162
echo
163163
}
164164

165-
#############################################################################
166-
#
167-
# Helper function for running a job
168-
#
169-
170-
function runJob() {
171-
trace "Info: Running job '${1?}' for script '${2?}'."
172-
173-
local job_name=${1?}
174-
local job_script=${2?}
175-
local yaml_template=${3?}
176-
local yaml_file=${4?}
177-
178-
# Remove old job yaml in case its leftover from a previous run
179-
180-
rm -f ${test_home}/${yaml_file}
181-
182-
# Create the job yaml from its template
183-
184-
env \
185-
JOB_SCRIPT=${job_script} \
186-
JOB_NAME=${job_name} \
187-
${SCRIPTPATH}/util_subst.sh -g ${yaml_template} ${test_home}/${yaml_file} \
188-
|| exit 1
189-
190-
# Run the job
191-
192-
tracen "Info: Waiting for job '$job_name' to complete."
193-
printdots_start
194-
env \
195-
KUBECONFIG=$KUBECONFIG \
196-
JOB_YAML=${test_home}/${yaml_file} \
197-
JOB_NAME=${job_name} \
198-
NAMESPACE=$NAMESPACE \
199-
${SCRIPTPATH}/util_job.sh \
200-
2>&1 > ${test_home}/job-${1}.out
201-
local status=$?
202-
printdots_end
203-
204-
if [ ! $status -eq 0 ]; then
205-
printdots_end
206-
trace "Error: job failed, job contents"
207-
cat ${test_home}/job-${1}.out
208-
trace "Error: end of failed job contents"
209-
exit 1
210-
fi
211-
}
212-
213165
#############################################################################
214166
#
215167
# Helper function for deploying a yaml template. Template $1 is converted
@@ -359,25 +311,23 @@ function deployCustomOverridesConfigMap() {
359311
#
360312

361313
function createTestRootPVDir() {
362-
363-
trace "Info: Creating k8s cluster physical directory 'PV_ROOT/acceptance_test_pv/domain-${DOMAIN_UID}-storage'."
364314
trace "Info: PV_ROOT='$PV_ROOT'"
365-
trace "Info: Test k8s resources use this physical directory via a PV/PVC '/shared' logical directory."
366315

367316
# TBD on Wercker/Jenkins PV_ROOT will differ and may already exist or be remote
368317
# so we need to add logic/booleans to skip the following mkdir/chmod as needed
318+
369319
mkdir -p ${PV_ROOT} || exit 1
370320
chmod 777 ${PV_ROOT} || exit 1
371321

372-
# Create test root within PV_ROOT via a job
373-
374-
deployYamlTemplate create-test-root-pv.yamlt create-test-root-pv.yaml
375-
deployYamlTemplate create-test-root-pvc.yamlt create-test-root-pvc.yaml
322+
trace "Info: Creating k8s cluster physical directory 'PV_ROOT/acceptance_test_pv/domain-${DOMAIN_UID}-storage' via 'kubectl run'."
323+
trace "Info: Test k8s resources use this physical directory via a PV/PVC '/shared' logical directory."
376324

377-
runJob ${DOMAIN_UID}-create-test-root-job \
378-
/test-scripts/createTestRoot.sh \
379-
create-test-root-job.yamlt \
380-
create-test-root-job.yaml
325+
${SCRIPTPATH}/util_krun.sh -m ${PV_ROOT}:/pv-root \
326+
-i ${WEBLOGIC_IMAGE_NAME}:${WEBLOGIC_IMAGE_TAG} \
327+
-l ${WEBLOGIC_IMAGE_PULL_POLICY} \
328+
-f ${SCRIPTPATH}/createTestRoot.sh \
329+
-c "sh /tmpmount/createTestRoot.sh ${DOMAIN_UID}" \
330+
|| exit 1
381331
}
382332

383333
#############################################################################
@@ -695,18 +645,18 @@ deployDomainConfigMap
695645
deployTestScriptConfigMap
696646
deployCustomOverridesConfigMap
697647

648+
kubectl -n $NAMESPACE delete secret my-secret > /dev/null 2>&1
649+
kubectl -n $NAMESPACE create secret generic my-secret \
650+
--from-literal=key1=supersecret \
651+
--from-literal=key2=topsecret 2>&1 | tracePipe "Info: kubectl output: "
652+
698653
if [ ! "$RERUN_INTROSPECT_ONLY" = "true" ]; then
699654
createTestRootPVDir
700655
deployMySQL
701656
deployWebLogic_PV_PVC_and_Secret
702657
deployCreateDomainJobPod
703658
fi
704659

705-
kubectl -n $NAMESPACE delete secret my-secret > /dev/null 2>&1
706-
kubectl -n $NAMESPACE create secret generic my-secret \
707-
--from-literal=key1=supersecret \
708-
--from-literal=key2=topsecret 2>&1 | tracePipe "Info: kubectl output: "
709-
710660
deployIntrospectJobPod
711661

712662
#

0 commit comments

Comments
 (0)