forked from RedHatInsights/insights-host-inventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iqe_tests.sh
executable file
·78 lines (68 loc) · 2.7 KB
/
iqe_tests.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
78
#!/bin/bash
# --------------------------------------------
# Pre-commit checks
# --------------------------------------------
export APP_NAME="host-inventory" # name of app-sre "application" folder this component lives in
export IMAGE="quay.io/cloudservices/insights-inventory"
export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8
export APP_ROOT=$(pwd)
export WORKSPACE=${WORKSPACE:-$APP_ROOT} # if running in jenkins, use the build's workspace
export IMAGE_TAG=$(git rev-parse --short=7 HEAD)
export GIT_COMMIT=$(git rev-parse HEAD)
export REF_ENV="insights-stage"
# --------------------------------------------
# Options that must be configured by app owner
# --------------------------------------------
COMPONENT_NAME="host-inventory" # name of app-sre "resourceTemplate" in deploy.yaml for this component
COMPONENTS_W_RESOURCES="host-inventory" # this gives us resources defined in app-sre, otherwise we run low on memory
IQE_PLUGINS="host_inventory"
IQE_MARKER_EXPRESSION="not resilience and not cert_auth and not rbac_dependent"
IQE_FILTER_EXPRESSION=""
IQE_CJI_TIMEOUT="3h"
# ---------------------------
# We'll take it from here ...
# ---------------------------
# Get bonfire helper scripts
CICD_URL=https://raw.githubusercontent.com/RedHatInsights/bonfire/master/cicd
curl -s $CICD_URL/bootstrap.sh > .cicd_bootstrap.sh && source .cicd_bootstrap.sh
function check_image () {
for i in {1..60}
do
echo "Try number $i"
echo "Checking if image '$IMAGE:$IMAGE_TAG' already exists in quay.io..."
QUAY_REPO=${IMAGE#"quay.io/"}
RESPONSE=$( \
curl -Ls -H "Authorization: Bearer $QUAY_API_TOKEN" \
"https://quay.io/api/v1/repository/$QUAY_REPO/tag/?specificTag=$IMAGE_TAG" \
)
# find all non-expired tags
VALID_TAGS_LENGTH=$(echo $RESPONSE | jq '[ .tags[] ] | length')
if [[ "$VALID_TAGS_LENGTH" -gt 0 ]]; then
echo "Found image '$IMAGE:$IMAGE_TAG'"
return 0
fi
echo "Image '$IMAGE:$IMAGE_TAG' not found, retrying in 30 seconds"
sleep 30
done
return 1
}
check_image
if [[ $? -ne 0 ]]
then
echo "Image '$IMAGE:$IMAGE_TAG' not found in quay, exiting script"
exit 1
fi
# Deploy ephemeral env and run IQE tests
source $CICD_ROOT/deploy_ephemeral_env.sh
bonfire namespace extend $NAMESPACE --duration 3h
# Workaround for bonfire CICD script issue: https://github.com/RedHatInsights/bonfire/issues/283
# Restart `oc logs -f` after 1 hour
sed -i \
's/oc_wrapper logs -n $NAMESPACE $POD -c $CONTAINER -f &/ \
oc_wrapper logs -n $NAMESPACE $POD -c $CONTAINER -f \&\n \
LOGS_PID=$!\n sleep 3600\n kill $LOGS_PID\n \
oc_wrapper logs -n $NAMESPACE $POD -c $CONTAINER -f \&/' \
$CICD_ROOT/cji_smoke_test.sh
source $CICD_ROOT/cji_smoke_test.sh
source $CICD_ROOT/post_test_results.sh