#3 Add CI tests using the standard test interface
Merged 4 years ago by mruprich. Opened 4 years ago by esakaiev.
git://fedorapeople.org/~esakaiev/rsync tests_branch  into  master

Add tests for rsync to the tests_branch
root • 4 years ago  
tests/definig-the-set-of-files-to-transfer/Makefile
file added
+64
@@ -0,0 +1,64 @@

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile of /CoreOS/rsync/Sanity/definig-the-set-of-files-to-transfer

+ #   Description: Tests the options which modifie the list of files to be transfered

+ #   Author: Michal Trunecka <mtruneck@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   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.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ export TEST=/CoreOS/rsync/Sanity/definig-the-set-of-files-to-transfer

+ export TESTVERSION=1.0

+ 

+ BUILT_FILES=

+ 

+ FILES=$(METADATA) runtest.sh Makefile PURPOSE rsyncd@.service

+ 

+ .PHONY: all install download clean

+ 

+ run: $(FILES) build

+ 	./runtest.sh

+ 

+ build: $(BUILT_FILES)

+ 	test -x runtest.sh || chmod a+x runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

+ include /usr/share/rhts/lib/rhts-make.include

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Michal Trunecka <mtruneck@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     Tests the options which modifie the list of files to be transfered" >> $(METADATA)

+ 	@echo "Type:            Sanity" >> $(METADATA)

+ 	@echo "TestTime:        60m" >> $(METADATA)

+ 	@echo "RunFor:          rsync" >> $(METADATA)

+ 	@echo "Requires:        rsync rsync-daemon" >> $(METADATA)

+ 	@echo "Requires:        xinetd" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

tests/definig-the-set-of-files-to-transfer/PURPOSE
file added
+16
@@ -0,0 +1,16 @@

+ PURPOSE of /CoreOS/rsync/Sanity/definig-the-set-of-files-to-transfer

+ Description: Tests the options which modifie the list of files to be transfered

+ Author: Michal Trunecka <mtruneck@redhat.com>

+ Author: Karel Srot <ksrot@redhat.com>

+ 

+ Testing the sanity of following options:

+   -c --checksum

+   --ignore-existing

+   --max-size --min-size

+   --size-only

+   --include --exclude

+   --include-from --exclude-from

+ 

+ Not yet implemented:

+   -0, --from0

+   -f --filter, -F

tests/definig-the-set-of-files-to-transfer/rsyncd@.service
file added
+8
@@ -0,0 +1,8 @@

+ [Unit]

+ Description=fast remote file copy program daemon

+ ConditionPathExists=/etc/rsyncd.conf

+ 

+ [Service]

+ EnvironmentFile=/etc/sysconfig/rsyncd

+ ExecStart=/usr/bin/rsync --daemon --no-detach "$OPTIONS"

+ StandardInput=socket

tests/definig-the-set-of-files-to-transfer/runtest.sh
file added
+361
@@ -0,0 +1,361 @@

+ #!/bin/bash

+ # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/rsync/Sanity/definig-the-set-of-files-to-transfer

+ #   Description: Tests the options which modifie the list of files to be transfered

+ #   Author: Michal Trunecka <mtruneck@redhat.com>

+ #   Author: Karel Srot <ksrot@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   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/bin/rhts-environment.sh || exit 1

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="rsync"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 

+         rlFileBackup --clean /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"

+ 

+         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 "echo 'First file' > ${LOCAL}/first"

+         rlRun "echo 'Second file' > ${LOCAL}/second"

+         rlRun "echo 'Third file' > ${LOCAL}/third"

+         if ! rlIsRHEL 5 6; then

+             if ! ls /usr/lib/systemd/system/rsyncd@.service

+             then

+                 WORKAROUNDED=true

+                 rlFail "The /usr/lib/systemd/system/rsyncd@.service file is missing (bz#1082496), will be workarounded for now"

+                 rlRun "cp rsyncd@.service /usr/lib/systemd/system/"

+             else

+                 rlPass "The bz#1082496 is probably fixed, no workaround needed."

