From b4171794c9efeef9087285ca176713faf1d175c8 Mon Sep 17 00:00:00 2001 From: Serhii Turivny Date: Feb 01 2019 15:39:23 +0000 Subject: Add CI tests using the standard test interface --- diff --git a/tests/tar-testsuite/Makefile b/tests/tar-testsuite/Makefile new file mode 100644 index 0000000..4a457c4 --- /dev/null +++ b/tests/tar-testsuite/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/tar/Regression/tar-testsuite +# Description: TAR testsuite +# Author: Branislav Blaskovic +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 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/tar/Regression/tar-testsuite +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) + 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: Branislav Blaskovic " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: TAR testsuite" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 60m" >> $(METADATA) + @echo "RunFor: tar" >> $(METADATA) + @echo "Requires: tar texinfo libacl-devel rsh libselinux-devel rpm-build gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/tar-testsuite/PURPOSE b/tests/tar-testsuite/PURPOSE new file mode 100644 index 0000000..465b88d --- /dev/null +++ b/tests/tar-testsuite/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/tar/Regression/tar-testsuite +Description: TAR testsuite +Author: Branislav Blaskovic diff --git a/tests/tar-testsuite/runtest.sh b/tests/tar-testsuite/runtest.sh new file mode 100755 index 0000000..a15eb66 --- /dev/null +++ b/tests/tar-testsuite/runtest.sh @@ -0,0 +1,123 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/tar/Regression/tar-testsuite +# Description: TAR testsuite +# Author: Branislav Blaskovic +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 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 +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGE="tar" +TESTUSER="tar-testsuite" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "useradd $TESTUSER" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "chmod -R 777 $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + + # Getting archive + rlFetchSrcForInstalled $PACKAGE + VERSION=`ls -1 *.src.rpm | head -1 | sed 's/tar-\([0-9.]*\).*src.rpm/\1/'` + RPM_NAME=`ls -1 *.src.rpm | head -1` + + rlRun "chmod -R 777 $TmpDir" + + if [ -f "$RPM_NAME" ];then + # Get folders + HOME_DIR=$(awk -F: -v v="$TESTUSER" '{if ($1==v) print $6}' /etc/passwd) + rlRun "su $TESTUSER -c \"mkdir -p $HOME_DIR/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}\"" + SPECDIR=$(su $TESTUSER -c "rpm --define '_topdir $HOME_DIR/rpmbuild' --eval %{_specdir}") + BUILDDIR=$(su $TESTUSER -c "rpm --define '_topdir $HOME_DIR/rpmbuild' --eval %{_builddir}") + + # Print some info + rlLog "RPM name: $RPM_NAME" + rlLog "Version: $VERSION" + rlLog "Spec Dir: $SPECDIR" + rlLog "Build Dir: $BUILDDIR" + + # Installing RPM + rlRun -s "su $TESTUSER -c \"rpm --define '_topdir $HOME_DIR/rpmbuild' -Uvh $TmpDir/$RPM_NAME\"" + rlRun "mv $rlRun_LOG $TmpDir/rpm-install.log" + + # Dependencies + REQ="" + for i in `yum deplist $RPM_NAME 2>/dev/null | grep "dependency:" | awk '/dependency:/ {print $2}'`; do REQ="$REQ $i"; done + if [ ! -z "$REQ" ]; then + yum -y install $REQ 2>&1 >> $TmpDir/yum-install.log + rlRun "rpm -q $REQ" + else + rlLog "Build dependencies satisfied." + fi + + # Building + rlRun -s "su $TESTUSER -c \"rpmbuild --define '_topdir $HOME_DIR/rpmbuild' -ba $SPECDIR/tar.spec\"" + rlRun "mv $rlRun_LOG $TmpDir/rpmbuild.log" + + # Using system /bin/tar for testsuite + rlRun "cd $BUILDDIR/tar-$VERSION" + rlRun "rm -f src/tar" + + # Starting testsuite on /bin/tar + rlLog "Starting testsuite!" + + rlRun "su $TESTUSER -c \"ln -s /bin/tar src/tar\"" + rlRun -s "su $TESTUSER -c \"cd $BUILDDIR/tar-$VERSION/tests && ./testsuite\"" + rlRun "mv $rlRun_LOG $TmpDir/testsuite.log" + + # Grep fails from logs + while read line + do + echo "$line" | grep "[0-9]\{0,\}:.*FAILED (" && rlFail "$line" + done < $TmpDir/testsuite.log + + # Data from stderr + SKIPPED=`grep "[0-9]\{0,3\} tests were skipped" $TmpDir/testsuite.log` + if [ `echo $SKIPPED | wc -l` -eq 1 ];then + rlLog "$SKIPPED" + fi + else + + rlFail "No src RPM downloaded." + + fi + + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "cd $TmpDir" + rlBundleLogs "tar-testsuite-logs" "testsuite.log" "rpm-install.log" "rpmbuild.log" "yum-install.log" + rlRun "popd" + rlRun "userdel -r $TESTUSER" + rlRun "rm -rf $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/tar-using-remote-host-via-ssh/Makefile b/tests/tar-using-remote-host-via-ssh/Makefile new file mode 100644 index 0000000..f84e9a4 --- /dev/null +++ b/tests/tar-using-remote-host-via-ssh/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/tar/Sanity/tar-using-remote-host-via-ssh +# Description: It would be nice to have also tested the default behaviour over ssh. +# Author: Petr Sklenar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/tar/Sanity/tar-using-remote-host-via-ssh +export TESTVERSION=1.1 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile + +.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: Petr Sklenar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: It would be nice to have also tested the default behaviour over ssh." >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: tar ssh" >> $(METADATA) + @echo "Requires: tar rmt ssh rsh" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/tar-using-remote-host-via-ssh/PURPOSE b/tests/tar-using-remote-host-via-ssh/PURPOSE new file mode 100644 index 0000000..7dcfe50 --- /dev/null +++ b/tests/tar-using-remote-host-via-ssh/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/tar/Sanity/tar-using-remote-host-via-ssh +Description: It would be nice to have also tested the default behaviour over ssh. +Author: Petr Sklenar diff --git a/tests/tar-using-remote-host-via-ssh/runtest.sh b/tests/tar-using-remote-host-via-ssh/runtest.sh new file mode 100755 index 0000000..b1b1f52 --- /dev/null +++ b/tests/tar-using-remote-host-via-ssh/runtest.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/tar/Sanity/tar-using-remote-host-via-ssh +# Description: It would be nice to have also tested the default behaviour over ssh. +# Author: Petr Sklenar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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="tar" + +rlJournalStart +if rlIsRHEL 5 6 ;then +sshpath=`which ssh` +echo "DEBUG: ssh cmd $sshpath" +ls -la $sshpath +which ssh +sshcmd="--rsh-command=$sshpath" +else +sshcmd="" +fi + + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlAssertRpm rmt + rlFileBackup /etc/ssh/ssh_config + rm -rf /tmp/mytarball.tar /tmp/tralalaa.petr + username=petr$RANDOM + conf=ssh_config + + echo 'Host localhost' >> /etc/ssh/ssh_config + echo ' UserKnownHostsFile /dev/null' >> /etc/ssh/ssh_config + echo ' StrictHostKeyChecking no' >> /etc/ssh/ssh_config + echo ' HostbasedAuthentication no' >> /etc/ssh/ssh_config + rlPhaseEnd + + rlPhaseStartTest +# copy&paste from http://pkgs.devel.redhat.com/cgit/tests/openssh/tree/sshd/sanity/runtest.sh + rlRun "useradd $username" + rlRun "echo $username | passwd --stdin $username" + homedir=`getent passwd $username | awk -F: '{print $6}'` + ls /root/.ssh/id_rsa || ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa + rlAssert0 "ssh-keygen passed" $? + mkdir /home/$username/.ssh + cat /root/.ssh/id_rsa.pub >> /home/$username/.ssh/authorized_keys + cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys + restorecon -R /home/$username/.ssh + rlPhaseEnd + + rlPhaseStartTest + rlAssertNotExists /tmp/mytarball.tar + echo 'hello world' > tralalaa.petr + rlRun "tar $sshcmd -c -f $username@localhost:/tmp/mytarball.tar tralalaa.petr" + rlAssertExists /tmp/mytarball.tar + rlPhaseEnd + + rlPhaseStartTest + rlLog "nothing" + rm -rf tralalaa.petr + rlRun "tar xvf /tmp/mytarball.tar" + rlRun "cat tralalaa.petr | grep 'hello world'" + rlPhaseEnd + + rlPhaseStartCleanup + rm -rf /tmp/mytarball.tar tralalaa.petr + userdel $username + rlLog "clean up" + rlFileRestore + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..36263d2 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,44 @@ +--- +# This first play always runs on the local staging system +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + tests: + - tar-testsuite + - tar-using-remote-host-via-ssh + required_packages: + - tar # required by both tests + - rmt # required by tar-using-remote-host-via-ssh + - rsh # required by both tests + - texinfo # required by tar-testsuite + - libacl-devel # required by tar-testsuite + - libselinux-devel # required by tar-testsuite + - rpm-build # required by tar-testsuite + - gcc # required by tar-testsuite + - attr # required by tar-testsuite + - autoconf # required by tar-testsuite + - automake # required by tar-testsuite + +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - container + tests: + - tar-testsuite + required_packages: + - tar # required by tar-testsuite + - rsh # required by tar-testsuite + - texinfo # required by tar-testsuite + - libacl-devel # required by tar-testsuite + - libselinux-devel # required by tar-testsuite + - rpm-build # required by tar-testsuite + - gcc # required by tar-testsuite + - attr # required by tar-testsuite + - autoconf # required by tar-testsuite + - automake # required by tar-testsuite + - gettext # required by tar-testsuite + - wget # required by tar-testsuite + - policycoreutils # required by tar-testsuite