-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathdeployment-tests.sh
More file actions
executable file
·63 lines (52 loc) · 1.91 KB
/
deployment-tests.sh
File metadata and controls
executable file
·63 lines (52 loc) · 1.91 KB
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
#!/usr/bin/env bash
# shellcheck disable=SC2024
# I am redirecting many sudo run commands to logfiles which can be owned by the non-priv user
# copied from mission-portal/ci/run.sh for selenium tests
# todo refactor to share some of this instead of copy/pasting
set -ex
# find the dir one level up from here, home of all the repositories
COMPUTED_ROOT="$(readlink -e "$(dirname "$0")/../../")"
# NTECH_ROOT should be the same, but if available use it so user can do their own thing.
NTECH_ROOT=${NTECH_ROOT:-$COMPUTED_ROOT}
USER=${USER:-$(whoami)}
# prepare artifacts dir
sudo mkdir -p "${NTECH_ROOT}/artifacts"
sudo chown "$USER" "${NTECH_ROOT}/artifacts"
trap failure ERR
function failure() {
cd "${NTECH_ROOT}/artifacts"
if command cf-support; then
sudo cf-support --yes > $$.cfsupportlog 2>&1 || cat $$.cfsupportlog
else
cp /var/log/CFEngine-Install* . # ${NTECH_ROOT}/artifacts cd previously
fi
rm $$.cfsupportlog
}
if [ ! -d /var/cfengine ]; then
# ci and local buildscripts should place built packages in $NTECH_ROOT/artifacts
sudo dpkg -i "$NTECH_ROOT"/artifacts/cfengine-nova-hub*deb
fi
AGENT_LOG="${NTECH_ROOT}/artifacts/agent.log"
if [ -f "$AGENT_LOG" ]; then
mv "$AGENT_LOG" "${AGENT_LOG}.$(date +%s)"
fi
mkdir -p "${NTECH_ROOT}/artifacts"
touch "$AGENT_LOG"
if [ ! -f /var/cfengine/policy_server.dat ]; then
sudo /var/cfengine/bin/cf-agent -B "$(hostname -I | awk ' {print $1}')" >>"$AGENT_LOG" 2>&1
fi
# make artifacts directory to be slurped by CI (jenkins, github, ...)
mkdir -p "${NTECH_ROOT}/artifacts"
{
sudo /var/cfengine/bin/cf-agent -KIf update.cf
sudo /var/cfengine/bin/cf-agent -KI
sudo /var/cfengine/bin/cf-agent -KI
} >>"$AGENT_LOG" 2>&1
if grep -i error "$AGENT_LOG" >/dev/null; then
echo "FAIL test, errors in $AGENT_LOG"
grep -i error "$AGENT_LOG"
fi
apt-get -y install python3-psycopg2
export REPORTING_TEST_DELAY=5
cd "${NTECH_ROOT}/nova/tests/reporting"
python3 deployment_test.py