+             fi

+         fi

+ 

+         rlRun "cat > /etc/rsyncd.conf <<EOF

+ pid file = /var/run/rsyncd.pid

+ log file = $SERVER_LOG_FILE

+ 

+ [remote]

+     path = $REMOTE

+     hosts allow = 127.0.0.1, ::1

+     read only = no

+     uid = root

+     gid = root

+ EOF"

+ 	if rlIsRHEL 5 6; then

+           rlRun "chkconfig rsync on"

+           rlServiceStart xinetd

+ 	else 

+ 	  systemctl status rsyncd.socket && STOPPED=false || STOPPED=true

+ 	  rlServiceStop rsyncd

+ 	  rlRun "systemctl restart rsyncd.socket"

+ 	fi

+  

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "-c --checksum"

+ 

+ #       -c, --checksum

+ #              This  changes the way rsync checks if the files have been changed and are in

+ #              need of a transfer.  Without this option, rsync uses a  “quick  check”  that

+ #              (by  default) checks if each file’s size and time of last modification match

+ #              between the sender and receiver.  This option  changes  this  to  compare  a

+ #              128-bit  checksum  for  each  file that has a matching size.  Generating the

+ #              checksums means that both sides will expend a lot of disk  I/O  reading  all

+ #              the data in the files in the transfer (and this is prior to any reading that

+ #              will be done to transfer changed files), so this can slow things  down  sig-

+ #              nificantly.

+ #

+ #              The  sending  side generates its checksums while it is doing the file-system

+ #              scan that builds the list of the available files.   The  receiver  generates

+ #              its  checksums  when it is scanning for changed files, and will checksum any

+ #              file that has the same size as the corresponding sender’s file:  files  with

+ #              either a changed size or a changed checksum are selected for transfer.

+ #

+         rlRun "rsync -av -i ${LOCAL}/first localhost::remote | grep first"

+         rlRun "rsync -av -i ${LOCAL}/first localhost::remote | grep first" 1

+         rlRun "MODIF_DATE=\"`date -r ${REMOTE}/first`\""

+         # Modified content, but preserved the size

+         rlRun "echo 'first file' > ${REMOTE}/first"

+         # set the same dates to both local and remote file

+         rlRun "touch -d \"$MODIF_DATE\" ${REMOTE}/first"

+         rlRun "touch -d \"$MODIF_DATE\" ${LOCAL}/first"

+         rlRun "rsync -av -i ${LOCAL}/first localhost::remote | grep first" 1

+         rlRun "rsync -av -i -c ${LOCAL}/first localhost::remote | grep first"

+ 

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "--ignore-existing"

+ 

+ #       --ignore-existing

+ #              This  tells  rsync to skip updating files that already exist on the destina-

+ #              tion (this does not ignore existing directories, or nothing would get done).

+ #              See also --existing.

+ #

+ #              This  option  is  a  transfer rule, not an exclude, so it doesn’t affect the

+ #              data that goes into the file-lists, and thus it  doesn’t  affect  deletions.

+ #              It just limits the files that the receiver requests to be transferred.

+ #

+ #              This  option  can  be  useful  for those doing backups using the --link-dest

+ #              option when they need to continue a backup run that got interrupted.   Since

+ #              a  --link-dest run is copied into a new directory hierarchy (when it is used

+ #              properly), using --ignore existing  will  ensure  that  the  already-handled

+ #              files  don’t  get tweaked (which avoids a change in permissions on the hard-

+ #              linked files).  This does mean that this  option  is  only  looking  at  the

+ #              existing files in the destination hierarchy itself.

+ 

+         rlRun "echo 'lorem ipsum' > ${REMOTE}/first"

+         rlRun "echo 'dolor sit amet' > ${REMOTE}/second"

+         rlRun "echo 'consectetur adipiscing elit' > ${REMOTE}/third"

+         rlRun "echo 'lorem ipsum' > ${REMOTE}/smallfile"

+         rlRun "echo 'dolor sit amet' > ${REMOTE}/bigfile"

