-
Notifications
You must be signed in to change notification settings - Fork 19
/
kitchen.sh
executable file
·81 lines (66 loc) · 1.9 KB
/
kitchen.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
rm -f Berksfile.lock
set -eo pipefail
skip_converge=0
regex="test_src/services_spec.rb.(.+)"
boxes="test_src/box_(.+)"
for box in `ls test_src/box_* | grep -v *[#~]`
do
cp .kitchen.yml.old .kitchen.yml
if [[ $box =~ $boxes ]] ; then
b="${BASH_REMATCH[1]}"
echo "Testing box: ${b}"
perl -pi -e "s/XXXX/${b}/" .kitchen.yml
echo "test_src/box_${b}"
v=$(head -1 test_src/box_${b} | perl -pe 'chomp')
# escape the url
echo $v
v=$(echo $v | sed 's/\./\\\./g')
v=$(echo $v | sed 's/\_/\\\_/g')
v=$(echo $v | sed 's/\:/\\\:/g')
v=$(echo $v | sed 's/\//\\\//g')
echo $v
perl -pi -e "s/YYYY/${v}/" .kitchen.yml
echo "replaced text..."
fi
if [ $# -gt 0 ] ; then
if [ $1 == "-help" ] ; then
echo "usage: $0 [nodestroy [verify]]"
exit 0
elif [ $1 != "nodestroy" ] ; then
kitchen destroy
else
if [ $2 == "verify" ] ; then
skip_converge=1
fi
fi
else
kitchen destroy
fi
if [ $skip_converge -eq 0 ] ; then
for f in `ls test_src/services_spec.rb.* | grep -v *[#~]`
do
last_char="${f: -1}"
if [[ $f =~ $regex && "$last_char" != "~" && "$last_char" != "#" ]] ; then
name="${BASH_REMATCH[1]}"
echo "Converging default-${name}"
kitchen converge default-${name}
fi
done
fi
rm -f test/integration/default/serverspec/localhost/services_spec.rb
for f in `ls test_src/services_spec.rb.* | grep -v *[#~]`
do
if [[ $f =~ $regex ]] ; then
name="${BASH_REMATCH[1]}"
cp -f test_src/services_spec.rb.${name} test/integration/default/serverspec/localhost/services_spec.rb
echo "Verifying ${name}"
kitchen verify default-${name}
fi
done
rm test/integration/default/serverspec/localhost/services_spec.rb
kitchen destroy
done
cp .kitchen.yml.old .kitchen.yml
echo "Success"
exit 0