-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·30 lines (23 loc) · 967 Bytes
/
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
#!/bin/bash
tmpfile=$(mktemp)
teardown()
{
vagrant destroy -f
rm -rf .vagrant/ *.retry "$tmpfile" ubuntu-*-cloudimg-console.log
}
. test-library.sh
# turn on the environment
vagrant up
# check the solution playbook syntax
checkPlaybookSyntax playbook.yml
# execute the solution
ansible-playbook playbook.yml | tee ${tmpfile}
assertEquals 3 $(tail -10 ${tmpfile} | grep -c "failed=0")
# validate the solution
ansible qa -m shell -a "cat /etc/conn.properties" | tee ${tmpfile}
assertEquals "url=jdbc:mysql://db1/mydbusername=qa1userpassword=qa1secret" $(awk '/qa1/ {for(i=1; i<=3; i++) {getline; printf $0}}' ${tmpfile})
assertEquals "url=jdbc:mysql://db2/mydbusername=qa2userpassword=qa2secret" $(awk '/qa2/ {for(i=1; i<=3; i++) {getline; printf $0}}' ${tmpfile})
assertEquals "url=jdbc:mysql://db3/mydbusername=qa3userpassword=qa3secret" $(awk '/qa3/ {for(i=1; i<=3; i++) {getline; printf $0}}' ${tmpfile})
# turn off the environment and exit
teardown
exit 0