Add CI test for local example scripts.

This commit is contained in:
Anthony Yeh 2015-10-29 17:40:11 -07:00
Родитель d4de115720
Коммит 785c99688a
4 изменённых файлов: 78 добавлений и 1 удалений

Просмотреть файл

@ -78,6 +78,7 @@ for uid_index in $uids; do
$VTROOT/bin/vttablet \
-log_dir $VTDATAROOT/tmp \
-tablet-path $alias \
-tablet_hostname `hostname -i` \
-init_keyspace $keyspace \
-init_shard $shard \
-target_tablet_type $tablet_type \

Просмотреть файл

@ -34,3 +34,4 @@ for zkid in $zkids; do
fi
done
echo "Started zk servers."

Просмотреть файл

@ -105,6 +105,17 @@
"site_test"
]
},
"local_example": {
"File": "",
"Args": [],
"Command": [
"test/local_example.sh"
],
"Manual": false,
"Shard": 0,
"RetryMax": 0,
"Tags": []
},
"mysqlctl": {
"File": "mysqlctl.py",
"Args": [],
@ -326,4 +337,4 @@
]
}
}
}
}

64
test/local_example.sh Executable file
Просмотреть файл

@ -0,0 +1,64 @@
#!/bin/bash
# This test runs through the scripts in examples/local to make sure they work.
# timeout in seconds (for each step, not overall)
timeout=30
cd $VTTOP/examples/local
exitcode=1
teardown() {
./vtgate-down.sh &
./vttablet-down.sh &
./vtctld-down.sh &
./zk-down.sh &
wait
exit $exitcode
}
trap teardown SIGTERM SIGINT
# Set up servers.
timeout $timeout ./zk-up.sh || teardown
timeout $timeout ./vtctld-up.sh || teardown
timeout $timeout ./vtgate-up.sh || teardown
timeout $timeout ./vttablet-up.sh || teardown
# Retry loop function
retry_with_timeout() {
if [ `date +%s` -gt $[$start + $timeout] ]; then
echo "Timeout ($timeout) exceeded"
teardown
fi
echo "Waiting 5 seconds to try again..."
sleep 5
}
echo "Rebuild keyspace..."
start=`date +%s`
until vtctlclient -server localhost:15999 RebuildKeyspaceGraph test_keyspace; do
retry_with_timeout
done
echo "Initialize shard..."
start=`date +%s`
until vtctlclient -server localhost:15999 InitShardMaster -force test_keyspace/0 test-0000000100; do
retry_with_timeout
done
echo "Create table..."
start=`date +%s`
until vtctlclient -server localhost:15999 ApplySchema -sql "$(cat create_test_table.sql)" test_keyspace; do
retry_with_timeout
done
echo "Run client script..."
start=`date +%s`
until ./client.sh; do
retry_with_timeout
done
exitcode=0
teardown