Updated unit tests from 1.2

v1.1-maint
deajan 8 years ago
parent d00485e9db
commit 81571c605d

@ -1,185 +0,0 @@
#!/usr/bin/env bash
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2016 by Orsiris de Jong (www.netpower.fr)
###### osync v1.1x / v1.2x config file rev 2016102101
## ---------- GENERAL OPTIONS
## Sync job identification
INSTANCE_ID="local"
## Directories to synchronize.
## Initiator is the system osync runs on. The initiator directory must be a local path.
INITIATOR_SYNC_DIR="${HOME}/osync-tests/initiator"
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
TARGET_SYNC_DIR="${HOME}/osync-tests/target"
#TARGET_SYNC_DIR="ssh://backupuser@yourhost.old:22//home/git/osync/dir2"
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
## Alternatively, you may specify an SSH password file (less secure). Needs sshpass utility installed.
SSH_PASSWORD_FILE=""
## Create sync directories if they do not exist
CREATE_DIRS=no
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## Generate an alert if initiator or target replicas have less free space than given value in KB. Set this to zero to skip disk space tests.
MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
RSYNC_REMOTE_PATH=""
## Rsync exclude / include order (the option set here will be set first, eg: include will make include then exclude patterns)
RSYNC_PATTERN_FIRST=include
## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_INCLUDE_PATTERN=""
RSYNC_EXCLUDE_PATTERN="*.php"
#RSYNC_EXCLUDE_PATTERN="tmp;archives"
## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file.
## This file has to be in the same directory as the config file
## Paths are relative to sync dirs. One element per line.
RSYNC_INCLUDE_FROM=""
RSYNC_EXCLUDE_FROM=""
#RSYNC_EXCLUDE_FROM="exclude.list"
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## ---------- REMOTE SYNC OPTIONS
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=no
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=no
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
## ---------- MISC OPTIONS
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=yes
PRESERVE_OWNER=yes
PRESERVE_GROUP=yes
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=yes
## Preserve ACLS. Make sure source and target FS can manage same ACLs or you'll get loads of errors.
PRESERVE_ACL=yes
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=yes
## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=no
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=no
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=no
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## Log a message every KEEP_LOGGING seconds just to know the task is still alive
KEEP_LOGGING=1801
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
## Maximum time (in seconds) waiting in file monitor / daemon mode. After this time, sync is run.
## Use 0 to wait indefinitely.
MAX_WAIT=7200
## ---------- BACKUP AND DELETION OPTIONS
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=no
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
## ---------- RESUME OPTIONS
## Try to resume an aborted sync task
RESUME_SYNC=yes
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=no
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no
## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes
DELTA_COPIES=yes
## ---------- ALERT OPTIONS
## List of alert mails separated by spaces
DESTINATION_MAILS="your@alert.tld"
## Windows specific (msys / cygwin environment) only mail options (used with mailsend.exe from muquit, http://github.com/muquit/mailsend or from sendemail.exe from Brandon Zehm, http://caspian.dotconf.net/menu/Software/SendEmail/)
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_PORT=25
# encryption can be tls, ssl or none
SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
## ---------- EXECUTION HOOKS
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
LOCAL_RUN_BEFORE_CMD=""
LOCAL_RUN_AFTER_CMD=""
REMOTE_RUN_BEFORE_CMD=""
REMOTE_RUN_AFTER_CMD=""
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=no