+ 

+         rlRun "rsync -avv -i -c --ignore-existing ${LOCAL}/ localhost::remote | egrep 'first|second|third|smallfile|bigfile'" 1

+         rlRun "rsync -avv -i --size-only --ignore-existing ${LOCAL}/ localhost::remote | egrep 'first|second|third|smallfile|bigfile'" 1

+         rlRun "rsync -avv -i -I --ignore-existing ${LOCAL}/ localhost::remote | egrep 'first|second|third|smallfile|bigfile'" 1

+         rlRun "rsync -avv -i ${LOCAL}/ localhost::remote | egrep 'first|second|third|smallfile|bigfile'"

+ 

+         rlRun "rm -rf ${REMOTE}/*"

+ 

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "--max-size --min-size"

+ 

+ #       --max-size=SIZE

+ #              This tells rsync to avoid transferring any file  that  is  larger  than  the

+ #              specified  SIZE.  The SIZE value can be suffixed with a string to indicate a

+ #              size multiplier, and may be a fractional value (e.g. “--max-size=1.5m”).

+ #

+ #              This option is a transfer rule, not an exclude, so  it  doesn’t  affect  the

+ #              data  that  goes  into the file-lists, and thus it doesn’t affect deletions.

+ #              It just limits the files that the receiver requests to be transferred.

+ #

+ #              The suffixes are as follows: “K” (or “KiB”) is a kibibyte  (1024),  “M”  (or

+ #              “MiB”)  is  a  mebibyte  (1024*1024),  and  “G”  (or  “GiB”)  is  a gibibyte

+ #              (1024*1024*1024).  If you want the multiplier to be 1000  instead  of  1024,

+ #              use  “KB”,  “MB”,  or “GB”.  (Note: lower-case is also accepted for all val-

+ #              ues.)  Finally, if the suffix ends in either “+1” or “-1”, the value will be

+ #              offset by one byte in the indicated direction.

+ #

+ #              Examples:  --max-size=1.5mb-1  is  1499999  bytes,  and  --max-size=2g+1  is

+ #              2147483649 bytes.

+ #

+ #       --min-size=SIZE

+ #              This tells rsync to avoid transferring any file that  is  smaller  than  the

+ #              specified  SIZE,  which can help in not transferring small, junk files.  See

+ #              the --max-size option for a description of SIZE and other information.

+ 

+         for SIZE in 1K 1M 1KB 1MB; do

+             rlRun "dd if=/dev/zero of=${LOCAL}/testfile bs=1 count=${SIZE}"

+             rlRun "rsync -avh --max-size ${SIZE}-1 ${LOCAL}/testfile localhost::remote | grep testfile" 1

+             rlRun "rsync -avh --min-size ${SIZE}+1 ${LOCAL}/testfile localhost::remote | grep testfile" 1

+             rlRun "rsync -avh --max-size ${SIZE} ${LOCAL}/testfile localhost::remote | grep testfile"

+             rlRun "rm -f ${REMOTE}/testfile"

+             rlRun "rsync -avh --max-size ${SIZE} ${LOCAL}/testfile localhost::remote | grep testfile"

+             rlRun "rm -f ${REMOTE}/testfile"

+         done

+ 

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "--size-only"

+ 

+ #       --size-only

+ #              This modifies rsync’s “quick check” algorithm for finding files that need to

+ #              be transferred, changing it from the  default  of  transferring  files  with

+ #              either  a  changed  size or a changed last-modified time to just looking for

+ #              files that have changed in size.  This is useful when starting to use  rsync

+ #              after  using  another  mirroring  system  which  may not preserve timestamps

+ #              exactly.

+ 

+         rlRun "sleep 2"

+         # Modified content, but preserved the size of the destionation 

+         rlRun "echo 'Xirst file' > ${REMOTE}/first"

+ 

+         rlLog "The file would be transfered with only -a option"

+         rlRun "rsync -avv -n ${LOCAL}/ localhost::remote | grep first"

+ 

