@@ -6,11 +6,23 @@ set -o nounset
66HERE=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
77cd " $HERE /.."
88
9+ export PATH=$PWD /build:$PATH
10+
11+ SKIP_CLEANUP=${SKIP_CLEANUP:- false}
12+
13+ starterpid=" " # pid of the cli plugin starter
914cleanup () {
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
1221}
13- trap cleanup EXIT
22+
23+ if [ " $SKIP_CLEANUP " != " true" ]; then
24+ trap cleanup EXIT
25+ fi
1426
1527# infrakit directories
1628plugins=~ /.infrakit/plugins
@@ -27,9 +39,9 @@ echo group > $leaderfile
2739
2840# start up multiple instances of manager -- typically we want multiple SETS of plugins and managers
2941# 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 &
3345
3446sleep 5 # manager needs to detect leadership
3547
@@ -47,10 +59,10 @@ export LOG_DIR=$LOG_DIR
4759export TUTORIAL_DIR=$TUTORIAL_DIR
4860
4961# 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 &
5163
52- lastpid =$!
53- echo " plugin start pid=$lastpid "
64+ starterpid =$!
65+ echo " plugin start pid=$starterpid "
5466
5567sleep 5
5668
@@ -90,33 +102,33 @@ expect_output_lines() {
90102 fi
91103}
92104
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"
95107
96108echo " Commiting"
97- build/ infrakit group commit docs/cattle.json
109+ infrakit group commit docs/cattle.json
98110
99111echo ' Waiting for group to be provisioned'
100112sleep 2
101113
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"
104116
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
107119
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"
109121
110122expect_exact_output \
111123 " 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" \
113125 " Committing cattle would involve: Performing a rolling update on 5 instances, then adding 5 instances to increase the group size to 10"
114126
115- build/ infrakit group commit docs/cattle2.json
127+ infrakit group commit docs/cattle2.json
116128
117129sleep 5
118130
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"
120132
121133# Terminate 3 instances.
122134pushd $TUTORIAL_DIR
125137
126138sleep 5
127139
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"
129141
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"
132144
133145echo ' ALL TESTS PASSED'
0 commit comments