From edaba340af9be72000e2f47852614129ab4cf6e3 Mon Sep 17 00:00:00 2001 From: Ondrej Mejzlik Date: Tue, 2 Nov 2021 10:19:32 +0100 Subject: [PATCH] adding sanity test --- .../information-and-output-options/main.fmf | 27 ++ .../information-and-output-options/runtest.sh | 448 ++++++++++++++++++ 2 files changed, 475 insertions(+) create mode 100644 Sanity/information-and-output-options/main.fmf create mode 100755 Sanity/information-and-output-options/runtest.sh diff --git a/Sanity/information-and-output-options/main.fmf b/Sanity/information-and-output-options/main.fmf new file mode 100644 index 0000000..bc3ba5a --- /dev/null +++ b/Sanity/information-and-output-options/main.fmf @@ -0,0 +1,27 @@ +summary: Tests rsync options which change the rsync output (stdout, stderr and log) +description: '' +component: +- rsync +test: ./runtest.sh +framework: beakerlib +recommend: +- rsync +- rsync-daemon +- xinetd +duration: 10m +enabled: true +tag: +- TIPfail_infra +- TIPfail_samba +- TIPfail_systemd +- TIPpass +- TIPpass_Security +- TierCandidatesPASS +- TipWaived6 +- TipWaived7 +link: +- relates: https://bugzilla.redhat.com/show_bug.cgi?id=904135 +- relates: https://bugzilla.redhat.com/show_bug.cgi?id=918399 +extra-nitrate: TC#0238298 +extra-summary: /CoreOS/rsync/Sanity/information-and-output-options +extra-task: /CoreOS/rsync/Sanity/information-and-output-options diff --git a/Sanity/information-and-output-options/runtest.sh b/Sanity/information-and-output-options/runtest.sh new file mode 100755 index 0000000..16dec31 --- /dev/null +++ b/Sanity/information-and-output-options/runtest.sh @@ -0,0 +1,448 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/rsync/Sanity/information-and-output-options +# Description: Tests rsync options which change the rsync output (stdout, stderr and log) +# Author: Michal Trunecka +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="rsync" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlIsRHEL 8 && rlAssertRpm "rsync-daemon" + + rlFileBackup /etc/rsyncd.conf + START_DATE_TIME=`date "+%m/%d/%Y %T"` + + REMOTE="/tmp/remote$$" + LOCAL="/tmp/local$$" + LOCAL_2="/root/another_local" + TMP_FILE=`mktemp` + TMP_FILE_2=`mktemp` + SERVER_LOG_FILE=`mktemp` + rlRun "chcon -t rsync_log_t $SERVER_LOG_FILE" + LOG_FILE=`mktemp` + rlRun "chcon -t rsync_log_t $LOG_FILE" + MOTD="MOTD:$RANDOM$RANDOM" + + rlRun "mkdir $REMOTE" + rlRun "chcon -t rsync_tmp_t $REMOTE" + rlRun "mkdir $LOCAL" + rlRun "chcon -t rsync_tmp_t $LOCAL" + rlRun "dd if=/dev/zero of=${LOCAL}/bigfile bs=1000 count=20000" + rlRun "dd if=/dev/zero of=${LOCAL}/smallfile bs=1000 count=2" + rlRun "mkdir $LOCAL_2" + rlRun "chcon -t rsync_tmp_t $LOCAL_2" + rlRun "echo 'lorem ipsum...' > ${LOCAL_2}/file.txt" + rlRun "echo $MOTD > /etc/rsyncd.motd" + rlRun "cat > /etc/rsyncd.conf < $TMP_FILE" + rlRun "[ ! -e $REMOTE/bigfile ]" + + # NOTICE WHAT RETURN VALUES ARE EXPECTED + rlRun "cat ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 'opening tcp connection to'" 1 + rlRun "cat ${TMP_FILE} | grep 'sending daemon args:'" 1 + rlRun "cat ${TMP_FILE} | grep $MOTD" + rlRun "cat ${TMP_FILE} | grep 'sending incremental file list'" 1 + rlRun "cat ${TMP_FILE} | grep 'hiding file bigfile because of pattern bigfile'" 1 + rlRun "cat ${TMP_FILE} | grep './'" 1 + rlRun "cat ${TMP_FILE} | grep 'smallfile'" 1 + rlRun "cat ${TMP_FILE} | grep 'total: matches=.*hash_hits=.*false_alarms=.*data=.*'" 1 + rlRun "cat ${TMP_FILE} | grep 'sent .* bytes *received .* bytes .* bytes/sec'" 1 + rlRun "cat ${TMP_FILE} | grep 'total size is .* speedup is .*'" 1 + rlRun "rm ${REMOTE}/smallfile" + + rlRun "rsync -av --exclude 'bigfile' ${LOCAL}/ localhost::remote > $TMP_FILE" + rlRun "[ ! -e $REMOTE/bigfile ]" + + rlRun "cat ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 'opening tcp connection to'" 1 + rlRun "cat ${TMP_FILE} | grep 'sending daemon args:'" 1 + rlRun "cat ${TMP_FILE} | grep $MOTD" + rlRun "cat ${TMP_FILE} | grep 'sending incremental file list'" + rlRun "cat ${TMP_FILE} | grep 'hiding file bigfile because of pattern bigfile'" 1 + rlRun "cat ${TMP_FILE} | grep './'" + rlRun "cat ${TMP_FILE} | grep 'smallfile'" + rlRun "cat ${TMP_FILE} | grep 'total: matches=.*hash_hits=.*false_alarms=.*data=.*'" 1 + rlRun "cat ${TMP_FILE} | grep 'sent .* bytes *received .* bytes .* bytes/sec'" + rlRun "cat ${TMP_FILE} | grep 'total size is .* speedup is .*'" + rlRun "rm ${REMOTE}/smallfile" + + rlRun "rsync -avv --exclude 'bigfile' ${LOCAL}/ localhost::remote > $TMP_FILE" + rlRun "[ ! -e $REMOTE/bigfile ]" + + rlRun "cat ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 'opening tcp connection to'" + rlRun "cat ${TMP_FILE} | grep 'sending daemon args:'" + rlRun "cat ${TMP_FILE} | grep $MOTD" + rlRun "cat ${TMP_FILE} | grep 'sending incremental file list'" + rlRun "cat ${TMP_FILE} | grep 'hiding file bigfile because of pattern bigfile'" + rlRun "cat ${TMP_FILE} | grep './'" + rlRun "cat ${TMP_FILE} | grep 'smallfile'" + rlRun "cat ${TMP_FILE} | grep 'total: matches=.*hash_hits=.*false_alarms=.*data=.*'" + rlRun "cat ${TMP_FILE} | grep 'sent .* bytes *received .* bytes .* bytes/sec'" + rlRun "cat ${TMP_FILE} | grep 'total size is .* speedup is .*'" + rlRun "rm ${REMOTE}/smallfile" + + rlPhaseEnd + + rlPhaseStartTest " -h, --human-readable" +# -h, --human-readable +# Output numbers in a more human-readable format. This makes big numbers out- +# put using larger units, with a K, M, or G suffix. If this option was speci- +# fied once, these units are K (1000), M (1000*1000), and G (1000*1000*1000); + + rlRun "rsync -av ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 'total *size *is *20,\?000,\?000'" + rlRun "cat ${TMP_FILE} | grep 'M bytes'" 1 + rlRun "rm ${REMOTE}/bigfile" + + rlRun "rsync -avh ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 'total *size *is *20.00M'" + rlRun "cat ${TMP_FILE} | grep 'M bytes'" + rlRun "rm ${REMOTE}/bigfile" + +# if the option is repeated, the units are powers of 1024 instead of 1000. + + rlRun "rsync -avhh ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 'total *size *is *19.07M'" + rlRun "cat ${TMP_FILE} | grep 'M bytes'" + rlRun "rm ${REMOTE}/bigfile" + rlPhaseEnd + + rlPhaseStartTest "-q --quiet" + +# -q, --quiet +# This option decreases the amount of information you are given during the +# transfer, notably suppressing information messages from the remote server. +# This option is useful when invoking rsync from cron. + + rlRun "rsync -avvhhq ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "[ -z \"$(cat ${TMP_FILE})\" ]" + rlRun "rm ${REMOTE}/bigfile" + rlPhaseEnd + + rlPhaseStartTest "--list-only" + +# --list-only +# This option will cause the source files to be listed instead of transferred. +# This option is inferred if there is a single source arg and no destination +# specified, so its main uses are: (1) to turn a copy command that includes a +# destination arg into a file-listing command, or (2) to be able to specify +# more than one source arg (note: be sure to include the destination). + + rlRun "rsync --no-motd -a --list-only ${LOCAL}/ localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep bigfile" + rlRun "cat ${TMP_FILE} | grep smallfile" + rlRun "[ ! -e $REMOTE/bigfile ]" + rlRun "[ ! -e $REMOTE/smallfile ]" + rlRun "rsync -a ${LOCAL}/ > ${TMP_FILE_2}" + # pls uncomment following diff once bugs 918399 and 904135 are fixed + #rlRun "diff ${TMP_FILE} ${TMP_FILE_2}" + rlRun "rsync --list-only -a ${LOCAL}/ ${LOCAL_2}/ localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep bigfile" + rlRun "cat ${TMP_FILE} | grep smallfile" + rlRun "cat ${TMP_FILE} | grep file.txt" + rlPhaseEnd + + rlPhaseStartTest " --out-format=FORMAT" + +# --out-format=FORMAT +# This allows you to specify exactly what the rsync client outputs to the user +# on a per-update basis. The format is a text string containing embedded sin- +# gle-character escape sequences prefixed with a percent (%) character. A +# default format of “%n%L” is assumed if -v is specified (which reports the +# name of the file and, if the item is a link, where it points). +# +# Specifying the --out-format option will mention each file, dir, etc. that +# gets updated in a significant way (a transferred file, a recreated sym- +# link/device, or a touched directory). In addition, if the itemize-changes +# escape (%i) is included in the string (e.g. if the --itemize-changes option +# was used), the logging of names increases to mention any item that is +# changed in any way (as long as the receiving side is at least 2.6.4). See +# the --itemize-changes option for a description of the output of “%i”. + + #remove motd from config + rlRun "sed -i 's/^motd.*$//' /etc/rsyncd.conf" + if rlIsRHEL '<9'; then + rlRun "service xinetd restart" + fi + # NOTE: Because of the rsync Bug: https://bugzilla.samba.org/show_bug.cgi?id=8558 + # sequences %a %h %P and %u are not expanded on the client side because they are + # undefined + rlRun "rsync --out-format '%b' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 20002483" + rlRun "rm ${REMOTE}/bigfile" + rlRun "rsync --out-format '%B' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 'rw-r--r--'" + rlRun "rsync --out-format '%c' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep 16" + rlRun "rm ${REMOTE}/bigfile" + rlRun "rsync --out-format '%f' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep tmp/local$$/bigfile" + rlRun "rsync --out-format '%G' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep '\<0\>'" + rlRun "rsync --out-format '%i' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep ' ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep '\<20000000\>'" + rlRun "rsync --out-format '%L' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "[ -z \"$( cat ${TMP_FILE} )\" ] " + rlRun "rsync --out-format '%m' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE}" + rlRun "rsync --out-format '%M' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep `date '+%Y/%m/%d'`" + rlRun "rsync --out-format '%n' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep '\'" + rlRun "rsync --out-format '%o' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep send" + rlRun "rsync --out-format '%p' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE}" + rlRun "rsync --out-format '%t' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep `date '+%Y/%m/%d'`" + rlRun "rsync --out-format '%U' -n -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${TMP_FILE} | grep '\<0\>'" + rlPhaseEnd + + rlPhaseStartTest "--log-file=FILE" + +# --log-file=FILE +# This option causes rsync to log what it is doing to a file. This is similar +# to the logging that a daemon does, but can be requested for the client side +# and/or the server side of a non-daemon transfer. If specified as a client +# option, transfer logging will be enabled with a default format of “%i %n%L”. +# See the --log-file-format option if you wish to override this. + + rlRun "rsync -a --log-file=${LOG_FILE} ${LOCAL}/ ${REMOTE}" + rlRun "cat $LOG_FILE | grep 'building file list'" + rlRun "cat $LOG_FILE | grep '>f+++++++++ bigfile'" + rlRun "cat $LOG_FILE | grep '>f+++++++++ smallfile'" + rlRun "cat $LOG_FILE | grep 'sent .* bytes received .* bytes total size'" + rlRun "rm -rf ${REMOTE}/*" + + rlRun "rsync -a -h --log-file=${LOG_FILE} ${LOCAL}/ ${REMOTE}" + rlRun "cat $LOG_FILE" + rlRun "rm -rf ${REMOTE}/*" + rlRun "echo '' > $LOG_FILE" + rlPhaseEnd + + rlPhaseStartTest "--log-file-format=FORMAT" + +# --log-file-format=FORMAT +# This allows you to specify exactly what per-update logging is put into the +# file specified by the --log-file option (which must also be specified for +# this option to have any effect). If you specify an empty string, updated +# files will not be mentioned in the log file. For a list of the possible +# escape characters, see the “log format” setting in the rsyncd.conf manpage. +# +# The default FORMAT used if --log-file is specified and this option is not is +# ’%i %n%L’. + + # NOTE: Because of the rsync Bug: https://bugzilla.samba.org/show_bug.cgi?id=8558 + # sequences %a %h %P and %u are not expanded on the client side because they are + # undefined + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%b' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep 20002483" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%B' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep 'rw-r--r--'" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%c' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep 16" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%f' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep tmp/local$$/bigfile" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%G' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep '\<0\>'" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%i' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep ' $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%l' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep '\<20000000\>'" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%L' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%m' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%M' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep `date '+%Y/%m/%d'`" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%n' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep '\'" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%o' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep send" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%p' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%t' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep `date '+%Y/%m/%d'`" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlRun "rsync --log-file=${LOG_FILE} --log-file-format '%U' -a ${LOCAL}/bigfile localhost::remote > ${TMP_FILE}" + rlRun "cat ${LOG_FILE}" + rlRun "cat ${LOG_FILE} | grep '\<0\>'" + rlRun "rm ${REMOTE}/bigfile" + rlRun "echo '' > $LOG_FILE" + + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm -rf $REMOTE" + rlRun "rm -rf $LOCAL" + rlRun "rm -rf $LOCAL_2" + rlRun "rm -rf $SERVER_LOG_FILE" + rlRun "rm -rf $LOG_FILE" + rlRun "rm -f /etc/rsyncd.motd" + rlFileRestore + if rlIsRHEL 5 6; then + rlRun "chkconfig rsync off" + rlRun "service xinetd restart" + else + rlServiceRestore rsyncd + $SOCKET && systemctl start rsyncd.socket + fi + + sleep 2 + rlRun "ausearch -m AVC -m SELINUX_ERR -ts ${START_DATE_TIME} > ${TMP_FILE}" 0,1 + LINE_COUNT=`wc -l < ${TMP_FILE}` + rlRun "cat ${TMP_FILE}" + rlAssert0 "number of lines in ${TMP_FILE} should be 0" ${LINE_COUNT} + + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd