Commit fac9224d authored by Julius Goryavsky's avatar Julius Goryavsky

MDEV-27777: Some Galera tests fail on FreeBSD

This commit fixes problems due to bugs and quirks in bsdtar
(the FreeBSD version of tar). Separate tests are not required,
because without these fixes, many other tests fail when tested
in the FreeBSD environment.

Also, the grep patterns for reading utility version numbers
has been made more robust. The notation of some options of
the "cut" utility has been changed.
parent 17e0f522
...@@ -336,7 +336,7 @@ case "$1" in ...@@ -336,7 +336,7 @@ case "$1" in
else else
# If it's not bash, then we need to use slow # If it's not bash, then we need to use slow
# external utilities: # external utilities:
option=$(echo "$options" | cut -c1-1) option=$(echo "$options" | cut -c1)
fi fi
# And the subsequent characters consider option value: # And the subsequent characters consider option value:
value="" value=""
......
...@@ -323,7 +323,8 @@ get_transfer() ...@@ -323,7 +323,8 @@ get_transfer()
if [ "${sockopt#*,dhparam=}" != "$sockopt" ]; then if [ "${sockopt#*,dhparam=}" != "$sockopt" ]; then
if [ -z "$ssl_dhparams" ]; then if [ -z "$ssl_dhparams" ]; then
# Determine the socat version # Determine the socat version
SOCAT_VERSION=$(socat -V 2>&1 | grep -m1 -oe '[0-9]\.[0-9][\.0-9]*') SOCAT_VERSION=$(socat -V 2>&1 | \
grep -m1 -owE '[0-9]+(\.[0-9]+)+' | head -n1)
if [ -z "$SOCAT_VERSION" ]; then if [ -z "$SOCAT_VERSION" ]; then
wsrep_log_error "******** FATAL ERROR ******************" wsrep_log_error "******** FATAL ERROR ******************"
wsrep_log_error "* Cannot determine the socat version. *" wsrep_log_error "* Cannot determine the socat version. *"
...@@ -766,7 +767,7 @@ recv_joiner() ...@@ -766,7 +767,7 @@ recv_joiner()
# check donor supplied secret # check donor supplied secret
SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \ SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \
cut -d ' ' -f 2) cut -d ' ' -f2)
if [ "$SECRET" != "$MY_SECRET" ]; then if [ "$SECRET" != "$MY_SECRET" ]; then
wsrep_log_error "Donor does not know my secret!" wsrep_log_error "Donor does not know my secret!"
wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'" wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'"
......
...@@ -435,24 +435,38 @@ EOF ...@@ -435,24 +435,38 @@ EOF
tar_type=0 tar_type=0
if tar --help | grep -qw -F -- '--transform'; then if tar --help | grep -qw -F -- '--transform'; then
tar_type=1 tar_type=1
elif tar --help | grep -qw -E -- '-s[[:space:]]pattern' elif tar --version | grep -q -E '^bsdtar\>'; then
then
tar_type=2 tar_type=2
fi fi
if [ $tar_type -ne 2 ]; then
if [ -n "$BASH_VERSION" ]; then
printf '%s' "$binlog_files" >&2
else
echo "$binlog_files" >&2
fi
fi
if [ $tar_type -ne 0 ]; then if [ $tar_type -ne 0 ]; then
# Preparing list of the binlog file names: # Preparing list of the binlog file names:
echo "$binlog_files" | { echo "$binlog_files" | {
binlogs="" binlogs=""
while read bin_file || [ -n "$bin_file" ]; do while read bin_file || [ -n "$bin_file" ]; do
[ ! -f "$bin_file" ] && continue [ ! -f "$bin_file" ] && continue
if [ -n "$BASH_VERSION" ]; then
first="${bin_file:0:1}"
else
first=$(echo "$bin_file" | cut -c1)
fi
if [ "$first" = '-' -o "$first" = '@' ]; then
bin_file="./$bin_file"
fi
binlogs="$binlogs${binlogs:+ }'$bin_file'" binlogs="$binlogs${binlogs:+ }'$bin_file'"
done done
if [ -n "$binlogs" ]; then if [ -n "$binlogs" ]; then
tar_options='/^.*\///g'
if [ $tar_type -eq 1 ]; then if [ $tar_type -eq 1 ]; then
tar_options="--transform='s$tar_options'" tar_options="--transform='s/^.*\///g'"
else else
tar_options="-s '$tar_options'" # bsdtar handles backslash incorrectly:
tar_options="-s '?^.*/??g'"
fi fi
eval tar -P $tar_options \ eval tar -P $tar_options \
-cvf "'$BINLOG_TAR_FILE'" $binlogs >&2 -cvf "'$BINLOG_TAR_FILE'" $binlogs >&2
...@@ -465,6 +479,14 @@ EOF ...@@ -465,6 +479,14 @@ EOF
[ ! -f "$bin_file" ] && continue [ ! -f "$bin_file" ] && continue
bin_dir=$(dirname "$bin_file") bin_dir=$(dirname "$bin_file")
bin_base=$(basename "$bin_file") bin_base=$(basename "$bin_file")
if [ -n "$BASH_VERSION" ]; then
first="${bin_base:0:1}"
else
first=$(echo "$bin_base" | cut -c1)
fi
if [ "$first" = '-' -o "$first" = '@' ]; then
bin_base="./$bin_base"
fi
if [ -n "$bin_dir" -a "$bin_dir" != '.' ]; then if [ -n "$bin_dir" -a "$bin_dir" != '.' ]; then
tar $tar_options "$BINLOG_TAR_FILE" \ tar $tar_options "$BINLOG_TAR_FILE" \
-C "$bin_dir" "$bin_base" >&2 -C "$bin_dir" "$bin_base" >&2
...@@ -740,7 +762,7 @@ EOF ...@@ -740,7 +762,7 @@ EOF
exit 42 exit 42
fi fi
CN=$("$OPENSSL_BINARY" x509 -noout -subject -in "$SSTCERT" | \ CN=$("$OPENSSL_BINARY" x509 -noout -subject -in "$SSTCERT" | \
tr ',' '\n' | grep -F 'CN =' | cut -d= -f2 | sed s/^\ // | \ tr ',' '\n' | grep -F 'CN =' | cut -d '=' -f2 | sed s/^\ // | \
sed s/\ %//) sed s/\ %//)
fi fi
MY_SECRET="$(wsrep_gen_secret)" MY_SECRET="$(wsrep_gen_secret)"
...@@ -781,7 +803,7 @@ EOF ...@@ -781,7 +803,7 @@ EOF
if [ -n "$MY_SECRET" ]; then if [ -n "$MY_SECRET" ]; then
# Check donor supplied secret: # Check donor supplied secret:
SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \ SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \
cut -d ' ' -f 2) cut -d ' ' -f2)
if [ "$SECRET" != "$MY_SECRET" ]; then if [ "$SECRET" != "$MY_SECRET" ]; then
wsrep_log_error "Donor does not know my secret!" wsrep_log_error "Donor does not know my secret!"
wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'" wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'"
...@@ -840,12 +862,20 @@ EOF ...@@ -840,12 +862,20 @@ EOF
binlog_cd=0 binlog_cd=0
if [ -n "$binlog_dir" -a "$binlog_dir" != '.' ]; then if [ -n "$binlog_dir" -a "$binlog_dir" != '.' ]; then
[ ! -d "$binlog_dir" ] && mkdir -p "$binlog_dir" [ ! -d "$binlog_dir" ] && mkdir -p "$binlog_dir"
cd "$binlog_dir"
binlog_cd=1 binlog_cd=1
cd "$binlog_dir"
fi fi
# Extracting binlog files: # Extracting binlog files:
wsrep_log_info "Extracting binlog files:" wsrep_log_info "Extracting binlog files:"
if ! tar -xvf "$BINLOG_TAR_FILE" > "$tmpfile"; then RC=0
if tar --version | grep -q -E '^bsdtar\>'; then
tar -tf "$BINLOG_TAR_FILE" > "$tmpfile" && \
tar -xvf "$BINLOG_TAR_FILE" > /dev/null || RC=$?
else
tar -xvf "$BINLOG_TAR_FILE" > "$tmpfile" && \
cat "$tmpfile" >&2 || RC=$?
fi
if [ $RC -ne 0 ]; then
rm -f "$tmpfile" rm -f "$tmpfile"
wsrep_log_error "Error unpacking tar file with binlog files" wsrep_log_error "Error unpacking tar file with binlog files"
exit 32 exit 32
......
...@@ -328,7 +328,8 @@ get_transfer() ...@@ -328,7 +328,8 @@ get_transfer()
if [ "${sockopt#*,dhparam=}" != "$sockopt" ]; then if [ "${sockopt#*,dhparam=}" != "$sockopt" ]; then
if [ -z "$ssl_dhparams" ]; then if [ -z "$ssl_dhparams" ]; then
# Determine the socat version # Determine the socat version
SOCAT_VERSION=$(socat -V 2>&1 | grep -m1 -oe '[0-9]\.[0-9][\.0-9]*') SOCAT_VERSION=$(socat -V 2>&1 | \
grep -m1 -owE '[0-9]+(\.[0-9]+)+' | head -n1)
if [ -z "$SOCAT_VERSION" ]; then if [ -z "$SOCAT_VERSION" ]; then
wsrep_log_error "******** FATAL ERROR ******************" wsrep_log_error "******** FATAL ERROR ******************"
wsrep_log_error "* Cannot determine the socat version. *" wsrep_log_error "* Cannot determine the socat version. *"
...@@ -778,7 +779,7 @@ recv_joiner() ...@@ -778,7 +779,7 @@ recv_joiner()
# check donor supplied secret # check donor supplied secret
SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \ SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \
cut -d ' ' -f 2) cut -d ' ' -f2)
if [ "$SECRET" != "$MY_SECRET" ]; then if [ "$SECRET" != "$MY_SECRET" ]; then
wsrep_log_error "Donor does not know my secret!" wsrep_log_error "Donor does not know my secret!"
wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'" wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'"
...@@ -835,7 +836,7 @@ monitor_process() ...@@ -835,7 +836,7 @@ monitor_process()
XB_REQUIRED_VERSION='2.3.5' XB_REQUIRED_VERSION='2.3.5'
XB_VERSION=$($BACKUP_BIN --version 2>&1 | \ XB_VERSION=$($BACKUP_BIN --version 2>&1 | \
grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1) grep -m1 -owE '[0-9]+(\.[0-9]+)+' | head -n1)
if [ -z "$XB_VERSION" ]; then if [ -z "$XB_VERSION" ]; then
wsrep_log_error "FATAL: Cannot determine the $BACKUP_BIN version." \ wsrep_log_error "FATAL: Cannot determine the $BACKUP_BIN version." \
"Needs xtrabackup-$XB_REQUIRED_VERSION or higher to" \ "Needs xtrabackup-$XB_REQUIRED_VERSION or higher to" \
...@@ -1212,7 +1213,6 @@ then ...@@ -1212,7 +1213,6 @@ then
# May need xtrabackup_checkpoints later on # May need xtrabackup_checkpoints later on
[ -f "$DATA/xtrabackup_binary" ] && rm -f "$DATA/xtrabackup_binary" [ -f "$DATA/xtrabackup_binary" ] && rm -f "$DATA/xtrabackup_binary"
[ -f "$DATA/xtrabackup_galera_info" ] && rm -f "$DATA/xtrabackup_galera_info" [ -f "$DATA/xtrabackup_galera_info" ] && rm -f "$DATA/xtrabackup_galera_info"
[ -f "$DATA/ib_logfile0" ] && rm -f "$DATA/ib_logfile0"
ADDR="$WSREP_SST_OPT_ADDR" ADDR="$WSREP_SST_OPT_ADDR"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment