Skip to content

Commit 569dee9

Browse files
committed
adding latest krun.sh
1 parent 515b727 commit 569dee9

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/integration-tests/bash/krun.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
# Credit:
1111
# - This script is an expansion of https://gist.github.com/yuanying/3aa7d59dcce65470804ab43def646ab6
1212
#
13-
# TBD:
14-
# - Image secret parameter hasn't been tested.
15-
#
1613

1714
IMAGE='store/oracle/serverjre:8'
1815
IMAGEPULLPOLICY='IfNotPresent'
@@ -105,11 +102,6 @@ EOF
105102
exit 1
106103
}
107104

108-
delete_pod_and_cm() {
109-
kubectl delete -n ${NAMESPACE} pod ${PODNAME} --ignore-not-found > /dev/null 2>&1
110-
kubectl delete -n ${NAMESPACE} cm ${PODNAME}-cm --ignore-not-found > /dev/null 2>&1
111-
}
112-
113105
while getopts m:t:i:c:n:f:p:l:s:d: OPT
114106
do
115107
case $OPT in
@@ -176,6 +168,11 @@ TEMPFILE="${TMPDIR}/$(basename $0).${NAMESPACE}.${PODNAME}.tmp.$$"
176168

177169
# cleanup anything from previous run
178170

171+
delete_pod_and_cm() {
172+
kubectl delete -n ${NAMESPACE} pod ${PODNAME} --ignore-not-found > /dev/null 2>&1
173+
kubectl delete -n ${NAMESPACE} cm ${PODNAME}-cm --ignore-not-found > /dev/null 2>&1
174+
}
175+
179176
delete_pod_and_cm
180177

181178
# create cm that contains any files the user specified on the command line:
@@ -199,7 +196,7 @@ fi
199196
\"containers\":[
200197
{
201198
\"command\": [\"bash\"],
202-
\"args\": [\"-c\",\"${COMMAND} ; echo -n {EXITCODE=\$?}\"],
199+
\"args\": [\"-c\",\"${COMMAND} ; echo -n {{EXITCODE=\$?=EXITCODE}} ; echo -n {{ID=\`id\`=ID}} ; echo -n {{PWD=\`pwd\`=PWD}}\"],
203200
\"stdin\": true,
204201
\"tty\": true,
205202
\"name\": \"${PODNAME}\",
@@ -237,11 +234,11 @@ do
237234
sleep 0.1
238235
done
239236

240-
# If background task's out file doesn't contain '{EXITCODE=0}',
237+
# If background task's out file doesn't contain '{{EXITCODE=0=EXITCODE}}',
241238
# then it didn't finish or it failed...
242239

243240
if [ $EXITCODE -eq 0 ]; then
244-
if [ ! "`grep -c '{EXITCODE=0}' $TEMPFILE`" -eq 1 ]; then
241+
if [ ! "`grep -c '{{EXITCODE=0=EXITCODE}}' $TEMPFILE`" -eq 1 ]; then
245242
EXITCODE=99
246243
fi
247244
fi
@@ -254,7 +251,18 @@ delete_pod_and_cm
254251

255252
# Show output from pod (or from failing 'kubectl create cm' command above)
256253

257-
cat $TEMPFILE | sed 's/{EXITCODE=0}//' \
254+
if [ $EXITCODE -eq 0 ]; then
255+
IDFILTER="{{ID=.*=ID}}"
256+
PWDFILTER="{{PWD=.*=PWD}}"
257+
else
258+
# Don't filter out ID and PWD - leave it in for debugging purposes...
259+
IDFILTER="{{DNE=DNE}}"
260+
PWDFILTER="{{DNE=DNE}}"
261+
fi
262+
263+
cat $TEMPFILE | sed "s/{{EXITCODE=0=EXITCODE}}//" \
264+
| sed "s/$IDFILTER//" \
265+
| sed "s/$PWDFILTER//" \
258266
| grep -v "Unable to use a TTY - input is not a terminal or the right kind of file" \
259267
| grep -v "If you don't see a command prompt, try pressing enter." \
260268
| grep -v "Error attaching, falling back to logs:"

0 commit comments

Comments
 (0)