Added upgrade script test

This commit is contained in:
deajan 2016-10-23 19:17:25 +02:00
parent bd2265b76c
commit 0bd6f61a34
1 changed files with 43 additions and 4 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# osync test suite 2016101601 # osync test suite 2016102301
# 4 tests: # 4 tests:
# quicklocal # quicklocal
@ -24,7 +24,8 @@
#TODO: conflict resolution missing #TODO: conflict resolution missing
#TODO: softdelete missing #TODO: softdelete missing
#TODO: lock checks missing #TODO: lock checks missing
#TODO: fille attribute missing #TODO: file attribute missing
#TODO: skip deletion tests
TEST_DISK=/dev/vda1 TEST_DISK=/dev/vda1
LARGE_FILESET_URL="http://ftp.drupal.org/files/projects/drupal-8.1.9.tar.gz" LARGE_FILESET_URL="http://ftp.drupal.org/files/projects/drupal-8.1.9.tar.gz"
@ -34,10 +35,17 @@ OSYNC_DIR=${OSYNC_DIR%%/dev*}
DEV_DIR="$OSYNC_DIR/dev" DEV_DIR="$OSYNC_DIR/dev"
TESTS_DIR="$DEV_DIR/tests" TESTS_DIR="$DEV_DIR/tests"
LOCAL_CONF="local.conf"
REMOTE_CONF="remote.conf"
OLD_CONF="old.conf"
TMP_OLD_CONF="tmp.old.conf"
OSYNC_EXECUTABLE="osync.sh" OSYNC_EXECUTABLE="osync.sh"
OSYNC_UPGRADE="upgrade-v1.0x-v1.2x.sh"
TMP_FILE="$DEV_DIR/tmp" TMP_FILE="$DEV_DIR/tmp"
if [ "$TRAVIS_RUN" == true ]; then if [ "$TRAVIS_RUN" == true ]; then
echo "Running with travis settings" echo "Running with travis settings"
CONF_DIR="$TESTS_DIR/conf-travis" CONF_DIR="$TESTS_DIR/conf-travis"
@ -48,8 +56,8 @@ else
SSH_PORT=49999 SSH_PORT=49999
fi fi
INITIATOR_DIR="${HOME}/osync/initiator" INITIATOR_DIR="${HOME}/osync-tests/initiator"
TARGET_DIR="${HOME}/osync/target" TARGET_DIR="${HOME}/osync-tests/target"
OSYNC_WORKDIR=".osync_workdir" OSYNC_WORKDIR=".osync_workdir"
OSYNC_STATE_DIR="$OSYNC_WORKDIR/state" OSYNC_STATE_DIR="$OSYNC_WORKDIR/state"
OSYNC_DELETE_DIR="$OSYNC_WORKDIR/deleted" OSYNC_DELETE_DIR="$OSYNC_WORKDIR/deleted"
@ -138,6 +146,11 @@ function oneTimeTearDown () {
SetStableToOrigin SetStableToOrigin
} }
function setUp () {
rm -rf "$INITIATOR_DIR"
rm -rf "$TARGET_DIR"
}
function test_Merge () { function test_Merge () {
cd "$DEV_DIR" cd "$DEV_DIR"
./merge.sh ./merge.sh
@ -226,6 +239,9 @@ function test_Deletetion () {
function test_osync_quicksync_local () { function test_osync_quicksync_local () {
cd "$OSYNC_DIR" cd "$OSYNC_DIR"
PrepareLocalDirs
./$OSYNC_EXECUTABLE --initiator="$INITIATOR_DIR" --target="$TARGET_DIR" ./$OSYNC_EXECUTABLE --initiator="$INITIATOR_DIR" --target="$TARGET_DIR"
assertEquals "Return code" "0" $? assertEquals "Return code" "0" $?
@ -239,6 +255,9 @@ function test_osync_quicksync_local () {
function test_osync_quicksync_remote () { function test_osync_quicksync_remote () {
cd "$OSYNC_DIR" cd "$OSYNC_DIR"
PrepareLocalDirs
# Disable remote host ping because Travis can't ping # Disable remote host ping because Travis can't ping
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE --initiator="$INITIATOR_DIR" --target="ssh://localhost:$SSH_PORT/$TARGET_DIR" --rsakey="${HOME}/.ssh/id_rsa_local" REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE --initiator="$INITIATOR_DIR" --target="ssh://localhost:$SSH_PORT/$TARGET_DIR" --rsakey="${HOME}/.ssh/id_rsa_local"
assertEquals "Return code" "0" $? assertEquals "Return code" "0" $?
@ -342,4 +361,24 @@ function test_ParallelExec () {
} }
function test_UpgradeConfRun () {
# Basic return code tests. Need to go deep into file presence testing
cd "$OSYNC_DIR"
PrepareLocalDirs
# Make a security copy of the old config file
cp "$CONF_DIR/$OLD_CONF" "$CONF_DIR/$TMP_OLD_CONF"
./$OSYNC_UPGRADE "$CONF_DIR/$TMP_OLD_CONF"
assertEquals "Conf file upgrade" "0" $?
./$OSYNC_EXECUTABLE "$CONF_DIR/$TMP_OLD_CONF"
assertEquals "Upgraded conf file execution test" "0" $?
rm -f "$CONF_DIR/$TMP_OLD_CONF"
rm -f "$CONF_DIR/$TMP_OLD_CONF.save"
}
. "$TESTS_DIR/shunit2/shunit2" . "$TESTS_DIR/shunit2/shunit2"