From e9fafb43db4836f730c8ae2f5d9295a5392e5ee4 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: May 09 2017 05:12:40 +0000 Subject: Add tests for MM checkin. --- diff --git a/test/TODO b/test/TODO new file mode 100644 index 0000000..b193685 --- /dev/null +++ b/test/TODO @@ -0,0 +1,3 @@ +Need tests for: + +File list filtering (mirror) diff --git a/test/checkin/checkin.conf b/test/checkin/checkin.conf new file mode 100644 index 0000000..2c19443 --- /dev/null +++ b/test/checkin/checkin.conf @@ -0,0 +1,25 @@ +REMOTE=$TESTD/src +TIMEFILE=$TESTD/lastmirrortime +DESTD=$TESTD/dest +TMPDIR=$TESTD/tmp +LOGFILE=$TESTD/qfm.log + +MASTERMODULE=master +MODULEMAPPING=( +a module-a +) +MIRRORMANAGERMAPPING=( +a 'test-suite-a' +) +MIRRORMANAGERMODULEMAPPING=( +a module-a +) + +VERBOSE=9 +LOGITEMS=@ +MAXRETRIES=1 + +MODULES=(a) +CHECKIN_HOST='test.checkin.host' +CHECKIN_SITE='Test Suite Site' +CHECKIN_PASSWORD='secret' diff --git a/test/checkin/test b/test/checkin/test new file mode 100755 index 0000000..c609efe --- /dev/null +++ b/test/checkin/test @@ -0,0 +1,71 @@ +#!/bin/zsh +# Exercise the quick-fedora-mirror checkin +# This can't really exercise the checkin properly because it can't talk to the +# remote server, but we can dump the encoded payload, make sure it's decodable +# and then make sure it contains the necessary information. + +testdir=${0:A:h} +qfh=${0:A:h}/../../quick-fedora-hardlink +cf=${0:A:h}/../../create-filelist +qfm=${0:A:h}/../../quick-fedora-mirror + +test_checkin () { + # Just a simple copy + dc=$mdir/decoded-checkin + assertTrue 'A simple copy did not succeed' "$qfm -c $testdir/checkin.conf --dump-mm-checkin $mdir/checkin &> $so" # 2> $se" + assertFalse 'Errors present in log (1)' "file_contains $mdir/qfm.log \"E[rR][rR]\"" + assertTrue 'The content was not copied correctly' "dirs_contents_identical $srcdir/master $destdir" + grep '^.value..string.' $mdir/checkin-a \ + | sed -e 's///' -e 's,,,' \ + | tr -- '-_' '+/' \ + | base64 -d \ + | bzcat > $dc + assertTrue 'The payload could not be unpacked' "$?" + assertTrue 'Site name missing' "file_contains $dc \"name....Test Suite Site\"" + assertTrue 'Password missing' "file_contains $dc \"password....secret\"" + assertTrue 'Checkin host missing' "file_contains $dc \"test.checkin.host\"" + assertTrue 'Module name missing' "file_contains $dc \"test-suite-a...{\"" + for i in $(find $td/ -type d); do + d=${i/$td\//} + assertTrue "Dir missing $d" "file_contains $dc \" .$d.: {}\"" + done +} + +setUp () { + td="$master/module-a" + fl=$td/fullfiletimelist-module-a + + mkdir -p $mdir/tmp $srcdir $master $td $destdir + + create_dir_structure $td 2 7 + mkdir -p $td/module-a/z/z + $cf -d $td -s -f $td/fullfilelist -t $td/fullfiletimelist-module-a + touch $td/imagelist-module-a + + mkdir $sd + touch $mdir/qfm.log + export TESTD=$mdir +} + +tearDown () { + rm -rf $tdup $sd + if [[ -n "$TEST_VERBOSE" ]]; then + if [[ -s $so ]]; then + echo "Assertion standard output:" + cat $so + fi + if [[ -s $se ]]; then + echo "Assertion standard error:" + cat $se + fi + fi + rm -rf $so $se $mdir +} + +# load local functions +source ${0:h}/../test-setup.zsh + +# load shunit2 +SHUNIT_PARENT=$0 +setopt shwordsplit +. $(find-shunit)