forked from d2iq-archive/dcos-commons
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.sh
executable file
·77 lines (65 loc) · 2.79 KB
/
test.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
#!/usr/bin/env bash
# This file contains logic for integration tests which are executed by CI upon pull requests to
# dcos-commons. The script builds the Hello World framework, packages and uploads it, then runs its
# integration tests against a newly-launched cluster.
# Exit immediately on errors -- the helper scripts all emit github statuses internally
set -e
function proxylite_preflight {
bash frameworks/proxylite/scripts/ci.sh pre-test
}
function run_framework_tests {
framework=$1
FRAMEWORK_DIR=${REPO_ROOT_DIR}/frameworks/${framework}
if [ "$framework" = "proxylite" ]; then
if ! proxylite_preflight; then
sleep 5
proxylite_preflight
fi
fi
# Build/upload framework scheduler artifact if one is not directly provided:
if [ -z "${!STUB_UNIVERSE_URL}" ]; then
STUB_UNIVERSE_URL=$(echo "${framework}_STUB_UNIVERSE_URL" | awk '{print toupper($0)}')
# Build/upload framework scheduler:
UNIVERSE_URL_PATH=$FRAMEWORK_DIR/${framework}-universe-url
UNIVERSE_URL_PATH=$UNIVERSE_URL_PATH ${FRAMEWORK_DIR}/build.sh aws
if [ ! -f "$UNIVERSE_URL_PATH" ]; then
echo "Missing universe URL file: $UNIVERSE_URL_PATH"
exit 1
fi
export STUB_UNIVERSE_URL=$(cat $UNIVERSE_URL_PATH)
rm -f $UNIVERSE_URL_PATH
echo "Built/uploaded stub universe: $STUB_UNIVERSE_URL"
else
echo "Using provided STUB_UNIVERSE_URL: $STUB_UNIVERSE_URL"
fi
# Run shakedown tests in framework directory:
TEST_GITHUB_LABEL="${framework}" ${REPO_ROOT_DIR}/tools/run_tests.py shakedown ${FRAMEWORK_DIR}/tests/
}
REPO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $REPO_ROOT_DIR
# Get a CCM cluster if not already configured (see available settings in dcos-commons/tools/README.md):
if [ -z "$CLUSTER_URL" ]; then
echo "CLUSTER_URL is empty/unset, launching new cluster."
export CCM_AGENTS=5
CLUSTER_INFO=$(${REPO_ROOT_DIR}/tools/launch_ccm_cluster.py)
echo "Launched cluster: ${CLUSTER_INFO}"
export CLUSTER_URL=$(echo "${CLUSTER_INFO}" | jq .url)
export CLUSTER_ID=$(echo "${CLUSTER_INFO}" | jq .id)
export CLUSTER_AUTH_TOKEN=$(echo "${CLUSTER_INFO}" | jq .auth_token)
else
echo "Using provided CLUSTER_URL as cluster: $CLUSTER_URL"
fi
# A specific framework can be specified to run its tests
# Otherwise all tests are run
if [ -n "$1" ]; then
run_framework_tests $1
else
for framework in $(ls $REPO_ROOT_DIR/frameworks); do
run_framework_tests $framework
done
fi
# Tests succeeded. Out of courtesy, trigger a teardown of the cluster if we created it ourselves.
# Don't wait for the cluster to complete teardown.
if [ -n "${CLUSTER_ID}" ]; then
${REPO_ROOT_DIR}/tools/launch_ccm_cluster.py trigger-stop ${CLUSTER_ID}
fi