@ -1,126 +0,0 @@
#!/bin/bash
###### Osync - Rsync based two way sync engine with fault tolerance
###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
#### Config file rev 0211201302
## ---------- GENERAL OPTIONS
## Sync job identification
SYNC_ID="old"
## Directories to synchronize. Master must be on the system Osync runs on. Slave can be either on the same system, or on a remote one.
MASTER_SYNC_DIR="${HOME}/osync-tests/initiator"
SLAVE_SYNC_DIR="${HOME}/osync-tests/target"
## Create sync directories if they do not exist
CREATE_DIRS=no
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## List of directories to exclude from sync on both sides (rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_EXCLUDE_PATTERN="tmp;archives"
## List elements separator char. You may set an alternative seperator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## Generate an alert if master or slave replicas have less free space than given value in KB.
MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## ---------- REMOTE SYNC OPTIONS
## The following options allow Osync to sync a slave replica on a remote system via an SSH tunnel.
## Needs public RSA key need to be put into ~/.ssh/authorized_keys in remote users home directory. See documentation for remote sync.
REMOTE_SYNC=no
SSH_RSA_PRIVATE_KEY=~/.ssh/id_rsa
REMOTE_USER=syncuser
REMOTE_HOST=your-remote-host.tld
REMOTE_PORT=22
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=no
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS=""
## Remote rsync executable path. Leave this empty in most cases
REMOTE_RSYNC_PATH=""
## ---------- MISC OPTIONS
## Preserve ACLS. Make sure source and target FS can manage same ACLs or you'll get loads of errors.
PRESERVE_ACL=no
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=no
## Let RSYNC compress file transfers. Do not use this if both master and slave replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
## Maximum execution time (in seconds) for sync process. Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## ---------- BACKUP AND TRASH OPTIONS
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=no
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=master
## On deletition propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## ---------- RESUME OPTIONS
## Try to resume an aborted sync task
RESUME_SYNC=yes
## Number maximum resume tries before initating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to master's sync-id, force pidlock removal. Be carefull with this option if you have multiple masters.
FORCE_STRANGER_LOCK_RESUME=no
## ---------- ALERT OPTIONS
## List of alert mails separated by spaces
DESTINATION_MAILS="your@alert.tld"
## Windows (MSYS environment) only mail options (used by sendemail.exe)
SENDER_MAIL="alert@your.system"
SMTP_SERVER=smtp.your.isp.com
SMTP_USER=
SMTP_PASSWORD=
## ---------- EXECUTION HOOKS
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_SYNC is set).
LOCAL_RUN_BEFORE_CMD=""
LOCAL_RUN_AFTER_CMD=""
REMOTE_RUN_BEFORE_CMD=""
REMOTE_RUN_AFTER_CMD=""
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops Osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes

@ -1,185 +0,0 @@
#!/usr/bin/env bash
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2016 by Orsiris de Jong (www.netpower.fr)
###### osync v1.1x / v1.2x config file rev 2016102101
## ---------- GENERAL OPTIONS
## Sync job identification
INSTANCE_ID="remote"
## Directories to synchronize.
## Initiator is the system osync runs on. The initiator directory must be a local path.
INITIATOR_SYNC_DIR="${HOME}/osync-tests/initiator"
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
#TARGET_SYNC_DIR="${HOME}/osync-tests/target"
TARGET_SYNC_DIR="ssh://travis@localhost:22/${HOME}/osync-tests/target"
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
SSH_RSA_PRIVATE_KEY="${HOME}/.ssh/id_rsa_local"
## Alternatively, you may specify an SSH password file (less secure). Needs sshpass utility installed.
SSH_PASSWORD_FILE=""
## Create sync directories if they do not exist
CREATE_DIRS=no
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## Generate an alert if initiator or target replicas have less free space than given value in KB. Set this to zero to skip disk space tests.
MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
RSYNC_REMOTE_PATH=""
## Rsync exclude / include order (the option set here will be set first, eg: include will make include then exclude patterns)
RSYNC_PATTERN_FIRST=include
## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_INCLUDE_PATTERN=""
RSYNC_EXCLUDE_PATTERN="*.php"
#RSYNC_EXCLUDE_PATTERN="tmp;archives"
## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file.
## This file has to be in the same directory as the config file
## Paths are relative to sync dirs. One element per line.
RSYNC_INCLUDE_FROM=""
RSYNC_EXCLUDE_FROM=""
#RSYNC_EXCLUDE_FROM="exclude.list"
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## ---------- REMOTE SYNC OPTIONS
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=no
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=no
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS=""
## ---------- MISC OPTIONS
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=yes
PRESERVE_OWNER=yes
PRESERVE_GROUP=yes
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=yes
## Preserve ACLS. Make sure source and target FS can manage same ACLs or you'll get loads of errors.
PRESERVE_ACL=yes
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=yes
## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=no
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=no
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=no
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## Log a message every KEEP_LOGGING seconds just to know the task is still alive
KEEP_LOGGING=1801
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
## Maximum time (in seconds) waiting in file monitor / daemon mode. After this time, sync is run.
## Use 0 to wait indefinitely.
MAX_WAIT=7200
## ---------- BACKUP AND DELETION OPTIONS
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=no
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
## ---------- RESUME OPTIONS
## Try to resume an aborted sync task
RESUME_SYNC=yes
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=no
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no
## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes
DELTA_COPIES=yes
## ---------- ALERT OPTIONS
## List of alert mails separated by spaces
DESTINATION_MAILS=""
## Windows specific (msys / cygwin environment) only mail options (used with mailsend.exe from muquit, http://github.com/muquit/mailsend or from sendemail.exe from Brandon Zehm, http://caspian.dotconf.net/menu/Software/SendEmail/)
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_PORT=25
# encryption can be tls, ssl or none
SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
## ---------- EXECUTION HOOKS
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
LOCAL_RUN_BEFORE_CMD=""
LOCAL_RUN_AFTER_CMD=""
REMOTE_RUN_BEFORE_CMD=""
REMOTE_RUN_AFTER_CMD=""
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=no

