-
Notifications
You must be signed in to change notification settings - Fork 15
/
test_oc_entrypoint.sh
executable file
·77 lines (63 loc) · 1.5 KB
/
test_oc_entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash -ex
set -o pipefail
# expects the following environment variables to be defined:
# - TEST_PLATFORM
# - OPENSHIFT_VERSION
# - OPENSHIFT_URL
# - OPENSHIFT_REGISTRY_URL
# - OPENSHIFT_USERNAME
# - OPENSHIFT_PASSWORD
# - CONJUR_NAMESPACE_NAME
# - CONJUR_APPLIANCE_IMAGE
export PLATFORM=openshift
export TEMPLATE_TAG="$TEST_PLATFORM."
export LOCAL_DEV_VOLUME=$(cat <<- ENDOFLINE
emptyDir: {}
ENDOFLINE
)
function finish {
echo 'Finishing'
echo '-----'
oc get events
{
pod_name="$(oc get pods -l role=master --no-headers | awk '{print $1}')"
if [[ -z "$pod_name" ]]; then
pod_name="$(oc get pods -l role=unset --no-headers | awk '{print $1}')"
fi
oc logs $pod_name > "output/$TEST_PLATFORM-authn-k8s-logs.txt"
} || {
echo "Logs could not be extracted from pod '$pod_name'"
touch "output/$TEST_PLATFORM-authn-k8s-logs.txt" # so Jenkins artifact collection doesn't fail
}
./stop
}
trap finish EXIT
function main() {
initialize
runScripts
}
function initialize() {
set +x
oc login "$OPENSHIFT_URL" \
--username="$OPENSHIFT_USERNAME" \
--password="$OPENSHIFT_PASSWORD" \
--insecure-skip-tls-verify=true
docker login \
-u _ \
-p $(oc whoami -t) \
"$OPENSHIFT_REGISTRY_URL"
set -x
}
function runScripts() {
echo 'Running tests'
cmd="./start"
if [ $CONJUR_DEPLOYMENT == "oss" ]; then
cmd="$cmd --oss"
fi
$cmd
}
function relaunchMaster() {
echo 'Relaunching master to test persistent volume restore'
./relaunch_master.sh
}
main