Skip to content

Commit baf4ea9

Browse files
author
Tom Barnes
committed
Slight test modification. Make it slighly better than watching pain dry. (Print dots while waiting for long foreground jobs to finish.)
1 parent e3830b8 commit baf4ea9

File tree

2 files changed

+87
-4
lines changed

2 files changed

+87
-4
lines changed

src/integration-tests/introspector/introspectTest.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
4242
SOURCEPATH="`echo $SCRIPTPATH | sed 's/weblogic-kubernetes-operator.*/weblogic-kubernetes-operator/'`"
4343
traceFile=${SOURCEPATH}/operator/src/main/resources/scripts/traceUtils.sh
4444
source ${traceFile}
45+
source ${SCRIPTPATH}/util_dots.sh
4546
[ $? -ne 0 ] && echo "Error: missing file ${traceFile}" && exit 1
4647

4748
# Set TRACE_INCLUDE_FILE to true to cause tracing to include filename & line number.
@@ -172,11 +173,15 @@ function cleanup() {
172173
# 2 - delete contents of k8s weblogic domain PV/PVC
173174
# (if CREATE_DOMAIN has been set to "true")
174175

176+
tracen "Info: Waiting for cleanup.sh to complete."
177+
printdots_start
175178
DELETE_FILES=${CREATE_DOMAIN:-false} \
176179
${SOURCEPATH}/src/integration-tests/bash/cleanup.sh 2>&1 > \
177180
${test_home}/cleanup.out
181+
status=$?
182+
printdots_end
178183

179-
if [ $? -ne 0 ]; then
184+
if [ $status -ne 0 ]; then
180185
trace "Error: cleanup failed. Cleanup output:"
181186
cat ${test_home}/cleanup.out
182187
exit 1
@@ -210,15 +215,20 @@ function runJob() {
210215

211216
# Run the job
212217

218+
tracen "Info: Waiting for job to complete."
219+
printdots_start
213220
env \
214221
KUBECONFIG=$KUBECONFIG \
215222
JOB_YAML=${test_home}/${yaml_file} \
216223
JOB_NAME=${job_name} \
217224
NAMESPACE=$NAMESPACE \
218225
${SCRIPTPATH}/util_job.sh \
219226
2>&1 > ${test_home}/job-${1}.out
227+
local status=$?
228+
printdots_end
220229

221-
if [ ! $? -eq 0 ]; then
230+
if [ ! $status -eq 0 ]; then
231+
printdots_end
222232
trace "Error: job failed, job contents"
223233
cat ${test_home}/job-${1}.out
224234
trace "Error: end of failed job contents"
@@ -513,7 +523,7 @@ function deployPod() {
513523
sleep 1
514524
status=`kubectl get pods -n $NAMESPACE 2>&1 | egrep $pod_name | awk '{print $2}'`
515525
done
516-
echo
526+
echo " ($((SECONDS - startsecs)) seconds)"
517527
}
518528

519529
function deploySinglePodService() {
@@ -606,12 +616,16 @@ deploySinglePodService ${MANAGED_SERVER_NAME_BASE?}1 ${MANAGED_SERVER_PORT?} 308
606616
trace "Info: Checking beans to see if sit-cfg took effect. Input file 'checkBeans.input', output file '$test_home/checkBeans.out'."
607617
kubectl cp checkBeans.input domain1-admin-server:/shared/checkBeans.input || exit 1
608618
kubectl cp checkBeans.py domain1-admin-server:/shared/checkBeans.py || exit 1
619+
tracen "Info: Waiting for WLST checkBeans.py to complete."
620+
printdots_start
609621
kubectl exec -it domain1-admin-server \
610622
wlst.sh /shared/checkBeans.py \
611623
weblogic welcome1 t3://domain1-admin-server:7001 \
612624
/shared/checkBeans.input \
613625
> $test_home/checkBeans.out 2>&1
614-
if [ $? -ne 0 ]; then
626+
status=$?
627+
printdots_end
628+
if [ $status -ne 0 ]; then
615629
trace "Error: checkBeans failed, see '$test_home/checkBeans.out'."
616630
exit 1
617631
fi
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# !/bin/sh
2+
3+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
5+
6+
#
7+
# Description:
8+
# ------------
9+
#
10+
# This helper utility prints dots using a background process
11+
# while a foreground process runs. Use it to provide feedback
12+
# while you wait for the foreground process to finish.
13+
#
14+
# It stops printing dots when any of the following are true:
15+
# - printdots_end is called
16+
# - the process that called printdots_start is no longer around
17+
# - more than 120 seconds has passed
18+
#
19+
# Usage example:
20+
# source ./util_dots.sh
21+
#
22+
# echo -n "Hello"
23+
# printdots_start 1
24+
# sleep 6
25+
# printdots_end
26+
#
27+
# The first parameter of printdots_start is the number of seconds
28+
# to wait before each dot - default is 2 seconds.
29+
#
30+
# 'printdots_end' calls 'echo' without any parameters.
31+
#
32+
33+
printdots_inner() {
34+
local start_pids=""
35+
local dotsfile=$1
36+
local begin_sec=$SECONDS
37+
[ -f "$dotsfile" ] || return
38+
while [ 1 -eq 1 ]; do
39+
[ "$start_pids" = "" ] && start_pids="`ps -o ppid=`"
40+
sleep ${2:-1}
41+
42+
# if parent pids changed, then our parent died and we should exit
43+
local end_pids="`ps -o ppid=`"
44+
[ "$start_pids" = "$end_pids" ] || break
45+
46+
# if too much time has passed, then exit
47+
[ $((SECONDS-begin_sec)) -lt 120 ] || break
48+
49+
# if parent deleted our temp file, then exit
50+
[ -f "$dotsfile" ] || break
51+
52+
echo -n "."
53+
done
54+
rm -f $dotsfile
55+
}
56+
57+
printdots_start() {
58+
dotsfile=$(mktemp /tmp/dots.`basename $0`.XXXXXXXXX)
59+
touch $dotsfile
60+
printdots_inner $dotsfile $1 &
61+
printdots_pid=$!
62+
printdots_time_start=$SECONDS
63+
}
64+
65+
printdots_end() {
66+
rm -f $dotsfile
67+
wait $printdots_pid > /dev/null 2>&1
68+
echo " ($((SECONDS - printdots_time_start)) seconds)"
69+
}

0 commit comments

Comments
 (0)