@@ -6,11 +6,23 @@ set -o nounset
6
6
HERE=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
7
7
cd " $HERE /.."
8
8
9
+ export PATH=$PWD /build:$PATH
10
+
11
+ SKIP_CLEANUP=${SKIP_CLEANUP:- false}
12
+
13
+ starterpid=" " # pid of the cli plugin starter
9
14
cleanup () {
10
- kill $( jobs -p)
11
- rm -rf tutorial
15
+ pgid=$( ps -o pgid= -p $starterpid )
16
+ echo " Stopping plugin starter utility - $starterpid , pgid=$pgid "
17
+ kill -TERM -$pgid
18
+ echo " Stopping other jobs"
19
+ kill $( jobs -p)
20
+ rm -rf tutorial
12
21
}
13
- trap cleanup EXIT
22
+
23
+ if [ " $SKIP_CLEANUP " != " true" ]; then
24
+ trap cleanup EXIT
25
+ fi
14
26
15
27
# infrakit directories
16
28
plugins=~ /.infrakit/plugins
@@ -27,9 +39,9 @@ echo group > $leaderfile
27
39
28
40
# start up multiple instances of manager -- typically we want multiple SETS of plugins and managers
29
41
# but here for simplicity just start up with multiple managers and one set of plugins
30
- build/ infrakit-manager --name group --proxy-for-group group-stateless os --leader-file $leaderfile --store-dir $configstore &
31
- build/ infrakit-manager --name group1 --proxy-for-group group-stateless os --leader-file $leaderfile --store-dir $configstore &
32
- build/ infrakit-manager --name group2 --proxy-for-group group-stateless os --leader-file $leaderfile --store-dir $configstore &
42
+ infrakit-manager --name group --proxy-for-group group-stateless os --leader-file $leaderfile --store-dir $configstore &
43
+ infrakit-manager --name group1 --proxy-for-group group-stateless os --leader-file $leaderfile --store-dir $configstore &
44
+ infrakit-manager --name group2 --proxy-for-group group-stateless os --leader-file $leaderfile --store-dir $configstore &
33
45
34
46
sleep 5 # manager needs to detect leadership
35
47
@@ -47,10 +59,10 @@ export LOG_DIR=$LOG_DIR
47
59
export TUTORIAL_DIR=$TUTORIAL_DIR
48
60
49
61
# note -- on exit, this won't clean up the plugins started by the cli since they will be in a separate process group
50
- build/ infrakit plugin start --wait --config-url file:///$PWD /scripts/tutorial-start-plugins.json --os group-default instance-file flavor-vanilla &
62
+ infrakit plugin start --wait --config-url file:///$PWD /scripts/tutorial-start-plugins.json --os group-default instance-file flavor-vanilla &
51
63
52
- lastpid =$!
53
- echo " plugin start pid=$lastpid "
64
+ starterpid =$!
65
+ echo " plugin start pid=$starterpid "
54
66
55
67
sleep 5
56
68
@@ -90,33 +102,33 @@ expect_output_lines() {
90
102
fi
91
103
}
92
104
93
- expect_output_lines " 6 plugins should be discoverable" " build/ infrakit plugin ls -q" " 6"
94
- expect_output_lines " 0 instances should exist" " build/ infrakit instance describe -q --name instance-file" " 0"
105
+ expect_output_lines " 6 plugins should be discoverable" " infrakit plugin ls -q" " 6"
106
+ expect_output_lines " 0 instances should exist" " infrakit instance describe -q --name instance-file" " 0"
95
107
96
108
echo " Commiting"
97
- build/ infrakit group commit docs/cattle.json
109
+ infrakit group commit docs/cattle.json
98
110
99
111
echo ' Waiting for group to be provisioned'
100
112
sleep 2
101
113
102
- expect_output_lines " 5 instances should exist in group" " build/ infrakit group describe cattle -q" " 5"
103
- expect_output_lines " 5 instances should exist" " build/ infrakit instance describe -q --name instance-file" " 5"
114
+ expect_output_lines " 5 instances should exist in group" " infrakit group describe cattle -q" " 5"
115
+ expect_output_lines " 5 instances should exist" " infrakit instance describe -q --name instance-file" " 5"
104
116
105
- build/ infrakit group free cattle
106
- build/ infrakit group commit docs/cattle.json
117
+ infrakit group free cattle
118
+ infrakit group commit docs/cattle.json
107
119
108
- expect_exact_output " Should be watching one group" " build/ infrakit group ls -q" " cattle"
120
+ expect_exact_output " Should be watching one group" " infrakit group ls -q" " cattle"
109
121
110
122
expect_exact_output \
111
123
" Update should roll 5 and scale group to 10" \
112
- " build/ infrakit group commit docs/cattle2.json --pretend" \
124
+ " infrakit group commit docs/cattle2.json --pretend" \
113
125
" Committing cattle would involve: Performing a rolling update on 5 instances, then adding 5 instances to increase the group size to 10"
114
126
115
- build/ infrakit group commit docs/cattle2.json
127
+ infrakit group commit docs/cattle2.json
116
128
117
129
sleep 5
118
130
119
- expect_output_lines " 10 instances should exist in group" " build/ infrakit group describe cattle -q" " 10"
131
+ expect_output_lines " 10 instances should exist in group" " infrakit group describe cattle -q" " 10"
120
132
121
133
# Terminate 3 instances.
122
134
pushd $TUTORIAL_DIR
125
137
126
138
sleep 5
127
139
128
- expect_output_lines " 10 instances should exist in group" " build/ infrakit group describe cattle -q" " 10"
140
+ expect_output_lines " 10 instances should exist in group" " infrakit group describe cattle -q" " 10"
129
141
130
- build/ infrakit group destroy cattle
131
- expect_output_lines " 0 instances should exist" " build/ infrakit instance describe -q --name instance-file" " 0"
142
+ infrakit group destroy cattle
143
+ expect_output_lines " 0 instances should exist" " infrakit instance describe -q --name instance-file" " 0"
132
144
133
145
echo ' ALL TESTS PASSED'
0 commit comments