+         rlLog "only the time  be updated with --size-only option"

+         rlRun "rsync -avvv -i --size-only ${LOCAL}/ localhost::remote | grep '.f..t...... first'"

+         rlRun "grep 'Xirst' ${REMOTE}/first"

+ 

+         rlLog "The file won't be tranferred with -a option because of the updated time" 

+         rlRun "rsync -avv -i ${LOCAL}/ localhost::remote | grep first" 1

+ 

+         rlLog "..and finaly, the file will be transfered with -c option"

+         rlRun "rsync -avv -i -c ${LOCAL}/ localhost::remote"

+         rlRun "grep 'First' ${REMOTE}/first"

+ 

+     rlPhaseEnd

+ 

+     #rlPhaseStartTest "-f --filter, -F"

+ 

+ #       -f, --filter=RULE

+ #              This  option  allows  you  to add rules to selectively exclude certain files

+ #              from the list of files to be transferred. This is most useful in combination

+ #              with a recursive transfer.

+ #

+ #              You  may  use  as  many  --filter options on the command line as you like to

+ #              build up the list of files to exclude.  If the filter  contains  whitespace,

+ #              be  sure  to  quote it so that the shell gives the rule to rsync as a single

+ #              argument.  The text below also mentions that you can use  an  underscore  to

+ #              replace the space that separates a rule from its arg.

+ #

+ #              See the FILTER RULES section for detailed information on this option.

+ #

+ #       -F     The  -F option is a shorthand for adding two --filter rules to your command.

+ #              The first time it is used is a shorthand for this rule:

+ #

+ #                 --filter=’dir-merge /.rsync-filter’

+ #

+ #              This tells rsync to look for per-directory  .rsync-filter  files  that  have

+ #              been sprinkled through the hierarchy and use their rules to filter the files

+ #              in the transfer.  If -F is repeated, it is a shorthand for this rule:

+ #

+ #                 --filter=’exclude .rsync-filter’

+ #

+ #              This filters out the .rsync-filter files themselves from the transfer.

+ #

+ #              See the FILTER RULES section for detailed information on how  these  options

+ #              work.

+ 

+     #rlPhaseEnd

+ 

+     rlPhaseStartTest "--include --exclude"

+ 

+ #       --include=PATTERN

+ #              This option is a simplified form of the --filter option that defaults to  an

+ #              include  rule and does not allow the full rule-parsing syntax of normal fil-

+ #              ter rules.

+ #

+ #              See the FILTER RULES section for detailed information on this option.

+ #

+ 	rlLogInfo "prepare test files"

+ 	rlRun "mkdir ${LOCAL}/include-test"

+ 	for F in "a.c" "a.log" "b.c" "b.log" "c.c" "c.log" "d.txt"; do

+ 	    rlRun "echo $F$F$F > ${LOCAL}/include-test/$F" 0 "Creating ${LOCAL}/include-test/$F file"

+ 	done

+ 

+ 	rlLogInfo "execute rsync command and verify results"

+ 	rlRun "rsync -avv -i --include='*.c' --include='b*' --exclude='*.log' ${LOCAL}/include-test localhost::remote"

+ 	# note: rsync checks each name to  be  transferred  against the list of include/exclude patterns in turn, and the first matching pattern is acted on

+ 	for F in "a.c" "b.c" "c.c" "b.log" "d.txt"; do

+ 		rlAssertExists ${REMOTE}/include-test/$F

+ 	done

+ 	rlAssertNotExists ${REMOTE}/include-test/a.log

+ 	rlAssertNotExists ${REMOTE}/include-test/c.log

+ 	rlRun "rm -rf ${REMOTE}/include-test ${LOCAL}/include-test"

+ 

+     rlPhaseEnd

+ 	

+     rlPhaseStartTest "--include-from --exclude-from"

+ 		

+ 

+ #       --include-from=FILE

+ #              This option is related to the --include option, but it specifies a FILE that

+ #              contains include patterns (one per line).  Blank lines in the file and lines

