2016-08-22 08:26:38 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-08-30 14:34:15 +00:00
|
|
|
# osync test suite 2016083002
|
2016-08-30 11:42:35 +00:00
|
|
|
# Add big fileset tests (eg: drupal 8 ?)
|
|
|
|
|
2016-08-22 08:26:38 +00:00
|
|
|
|
2016-08-30 11:52:58 +00:00
|
|
|
OSYNC_DIR="$(pwd)"
|
2016-08-30 14:34:15 +00:00
|
|
|
OSYNC_DIR=${OSYNC_DIR%%/dev*}
|
2016-08-30 11:52:58 +00:00
|
|
|
DEV_DIR="$OSYNC_DIR/dev"
|
|
|
|
TESTS_DIR="$DEV_DIR/tests"
|
2016-08-30 11:42:35 +00:00
|
|
|
|
2016-08-30 14:34:15 +00:00
|
|
|
OSYNC_EXECUTABLE="osync.sh"
|
2016-08-22 08:26:38 +00:00
|
|
|
|
2016-08-30 15:08:00 +00:00
|
|
|
INITIATOR_DIR="${HOME}/osync/initiator"
|
|
|
|
TARGET_DIR="${HOME}/osync/target"
|
2016-08-22 08:26:38 +00:00
|
|
|
OSYNC_STATE_DIR=".osync_workdir/state"
|
|
|
|
|
|
|
|
function CreateReplicas () {
|
|
|
|
if [ -d "$INITIATOR_DIR" ]; then
|
|
|
|
rm -rf "$INITIATOR_DIR"
|
|
|
|
fi
|
|
|
|
mkdir -p "$INITIATOR_DIR"
|
|
|
|
|
|
|
|
if [ -d "$TARGET_DIR" ]; then
|
|
|
|
rm -rf "$TARGET_DIR"
|
|
|
|
fi
|
|
|
|
mkdir -p "$TARGET_DIR"
|
|
|
|
}
|
|
|
|
|
|
|
|
function oneTimeSetUp () {
|
|
|
|
source "$DEV_DIR/ofunctions.sh"
|
|
|
|
}
|
|
|
|
|
|
|
|
function oneTimeTearDown () {
|
|
|
|
if [ "$IS_STABLE" == "no" ]; then
|
2016-08-30 15:08:00 +00:00
|
|
|
sed -i.tmp 's/^IS_STABLE=yes/IS_STABLE=no/' "$OSYNC_DIR/$OSYNC_EXECUTABLE"
|
2016-08-22 08:26:38 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-08-30 14:34:15 +00:00
|
|
|
function test_Merge () {
|
|
|
|
cd "$DEV_DIR"
|
|
|
|
./merge.sh
|
|
|
|
assertEquals "Merging code" "0" $?
|
|
|
|
}
|
|
|
|
|
2016-08-30 15:08:00 +00:00
|
|
|
function test_SetStable () {
|
|
|
|
if grep "^IS_STABLE=YES" "$OSYNC_DIR/$OSYNC_EXECUTABLE" > /dev/null; then
|
|
|
|
IS_STABLE=yes
|
|
|
|
echo "Is already set as stable"
|
|
|
|
else
|
|
|
|
IS_STABLE=no
|
|
|
|
sed -i.tmp 's/^IS_STABLE=no/IS_STABLE=yes/' "$OSYNC_DIR/$OSYNC_EXECUTABLE"
|
|
|
|
assertEquals "Set as stable" "0" $?
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-08-22 08:26:38 +00:00
|
|
|
function test_osync_quicksync_local () {
|
|
|
|
CreateReplicas
|
2016-08-30 15:08:00 +00:00
|
|
|
cd "$OSYNC_DIR"
|
|
|
|
./$OSYNC_EXECUTABLE --initiator="$INITIATOR_DIR" --target="$TARGET_DIR"
|
2016-08-22 08:26:38 +00:00
|
|
|
assertEquals "Return code" "0" $?
|
|
|
|
|
|
|
|
[ -d "$INITIATOR_DIR/$OSYNC_STATE_DIR" ]
|
|
|
|
assertEquals "Initiator state dir exists" "0" $?
|
|
|
|
|
|
|
|
[ -d "$TARGET_DIR/$OSYNC_STATE_DIR" ]
|
|
|
|
assertEquals "Target state dir exists" "0" $?
|
|
|
|
}
|
|
|
|
|
2016-08-29 15:40:32 +00:00
|
|
|
|
|
|
|
function test_osync_quicksync_remote () {
|
|
|
|
CreateReplicas
|
2016-08-30 15:08:00 +00:00
|
|
|
cd "$OSYNC_DIR"
|
2016-08-30 14:34:15 +00:00
|
|
|
./$OSYNC_EXECUTABLE --initiator="$INITIATOR_DIR" --target="ssh://localhost:49999/$TARGET_DIR" --rsakey=/root/.ssh/id_rsa_local > /dev/null
|
2016-08-29 15:40:32 +00:00
|
|
|
assertEquals "Return code" "0" $?
|
|
|
|
|
|
|
|
[ -d "$INITIATOR_DIR/$OSYNC_STATE_DIR" ]
|
|
|
|
assertEquals "Initiator state dir exists" "0" $?
|
|
|
|
|
|
|
|
[ -d "$TARGET_DIR/$OSYNC_STATE_DIR" ]
|
|
|
|
assertEquals "Target state dir exists" "0" $?
|
|
|
|
}
|
|
|
|
|
2016-08-30 11:42:35 +00:00
|
|
|
. "$TESTS_DIR/shunit2/shunit2"
|