@ -154,7 +154,7 @@ DELTA_COPIES=yes
## ---------- ALERT OPTIONS
## List of alert mails separated by spaces
DESTINATION_MAILS="your@alert.tld"
DESTINATION_MAILS=""
## Windows specific (msys / cygwin environment) only mail options (used with mailsend.exe from muquit, http://github.com/muquit/mailsend or from sendemail.exe from Brandon Zehm, http://caspian.dotconf.net/menu/Software/SendEmail/)
SENDER_MAIL="alert@your.system.tld"

@ -7,7 +7,7 @@
## On CYGWIN / MSYS, ACL and extended attributes aren't supported
# osync test suite 2016120401
# osync test suite 2016120901
# 4 tests:
# quicklocal
@ -37,13 +37,16 @@
# setfacl needs double ':' to be compatible with both linux and BSD
# setfacl -m o::rwx file
LARGE_FILESET_URL="http://ftp.drupal.org/files/projects/drupal-8.2.2.tar.gz"
# drupal servers are often unreachable for whetever reason or give 0 bytes files
#LARGE_FILESET_URL="http://ftp.drupal.org/files/projects/drupal-8.2.2.tar.gz"
LARGE_FILESET_URL="http://www.netpower.fr/sites/default/files/osync-test-files-drupal-8.2.2.tar.gz"
OSYNC_DIR="$(pwd)"
OSYNC_DIR=${OSYNC_DIR%%/dev*}
DEV_DIR="$OSYNC_DIR/dev"
TESTS_DIR="$DEV_DIR/tests"
CONF_DIR="$TESTS_DIR/conf"
LOCAL_CONF="local.conf"
REMOTE_CONF="remote.conf"
OLD_CONF="old.conf"
@ -55,17 +58,6 @@ OSYNC_UPGRADE="upgrade-v1.0x-v1.2x.sh"
TMP_FILE="$DEV_DIR/tmp"
if [ "$TRAVIS_RUN" == true ]; then
echo "Running with travis settings"
CONF_DIR="$TESTS_DIR/conf-travis"
SSH_PORT=22
else
echo "Running with local settings"
CONF_DIR="$TESTS_DIR/conf-local"
SSH_PORT=49999
fi
OSYNC_TESTS_DIR="${HOME}/osync-tests"
INITIATOR_DIR="$OSYNC_TESTS_DIR/initiator"
TARGET_DIR="$OSYNC_TESTS_DIR/target"
@ -122,6 +114,9 @@ function SetupSSH {
if [ -z "$(ssh-keygen -F localhost)" ]; then
ssh-keyscan -H localhost >> "${HOME}/.ssh/known_hosts"
fi
# Update remote conf files with SSH port
sed -i.tmp 's#ssh://.*@localhost:[0-9]*/${HOME}/osync-tests/target#ssh://'$REMOTE_USER'@localhost:'$SSH_PORT'/${HOME}/osync-tests/target#' "$CONF_DIR/$REMOTE_CONF"
}
function RemoveSSH {
@ -178,7 +173,7 @@ function PrepareLocalDirs () {
rm -rf "$INITIATOR_DIR"
fi
mkdir -p "$INITIATOR_DIR"
if [ -d "$TARGET_DIR" ]; then
rm -rf "$TARGET_DIR"
fi
@ -191,6 +186,24 @@ function oneTimeSetUp () {
source "$DEV_DIR/ofunctions.sh"
GetLocalOS
echo "Detected OS: $LOCAL_OS"
# Set some travis related changes
if [ "$TRAVIS_RUN" == true ]; then
echo "Running with travis settings"
REMOTE_USER="travis"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "REMOTE_3RD_PARTY_HOSTS" ""
else
echo "Running with local settings"
REMOTE_USER="root"
SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "REMOTE_3RD_PARTY_HOSTS" "\"www.kernel.org www.google.com\""
fi
# Get default ssh port from env
if [ "$SSH_PORT" == "" ]; then
SSH_PORT=22
fi
# Setup modes per test
readonly __quickLocal=0
readonly __quickRemote=1
@ -208,7 +221,7 @@ function oneTimeSetUp () {
osyncDaemonParameters[$__local]="$CONF_DIR/$LOCAL_CONF --on-changes"
if [ "$LOCAL_OS" != "msys" ]; then
if [ "$LOCAL_OS" != "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then
osyncParameters[$__quickRemote]="--initiator=$INITIATOR_DIR --target=ssh://localhost:$SSH_PORT/$TARGET_DIR --rsakey=${HOME}/.ssh/id_rsa_local --instance-id=quickremote"
osyncParameters[$__confRemote]="$CONF_DIR/$REMOTE_CONF"
@ -263,6 +276,7 @@ function oneTimeTearDown () {
#TODO: uncomment this when dev is done
#rm -rf "$OSYNC_TESTS_DIR"
rm -f "$TMP_FILE"
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "It took $ELAPSED_TIME seconds to run these tests."
@ -374,7 +388,7 @@ function test_Deletetion () {
}
function test_deletion_failure () {
if [ "$LOCAL_OS" == "WinNT10" ]; then
if [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ]; then
echo "Skipping deletion failure test as Win10 does not have chattr support."
return 0
fi
@ -448,7 +462,12 @@ function test_skip_deletion () {
return 0
fi
modes=('initiator' 'target' 'initiator,target')
# TRAVIS SPECIFIC - time limitation
if [ "$TRAVIS_RUN" != true ]; then
modes=('initiator' 'target' 'initiator,target')
else
modes=('target')
fi
for mode in "${modes[@]}"; do
@ -517,8 +536,13 @@ function test_handle_symlinks () {
return 0
fi
if [ "$LOCAL_OS" == "msys" ]; then
echo "Skipping symlink tests because msys handles them strangely or not at all."
return 0
fi
# Check with and without copySymlinks
copySymlinks="yes"
copySymlinks="no"
echo "Running with COPY_SYMLINKS=$copySymlinks"
@ -558,13 +582,13 @@ function test_handle_symlinks () {
assertEquals "Second symlink deletion run with parameters [$i]." "0" $?
# symlink deletion propagation
[ ! -f "$TARGET_DIR/$FileAL" ]
[ ! -L "$TARGET_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$FileAL] is still present in replica dir." "0" $?
[ -f "$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL" ]
[ -L "$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL] is not present in deletion dir." "0" $?
[ ! -f "$INITIATOR_DIR/$FileBL" ]
[ ! -L "$INITIATOR_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$FileBL] is still present in replica dir." "0" $?
[ -f "$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL" ]
[ -L "$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL] is not present in deletion dir." "0" $?
# Create broken symlinks and propagate them
@ -574,12 +598,12 @@ function test_handle_symlinks () {
rm -f "$TARGET_DIR/$FileB"
COPY_SYMLINKS=$copySymlinks REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE $i
assertEquals "Third broken symlink run with parameters should fail [$i]." "1" $?
assertEquals "Third broken symlink run with parameters [$i]." "0" $?
[ ! -f "$TARGET_DIR/$FileAL" ]
[ -L "$TARGET_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$FileAL] is present in replica dir." "0" $?
[ ! -f "$INITIATOR_DIR/$FileBL" ]
[ -L "$INITIATOR_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$FileBL] is present in replica dir." "0" $?
# Check broken symlink deletion propagation
@ -587,20 +611,25 @@ function test_handle_symlinks () {
rm -f "$TARGET_DIR/$FileBL"
COPY_SYMLINKS=$copySymlinks REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE $i
assertEquals "Fourth symlink deletion run should resume with parameters [$i]." "2" $?
assertEquals "Fourth symlink deletion run with parameters [$i]." "0" $?
[ ! -f "$TARGET_DIR/$FileAL" ]
[ ! -L "$TARGET_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$FileAL] is still present in replica dir." "0" $?
[ -f "$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL" ]
[ -L "$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL] is not present in deletion dir." "0" $?
[ ! -f "$INITIATOR_DIR/$FileBL" ]
[ ! -L "$INITIATOR_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$FileBL] is still present in replica dir." "0" $?
[ -f "$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL" ]
[ -L "$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL] is not present in deletion dir." "0" $?
done
# TRAVIS SPECIFIC - time limitation
if [ "$TRAVIS_RUN" != true ]; then
return 0
fi
# Check with and without copySymlinks
copySymlinks="no"
copySymlinks="yes"
echo "Running with COPY_SYMLINKS=$copySymlinks"
@ -640,13 +669,13 @@ function test_handle_symlinks () {
assertEquals "Second symlink deletion run with parameters [$i]." "0" $?
# symlink deletion propagation
[ ! -L "$TARGET_DIR/$FileAL" ]
[ ! -f "$TARGET_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$FileAL] is still present in replica dir." "0" $?
[ -L "$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL" ]
[ -f "$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL] is not present in deletion dir." "0" $?
[ ! -L "$INITIATOR_DIR/$FileBL" ]
[ ! -f "$INITIATOR_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$FileBL] is still present in replica dir." "0" $?
[ -L "$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL" ]
[ -f "$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL] is not present in deletion dir." "0" $?
# Create broken symlinks and propagate them
@ -656,12 +685,12 @@ function test_handle_symlinks () {
rm -f "$TARGET_DIR/$FileB"
COPY_SYMLINKS=$copySymlinks REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE $i
assertEquals "Third broken symlink run with parameters [$i]." "0" $?
assertEquals "Third broken symlink run with parameters should fail [$i]." "1" $?
[ -L "$TARGET_DIR/$FileAL" ]
[ ! -f "$TARGET_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$FileAL] is present in replica dir." "0" $?
[ -L "$INITIATOR_DIR/$FileBL" ]
[ ! -f "$INITIATOR_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$FileBL] is present in replica dir." "0" $?
# Check broken symlink deletion propagation
@ -669,15 +698,15 @@ function test_handle_symlinks () {
rm -f "$TARGET_DIR/$FileBL"
COPY_SYMLINKS=$copySymlinks REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE $i
assertEquals "Fourth symlink deletion run with parameters [$i]." "0" $?
assertEquals "Fourth symlink deletion run should resume with parameters [$i]." "2" $?
[ ! -L "$TARGET_DIR/$FileAL" ]
[ ! -f "$TARGET_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$FileAL] is still present in replica dir." "0" $?
[ -L "$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL" ]
[ -f "$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL" ]
assertEquals "File [$TARGET_DIR/$OSYNC_DELETE_DIR/$FileAL] is not present in deletion dir." "0" $?
[ ! -L "$INITIATOR_DIR/$FileBL" ]
[ ! -f "$INITIATOR_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$FileBL] is still present in replica dir." "0" $?
[ -L "$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL" ]
[ -f "$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL" ]
assertEquals "File [$INITIATOR_DIR/$OSYNC_DELETE_DIR/$FileBL] is not present in deletion dir." "0" $?
done
}
@ -711,7 +740,7 @@ function test_softdeletion_cleanup () {
touch "$file.new"
if [ "$TRAVIS_RUN" == true ] || [ "$LOCAL_OS" == "BSD" ] || [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "WinNT10" ] || [ "LOCAL_OS" == "msys" ]; then
if [ "$TRAVIS_RUN" == true ] || [ "$LOCAL_OS" == "BSD" ] || [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then
echo "Skipping changing ctime on file because travis / bsd / macos / Win10 / msys / cygwin does not support debugfs"
else
CreateOldFile "$file.old"
@ -726,7 +755,7 @@ function test_softdeletion_cleanup () {
[ -f "$file.new" ]
assertEquals "New softdeleted / backed up file [$file.new] exists." "0" $?
if [ "$TRAVIS_RUN" == true ] || [ "$LOCAL_OS" == "BSD" ] || [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ]; then
if [ "$TRAVIS_RUN" == true ] || [ "$LOCAL_OS" == "BSD" ] || [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then
[ ! -f "$file.old" ]
assertEquals "Old softdeleted / backed up file [$file.old] is deleted permanently." "0" $?
else
@ -745,8 +774,8 @@ function test_FileAttributePropagation () {
return 0
fi
if [ "$LOCAL_OS" == "MacOSX" ]; then
echo "Skipping FileAttributePropagation tests because Mac OSX does not support ACL."
if [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "msys" ]; then
echo "Skipping FileAttributePropagation tests because [$LOCAL_OS] does not support ACL."
return 0
fi
@ -951,19 +980,21 @@ function test_Locking () {
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confLocal]}
assertEquals "Should be able to resume locked target with same instance_id in confLocal mode." "0" $?
PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@quickremote > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
if [ "$LOCAL_OS" != "msys" ]; then
PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@quickremote > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__quickRemote]}
assertEquals "Should be able to resume locked target with same instance_id in quickRemote mode." "0" $?
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__quickRemote]}
assertEquals "Should be able to resume locked target with same instance_id in quickRemote mode." "0" $?
PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@remote > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@remote > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confRemote]}
assertEquals "Should be able to resume locked target with same instance_id in confRemote mode." "0" $?
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confRemote]}
assertEquals "Should be able to resume locked target with same instance_id in confRemote mode." "0" $?
fi
# Remote Target lock present should not be resumed if instance ID is NOT the same as current one, local target lock is resumed
PrepareLocalDirs
@ -980,19 +1011,21 @@ function test_Locking () {
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confLocal]}
assertEquals "Should be able to resume locked local target with bogus instance_id in confLocal mode." "0" $?
PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@bogusinstance > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
if [ "$LOCAL_OS" != "msys" ]; then
PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@bogusinstance > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__quickRemote]}
assertEquals "Should not be able to resume remote locked target with bogus instance_id in quickRemote mode." "1" $?
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__quickRemote]}
assertEquals "Should not be able to resume remote locked target with bogus instance_id in quickRemote mode." "1" $?
PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@bogusinstance > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@bogusinstance > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confRemote]}
assertEquals "Should not be able to resume remote locked target with bgous instance_id in confRemote mode." "1" $?
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confRemote]}
assertEquals "Should not be able to resume remote locked target with bogus instance_id in confRemote mode." "1" $?
fi
# Target lock present should be resumed if instance ID is NOT the same as current one but FORCE_STRANGER_UNLOCK=yes
@ -1168,7 +1201,6 @@ function test_ParallelExec () {
cmd="sleep 4;du /none;sleep 3;du /none;sleep 2"
ParallelExec 3 "$cmd" false 1 2 .05 7000 true true false ${FUNCNAME[0]}
assertNotEquals "ParallelExec full test 3" "0" $?
}
function test_timedExecution () {
@ -1241,8 +1273,8 @@ function test_UpgradeConfRun () {
}
function test_DaemonMode () {
if [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ]; then
echo "Skipping daemon mode test as Win10 does not have inotifywait support."
if [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then
echo "Skipping daemon mode test as [$LOCAL_OS] does not have inotifywait support."
return 0
fi

Loading…
Cancel
Save