+ #              starting with ‘;’ or ‘#’ are ignored.  If FILE is -, the list will  be  read

+ #              from standard input.

+ 

+ 	rlLogInfo "prepare test files"

+ 	rlRun "mkdir ${LOCAL}/include-from-test"

+ 	for F in "a.c" "a.log" "b.c" "b.log" "c.c" "c.log" "d.txt"; do

+ 	    rlRun "echo $F$F$F > ${LOCAL}/include-from-test/$F" 0 "Creating ${LOCAL}/include-from-test/$F file"

+ 	done

+ 	rlRun "echo -e '*.c\nb*' > list-include"

+ 	rlRun "echo -e '*.log' > list-exclude"

+ 

+ 	rlLogInfo "execute rsync command and verify results"

+ 	rlRun "rsync -avv -i --include-from=list-include --exclude-from=list-exclude ${LOCAL}/include-from-test localhost::remote"

+ 	# note: rsync checks each name to  be  transferred  against the list of include/exclude patterns in turn, and the first matching pattern is acted on

+ 	for F in "a.c" "b.c" "c.c" "b.log" "d.txt"; do

+ 		rlAssertExists ${REMOTE}/include-from-test/$F

+ 	done

+ 	rlAssertNotExists ${REMOTE}/include-from-test/a.log

+ 	rlAssertNotExists ${REMOTE}/include-from-test/c.log

+ 	rlRun "rm -rf ${REMOTE}/include-from-test ${LOCAL}/include-from-test list-include list-exclude"

+ 

+     rlPhaseEnd

+ 

+     #rlPhaseStartTest "-0, --from0"

+ #

+ #       -0, --from0

+ #              This tells rsync that the rules/filenames it reads from a  file  are  termi-

+ #              nated  by  a  null  (’\0’)  character, not a NL, CR, or CR+LF.  This affects

+ #              --exclude-from, --include-from, --files-from, and any merged files specified

+ #              in  a --filter rule.  It does not affect --cvs-exclude (since all names read

+ #              from a .cvsignore file are split on whitespace).

+ #

+ #              If the --iconv and --protect-args options are specified and the --files-from

+ #              filenames  are  being  sent  from one host to another, the filenames will be

+ #              translated from the sending host’s charset to the receiving host’s  charset.

+ 

+     #rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "rm -rf $REMOTE"

+         rlRun "rm -rf $LOCAL"

+         rlRun "rm -rf $SERVER_LOG_FILE"

+         rlRun "rm -rf $LOG_FILE"

+         rlFileRestore

+         if rlIsRHEL 5 6; then

+             rlRun "chkconfig rsync off"

+             rlServiceRestore xinetd

+         else 

+             rlRun "systemctl stop rsyncd.socket"

+             rlServiceRestore rsyncd

+             $STOPPED || rlRun "systemctl start rsyncd.socket"

+         fi

+         if [ -n "$WORKAROUNDED" ]; then

+ 	    rlLog "Cleanup of the workaround for bz#1082496"

+ 	    rlRun "rm -rf /usr/lib/systemd/system/rsyncd@.service"

+         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

tests/setting-group-acls/Makefile
file added
+64
@@ -0,0 +1,64 @@

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile of setting-group-acls

+ #   Description: If you are using the -A/--acls option and you are not running as root and are not using the --numeric-ids option then if you have an ACL that includes a group entry for a group you are not a member of on the receiving side, then acl_set_file will return EINVAL, b/c rsync mistakenly maps the group name to gid GID_NONE (-1), which (fortunately) fails.

+ #   Author: Ales Marecek <amarecek@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2011 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.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ export TEST=setting-group-acls

+ export TESTVERSION=1.0

+ 

+ BUILT_FILES=

+ 

+ FILES=$(METADATA) runtest.sh Makefile PURPOSE

+ 

+ .PHONY: all install download clean

+ 

+ run: $(FILES) build

+ 	./runtest.sh

+ 

+ build: $(BUILT_FILES)

+ 	chmod a+x runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

