Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions mysql-test/include/have_mariabackup_wrapper.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ==== Purpose ====
#
# Redirect `$XTRABACKUP` so existing test invocations like
#
# --exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf \
# --backup --target-dir=$targetdir
#
# run through scripts/mariabackup/mariabackup.sh — the BACKUP SERVER
# compatibility wrapper — without any change to the test body.
#
#
# Skip the test if any of these are missing:
# - the wrapper script
# - bash
# - the mariadb client (wrapper shells out to it)
#
# ==== Usage ====
#
# --source include/have_mariabackup_wrapper.inc
# # ... rest of the test, using $XTRABACKUP as usual ...
#
# ==== Exposed variables ====
#
# $XTRABACKUP — now points at mariabackup.sh

--source include/linux.inc

--let MARIABACKUP_WRAPPER=$MYSQL_TEST_DIR/../scripts/mariabackup/mariabackup.sh

--error 0,1
perl;
use strict;
use warnings;
use File::Basename;

my $wrapper = $ENV{MARIABACKUP_WRAPPER};
exit 1 unless $wrapper && -x $wrapper;

chomp(my $bash = `command -v bash 2>/dev/null`);
exit 1 unless $bash && -x $bash;

# Prepend its directory to PATH so the bare `mariadb` invocation
# inside the wrapper resolves.
my ($mariadb) = split /\s+/, ($ENV{MYSQL} // '');
exit 1 unless $mariadb && -x $mariadb;
$ENV{PATH} = dirname($mariadb) . ":$ENV{PATH}";

exit 0;
EOF

if ($errno)
{
--skip mariabackup.sh wrapper unavailable (script, bash, or mariadb client missing)
}

--let XTRABACKUP=$MARIABACKUP_WRAPPER
31 changes: 31 additions & 0 deletions mysql-test/suite/mariabackup/wrapper_basic.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
#
# Full backup succeeds and runs BACKUP SERVER
#
FOUND 1 /Executing: BACKUP SERVER TO/ in wrapper.log
#
# (--parallel/--throttle/--no-lock/--safe-slave-backup)
#
FOUND 1 /Executing: BACKUP SERVER TO/ in wrapper.log
#
# --stream=mbstream emits a valid tar archive to stdout
#
FOUND 1 /Creating tar stream/ in wrapper.log
#
# --compress produces a valid gzip stream
#
FOUND 1 /Compressing with gzip/ in wrapper.log
#
# Backup into an already-existing target directory is rejected
#
FOUND 1 /Target directory already exists/ in wrapper.log
#
# Missing --target-dir is rejected
#
FOUND 1 /--target-dir required/ in wrapper.log
#
# Non-existent parent directory is rejected
#
FOUND 1 /Parent directory does not exist/ in wrapper.log
DROP TABLE t1;
82 changes: 82 additions & 0 deletions mysql-test/suite/mariabackup/wrapper_basic.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
--source include/have_mariabackup_wrapper.inc
--source include/have_innodb.inc

--let $defaults=--defaults-file=$MYSQLTEST_VARDIR/my.cnf
--let $logfile=$MYSQLTEST_VARDIR/tmp/wrapper.log
--let SEARCH_FILE=$logfile
--let SEARCH_ABORT=NOT FOUND

CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);

--echo #
--echo # Full backup succeeds and runs BACKUP SERVER
--echo #
--let $targetdir=$MYSQLTEST_VARDIR/tmp/bk_full
--exec $XTRABACKUP $defaults --backup --target-dir=$targetdir > $logfile 2>&1
--let SEARCH_PATTERN=Executing: BACKUP SERVER TO
--source include/search_pattern_in_file.inc
--rmdir $targetdir

--echo #
--echo # (--parallel/--throttle/--no-lock/--safe-slave-backup)
--echo #
--let $targetdir=$MYSQLTEST_VARDIR/tmp/bk_legacy
--exec $XTRABACKUP $defaults --backup --target-dir=$targetdir --parallel=4 --throttle=100 --no-lock --safe-slave-backup > $logfile 2>&1
--let SEARCH_PATTERN=Executing: BACKUP SERVER TO
--source include/search_pattern_in_file.inc
--rmdir $targetdir

--echo #
--echo # --stream=mbstream emits a valid tar archive to stdout
--echo #
--let $targetdir=$MYSQLTEST_VARDIR/tmp/bk_stream
--let $streamfile=$MYSQLTEST_VARDIR/tmp/bk_stream.tar
--exec $XTRABACKUP $defaults --backup --target-dir=$targetdir --stream=mbstream > $streamfile 2>$logfile
--exec tar -tf $streamfile > /dev/null
--let SEARCH_PATTERN=Creating tar stream
--source include/search_pattern_in_file.inc
--rmdir $targetdir
--remove_file $streamfile

--echo #
--echo # --compress produces a valid gzip stream
--echo #
--let $targetdir=$MYSQLTEST_VARDIR/tmp/bk_gz
--let $gzfile=$MYSQLTEST_VARDIR/tmp/bk.tar.gz
--exec $XTRABACKUP $defaults --backup --target-dir=$targetdir --compress > $gzfile 2>$logfile
--exec gzip -t $gzfile
--let SEARCH_PATTERN=Compressing with gzip
--source include/search_pattern_in_file.inc
--rmdir $targetdir
--remove_file $gzfile

--echo #
--echo # Backup into an already-existing target directory is rejected
--echo #
--let $targetdir=$MYSQLTEST_VARDIR/tmp/bk_exists
--mkdir $targetdir
--error 1
--exec $XTRABACKUP $defaults --backup --target-dir=$targetdir > $logfile 2>&1
--let SEARCH_PATTERN=Target directory already exists
--source include/search_pattern_in_file.inc
--rmdir $targetdir

--echo #
--echo # Missing --target-dir is rejected
--echo #
--error 1
--exec $XTRABACKUP $defaults --backup > $logfile 2>&1
--let SEARCH_PATTERN=--target-dir required
--source include/search_pattern_in_file.inc

--echo #
--echo # Non-existent parent directory is rejected
--echo #
--error 1
--exec $XTRABACKUP $defaults --backup --target-dir=$MYSQLTEST_VARDIR/tmp/no_such_parent/bk > $logfile 2>&1
--let SEARCH_PATTERN=Parent directory does not exist
--source include/search_pattern_in_file.inc

DROP TABLE t1;
--remove_file $logfile
Loading
Loading