Skip to content

Commit 38584db

Browse files
committed
maven clean verify to get the post-integration-test phase executed
1 parent d4fd8f0 commit 38584db

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
5+
6+
#
7+
# state_dump
8+
# - called at the end of a run
9+
# - places k8s logs, descriptions, etc in directory $RESULT_DIR/state-dump-logs
10+
# - calls archive.sh on RESULT_DIR locally, and on PV_ROOT via a job
11+
# - IMPORTANT: this method should not rely on exports
12+
#
13+
function state_dump {
14+
local RESULT_DIR="$RESULT_ROOT/acceptance_test_tmp"
15+
local PV_ROOT="$PV_ROOT"
16+
local PROJECT_ROOT="$PROJECT_ROOT"
17+
local SCRIPTPATH="$PROJECT_ROOT/src/integration-tests/bash"
18+
local LEASE_ID="$LEASE_ID"
19+
20+
if [ ! -d "$RESULT_DIR" ]; then
21+
echo State dump exiting early. RESULT_DIR \"$RESULT_DIR\" does not exist or is not a directory.
22+
return
23+
fi
24+
25+
local DUMP_DIR=$RESULT_DIR/state-dump-logs
26+
echo Starting state dump. Dumping state to directory ${DUMP_DIR}
27+
28+
mkdir -p ${DUMP_DIR}
29+
30+
# Test output is captured to ${TESTOUT} when run.sh is run stand-alone
31+
# if [ -f ${TESTOUT:-NoSuchFile.out} ]; then
32+
# echo Copying ${TESTOUT} to ${DUMP_DIR}/test_suite.out
33+
# cp ${TESTOUT} ${DUMP_DIR}/test_suite.out
34+
# fi
35+
36+
# dumping kubectl state
37+
# get domains is in its own command since this can fail if domain CRD undefined
38+
39+
echo Dumping kubectl gets to kgetmany.out and kgetdomains.out in ${DUMP_DIR}
40+
kubectl get all,crd,cm,pv,pvc,ns,roles,rolebindings,clusterroles,clusterrolebindings,secrets --show-labels=true --all-namespaces=true 2>&1 | tee ${DUMP_DIR}/kgetmany.out
41+
kubectl get domains --show-labels=true --all-namespaces=true 2>&1 | tee ${DUMP_DIR}/kgetdomains.out
42+
43+
# Get all pod logs and redirect/copy to files
44+
45+
set +x
46+
local namespaces="`kubectl get namespaces | egrep -v -e "(STATUS|kube)" | awk '{ print $1 }'`"
47+
set -x
48+
49+
local namespace
50+
echo "Copying logs and describes to pod-log.NAMESPACE.PODNAME and pod-describe.NAMESPACE.PODNAME in ${DUMP_DIR}"
51+
for namespace in $namespaces; do
52+
set +x
53+
local pods="`kubectl get pods -n $namespace --ignore-not-found | egrep -v -e "(STATUS)" | awk '{print $1}'`"
54+
set -x
55+
local pod
56+
for pod in $pods; do
57+
local logfile=${DUMP_DIR}/pod-log.${namespace}.${pod}
58+
local descfile=${DUMP_DIR}/pod-describe.${namespace}.${pod}
59+
kubectl log $pod -n $namespace 2>&1 | tee $logfile
60+
kubectl describe pod $pod -n $namespace 2>&1 | tee $descfile
61+
done
62+
done
63+
64+
# use a job to archive PV, /scratch mounts to PV_ROOT in the K8S cluster
65+
echo "Archiving pv directory using a kubernetes job. Look for it on k8s cluster in $PV_ROOT/acceptance_test_pv_archive"
66+
local outfile=${DUMP_DIR}/archive_pv_job.out
67+
$SCRIPTPATH/job.sh "/scripts/archive.sh /scratch/acceptance_test_pv /scratch/acceptance_test_pv_archive" 2>&1 | tee ${outfile}
68+
if [ "$?" = "0" ]; then
69+
echo Job complete.
70+
else
71+
echo Job failed. See ${outfile}.
72+
fi
73+
74+
if [ ! "$LEASE_ID" = "" ]; then
75+
# release the lease if we own it
76+
${SCRIPTPATH}/lease.sh -d "$LEASE_ID" 2>&1 | tee ${RESULT_DIR}/release_lease.out
77+
if [ "$?" = "0" ]; then
78+
echo Lease released.
79+
else
80+
echo Lease could not be released:
81+
cat /${RESULT_DIR}/release_lease.out
82+
fi
83+
fi
84+
85+
# now archive all the local test files
86+
$SCRIPTPATH/archive.sh "${RESULT_DIR}" "${RESULT_DIR}_archive"
87+
88+
echo Done with state dump
89+
}
90+
91+
export SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
92+
export PROJECT_ROOT="$SCRIPTPATH/../../../.."
93+
export RESULT_ROOT=${RESULT_ROOT:-/scratch/$USER/wl_k8s_test_results}
94+
export PV_ROOT=${PV_ROOT:-$RESULT_ROOT}
95+
echo "RESULT_ROOT$RESULT_ROOT PV_ROOT$PV_ROOT"
96+
97+
state_dump

wercker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ integration-test-java:
289289
yum -y install tar gzip procps
290290
291291
- wercker/maven:
292-
goals: test-compile integration-test
292+
goals: clean verify
293293
version: 3.5.2
294294
profiles: java-integration-tests
295295

0 commit comments

Comments
 (0)