+ include /usr/share/rhts/lib/rhts-make.include

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Ales Marecek <amarecek@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     If you are using the -A/--acls option and you are not running as root and are not using the --numeric-ids option then if you have an ACL that includes a group entry for a group you are not a member of on the receiving side, then acl_set_file will return EINVAL, b/c rsync mistakenly maps the group name to gid GID_NONE (-1), which (fortunately) fails." >> $(METADATA)

+ 	@echo "Type:            Regression" >> $(METADATA)

+ 	@echo "TestTime:        5m" >> $(METADATA)

+ 	@echo "RunFor:          rsync" >> $(METADATA)

+ 	@echo "Requires:        rsync" >> $(METADATA)

+ 	@echo "Requires:        acl" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

tests/setting-group-acls/PURPOSE
file added
+3
@@ -0,0 +1,3 @@

+ PURPOSE of setting-group-acls

+ Description: If you are using the -A/--acls option and you are not running as root and are not using the --numeric-ids option then if you have an ACL that includes a group entry for a group you are not a member of on the receiving side, then acl_set_file will return EINVAL, b/c rsync mistakenly maps the group name to gid GID_NONE (-1), which (fortunately) fails.

+ Author: Ales Marecek <amarecek@redhat.com>

tests/setting-group-acls/runtest.sh
file added
+71
@@ -0,0 +1,71 @@

+ #!/bin/bash

+ # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of setting-group-acls

+ #   Description: If you are using the -A/--acls option and you are not running as root and are not using the --numeric-ids option then if you have an ACL that includes a group entry for a group you are not a member of on the receiving side, then acl_set_file will return EINVAL, b/c rsync mistakenly maps the group name to gid GID_NONE (-1), which (fortunately) fails.

+ #   Author: Ales Marecek <amarecek@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2011 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 rhts environment

+ . /usr/bin/rhts-environment.sh

+ . /usr/share/beakerlib/beakerlib.sh

+ 

+ PACKAGE="rsync"

+ _TEST_USER="rsynctestuser"

+ _TEST_USER_PASSWORD="redhat"

+ _TEST_USER_HOME_DIR="/home/${_TEST_USER}"

+ _TEST_USER_SRC_TEST_DIR="${_TEST_USER_HOME_DIR}/src_rsync"

+ _TEST_USER_DST_TEST_DIR="${_TEST_USER_HOME_DIR}/dst_rsync"

+ _TEST_RAND_FILENAME="random.data"

+ _TEST_TEXT_FILENAME="hello_world.txt"

+ _TEST_RAND_FILE="${_TEST_USER_SRC_TEST_DIR}/${_TEST_RAND_FILENAME}"

+ _TEST_TEXT_FILE="${_TEST_USER_SRC_TEST_DIR}/${_TEST_TEXT_FILENAME}"

+ _TEST_RAND_FILE_SIZE=10

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 	id ${_TEST_USER} >/dev/null 2>&1 || rlRun "useradd -d ${_TEST_USER_HOME_DIR} -m ${_TEST_USER}" 0 "Creating a test user"

+ 	rlRun "echo \"${_TEST_USER_PASSWORD}\" | passwd --stdin ${_TEST_USER} >/dev/null 2>&1" 0 "Setting user's password"

+ 	rlRun "su - ${_TEST_USER} -c \"mkdir -p ${_TEST_USER_SRC_TEST_DIR} ${_TEST_USER_DST_TEST_DIR}\"" 0 "Creating directories for test data"

+ 	rlRun "su ${_TEST_USER} -c \"dd if=/dev/urandom of=${_TEST_RAND_FILE} bs=1M count=${_TEST_RAND_FILE_SIZE}\"" 0 "Generating random data file"

+ 	rlRun "su ${_TEST_USER} -c \"echo 'Hello world' >${_TEST_TEXT_FILE}\"" 0 "Generating text data file"

+ 	rlRun "setfacl -m g:root:--- ${_TEST_RAND_FILE}" 0 "Setting ACL for random data file"

