-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtests.sh
executable file
·55 lines (39 loc) · 1.25 KB
/
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
#!/usr/bin/env bash -e
img=nr
config_path=/etc/nginx-nr-agent/nginx-nr-agent.ini
e_license=foo
e_app=bar
e_url=http://demo.nginx.com/status
function run {
docker build -t $img .
test_sed
test_service
# TODO: probably should cleanup when tests fail too.
docker rmi $img
echo "All tests passed!"
}
function test_sed {
echo "[+] test_sed"
docker run -d --name=$img -e "NEWRELIC_LICENSE=$e_license" \
-e "NEWRELIC_APP=$e_app" \
-e "NGINX_STATUS_URL=$e_url" $img
docker exec $img bash -c "grep -q newrelic_license_key=$e_license $config_path \
|| (echo 'NEWRELIC_LICENSE not found' && exit 1)"
docker exec $img bash -c "grep -q name=$e_app $config_path \
|| (echo 'NEWRELIC_APP not found' && exit 1)"
docker exec $img bash -c "grep -q url=$e_url $config_path \
|| (echo 'NGINX_STATUS_URL not found' && exit 1)"
docker kill $img; docker rm $img
}
function test_service {
echo "[+] test_service"
docker run -d --name=$img -e "NEWRELIC_LICENSE=$e_license" \
-e "NEWRELIC_APP=$e_app" \
-e "NGINX_STATUS_URL=$e_url" $img
sleep 3
s=nginx-nr-agent
docker exec $img bash -c "[[ \$(service $s status) == '$s is running.' ]] \
|| (echo '$s is not running' && exit 1)"
docker kill $img; docker rm $img
}
run