-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·52 lines (37 loc) · 1.37 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
#!/usr/bin/env bash
set -euo pipefail
# Bring up etcd service container and wait a little until etcd gets initialised.
docker run \
--detach \
--name 'etcd' \
--net 'host' \
quay.io/coreos/etcd
sleep 1;
# Start confd container.
path=$(pwd)
docker run \
--detach \
--name 'confd' \
--net 'host' \
--volume "${path}/test:/etc/confd" \
ianbytchek/confd
sleep 1;
echo -n "Verify template doesn't get rendered without no keys."
if [ ! -f './test/output/foo.conf' ]; then
echo ' OK!'; else echo ' Fail!'; exit 1; fi;
curl --location --request 'PUT' --data 'value=foo' http://localhost:4001/v2/keys/services/x
sleep 1;
echo -n 'Verify template has only foo value.'
if cat './test/output/foo.conf' | grep -Pq '^foo$'; then
echo ' OK!'; else echo ' Fail!'; exit 1; fi;
curl --location --request 'PUT' --data 'value=bar' http://localhost:4001/v2/keys/services/y
curl --location --request 'DELETE' http://localhost:4001/v2/keys/services/x
sleep 1;
echo -n 'Verify template has only bar value.'
if cat './test/output/foo.conf' | grep -Pq '^bar$'; then
echo ' OK!'; else echo ' Fail!'; exit 1; fi;
curl --location --request 'PUT' --data 'value=baz' http://localhost:4001/v2/keys/services/z
sleep 1;
echo -n 'Verify template has only bar and baz value.'
if cat './test/output/foo.conf' | grep -Pq '^bar,baz|baz,bar$'; then
echo ' OK!'; else echo ' Fail!'; exit 1; fi;