test: Don't block on graph transitions

Improvements in the engine have uncovered some annoying race conditions
which would cause the engine to block between transitions. This is a
test which catches the most obvious file based ones.

This requires inotify to work in the test environment.
This commit is contained in:
James Shubin
2017-02-22 16:50:00 -05:00
parent e070a85ae0
commit 3bd37a7906
3 changed files with 48 additions and 0 deletions

30
test/shell/yaml-change1.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash -e
#if env | grep -q -e '^TRAVIS=true$'; then
# # inotify doesn't seem to work properly on travis
# echo "Travis and Jenkins give wonky results here, skipping test!"
# exit
#fi
if [ -z $timeout ]; then
timeout='timeout'
fi
# set the config file
cp -a yaml-change1a.yaml /tmp/mgmt/yaml-change.yaml
$timeout --kill-after=30s 20s ./mgmt run --yaml /tmp/mgmt/yaml-change.yaml --tmp-prefix &
pid=$!
sleep 5s # let it converge
grep -q 'hello world' /tmp/mgmt/change1 # check contents are correct
cp -a yaml-change1b.yaml /tmp/mgmt/yaml-change.yaml # change the config file
sleep 2s # let it converge
grep -q 'goodbye world' /tmp/mgmt/change1 # check new contents are correct
cp -a yaml-change1a.yaml /tmp/mgmt/yaml-change.yaml # change the config file
sleep 2s # let it converge
grep -q 'hello world' /tmp/mgmt/change1 # check contents are correct again
killall -SIGINT mgmt # send ^C to exit mgmt
wait $pid # get exit status
exit $?