+ 	rlRun "setfacl -m g:root:--- ${_TEST_TEXT_FILE}" 0 "Setting ACL for text data file"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlRun "su - ${_TEST_USER} -c \"rsync -A ${_TEST_RAND_FILE} ${_TEST_USER_DST_TEST_DIR}\"" 0 "Syncing random data file"

+ 	rlRun "su - ${_TEST_USER} -c \"rsync -A ${_TEST_TEXT_FILE} ${_TEST_USER_DST_TEST_DIR}\"" 0 "Syncing text data file"

+     getfacl ${_TEST_USER_DST_TEST_DIR}/${_TEST_RAND_FILENAME}

+     rlRun "getfacl ${_TEST_USER_DST_TEST_DIR}/${_TEST_RAND_FILENAME} | grep 'group:root:---'" 0 "Verify that ACL was properly set"

+     getfacl ${_TEST_USER_DST_TEST_DIR}/${_TEST_TEXT_FILENAME}

+     rlRun "getfacl ${_TEST_USER_DST_TEST_DIR}/${_TEST_TEXT_FILENAME} | grep 'group:root:---'" 0 "Verify that ACL was properly set"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 	rlRun "userdel -r ${_TEST_USER}" 0 "Deleting test user"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

tests/tests.yml
file added
+23
@@ -0,0 +1,23 @@

+ ---

+ # Tests that run in classic context

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     tests:

+     - definig-the-set-of-files-to-transfer

+     - setting-group-acls

+     required_packages:

+     - rsync         # all tests require rsync

+     - rsync-daemon  # definig-the-set-of-files-to-transfer requires rsync-daemon

+     - acl           # setting-group-acls requires acl

+ 

+ # Tests that run against Atomic Host

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - atomic

+     tests:

+     - setting-group-acls

no initial comment

Justification

Adds tests according to the CI wiki specifically the standard test interface in the spec.

The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Classic and Atomic. Test logs are stored in the artifacts directory.

The following steps are used to execute the tests using the standard test interface:

Test environment

Make sure you have installed packages from the spec

    # rpm -q ansible python2-dnf libselinux-python standard-test-roles \
    ansible-2.3.2.0-1.fc26.noarch \
    python2-dnf-2.6.3-11.fc26.noarch \
    libselinux-python-2.6-7.fc26.x86_64 \
    standard-test-roles-2.4-1.fc26.noarch

Run tests for Classic

    # export TEST_SUBJECTS=
    # sudo ansible-playbook --tags=classic tests.yml

Snip of the example test run for Classic tests:

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=16   changed=9    unreachable=0    failed=0   

PASS definig-the-set-of-files-to-transfer
PASS setting-group-acls

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: definig-the-set-of-files-to-transfer
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   LOG    ] :: Phases: 8 good, 0 bad
:: [   PASS   ] :: RESULT: definig-the-set-of-files-to-transfer

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: setting-group-acls
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   LOG    ] :: Phases: 3 good, 0 bad
:: [   PASS   ] :: RESULT: setting-group-acls

Run tests for Atomic

   # export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
   # curl -Lo atomic.qcow2 https://ftp-stud.hs-esslingen.de/pub/Mirrors/alt.fedoraproject.org/atomic/stable/Fedora-Atomic-26-20170707.1/CloudImages/x86_64/images/Fedora-Atomic-26-20170707.1.x86_64.qcow2
   # export TEST_SUBJECTS=$PWD/atomic.qcow2 
   # ansible-playbook --tags=atomic tests.yml

Snip of the example test run for Atomic tests:

PLAY RECAP ********************************************************************************************************************************************************************************************************
/home/fedora/rsync/atomic.qcow2 : ok=14   changed=9    unreachable=0    failed=0   

PASS setting-group-acls

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: setting-group-acls
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   LOG    ] :: Phases: 3 good, 0 bad
:: [   PASS   ] :: RESULT: setting-group-acls

Commit fbf0d67 fixes this pull-request

Pull-Request has been merged by mruprich

4 years ago

Pull-Request has been merged by mruprich

4 years ago