-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.sh
executable file
·63 lines (50 loc) · 1.7 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
#!/bin/bash -e
: "${RUBY_VERSION=3.0}"
# My local RUBY_VERSION is set to ruby-#.#.# so this allows running locally.
RUBY_VERSION="$(cut -d '-' -f 2 <<< "$RUBY_VERSION")"
source ./ci/oauth/keycloak/keycloak_functions.sh
TOP_LEVEL=$(git rev-parse --show-toplevel)
function finish {
echo 'Removing test environment'
echo '---'
docker compose down --rmi 'local' --volumes
}
trap finish EXIT
# Set up VERSION file for local development
if [ ! -f "${TOP_LEVEL}/VERSION" ]; then
echo -n "0.0.dev" > "${TOP_LEVEL}/VERSION"
fi
function main() {
if ! docker info >/dev/null 2>&1; then
echo "Docker does not seem to be running, run it first and retry"
exit 1
fi
# Generate reports folders locally
mkdir -p spec/reports features/reports
startConjur
runTests
}
function startConjur() {
echo 'Starting Conjur environment'
echo '-----'
# We want to pull to make sure we're testing against the newest release;
# failing to ensure that has caused many mysterious failures in CI.
# However, unconditionally pulling prevents working offline even
# with a warm cache. So try to pull, but ignore failures.
docker compose pull --ignore-pull-failures
docker compose build --build-arg RUBY_VERSION="$RUBY_VERSION"
docker compose up -d pg conjur
}
function runTests() {
echo 'Waiting for Conjur to come up, and configuring it...'
./ci/configure.sh
local api_key=$(docker compose exec -T conjur rake 'role:retrieve-key[cucumber:user:admin]')
echo 'Running tests'
echo '-----'
docker compose run --rm \
-e CONJUR_AUTHN_API_KEY="$api_key" \
-e SSL_CERT_FILE=/etc/ssl/certs/keycloak.pem \
tester \
"/scripts/fetch_certificate && rake jenkins_init jenkins_spec jenkins_cucumber"
}
main