From ae3ff361863b72d9cd52d9379cda7e7dbe825b15 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 5 Nov 2011 15:03:05 +0100 Subject: Adjust tests to use new db-remove interface --- test/test.d/create-filelists.sh | 2 +- test/test.d/db-remove.sh | 4 ++-- test/test.d/ftpdir-cleanup.sh | 8 ++++---- test/test.d/sourceballs.sh | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index 80b0927..49734c4 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -88,7 +88,7 @@ testCleanupFileLists() { ../db-update for arch in ${arches[@]}; do - ../db-remove pkg-simple-a extra ${arch} + ../db-remove extra ${arch} pkg-simple-a done for arch in ${arches[@]}; do diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index 573bd71..945ca62 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -19,7 +19,7 @@ testRemovePackages() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - ../db-remove ${pkgbase} extra ${arch} + ../db-remove extra ${arch} ${pkgbase} done done @@ -41,7 +41,7 @@ testRemoveAnyPackages() { ../db-update for pkgbase in ${pkgs[@]}; do - ../db-remove ${pkgbase} extra any + ../db-remove extra any ${pkgbase} done for pkgbase in ${pkgs[@]}; do diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 77b02b8..20026b4 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -18,7 +18,7 @@ testCleanupSimplePackages() { ../db-update for arch in ${arches[@]}; do - ../db-remove pkg-simple-a extra ${arch} + ../db-remove extra ${arch} pkg-simple-a done ../cron-jobs/ftpdir-cleanup >/dev/null @@ -49,7 +49,7 @@ testCleanupEpochPackages() { ../db-update for arch in ${arches[@]}; do - ../db-remove pkg-simple-epoch extra ${arch} + ../db-remove extra ${arch} pkg-simple-epoch done ../cron-jobs/ftpdir-cleanup >/dev/null @@ -72,7 +72,7 @@ testCleanupAnyPackages() { done ../db-update - ../db-remove pkg-any-a extra any + ../db-remove extra any pkg-any-a ../cron-jobs/ftpdir-cleanup >/dev/null local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' @@ -100,7 +100,7 @@ testCleanupSplitPackages() { ../db-update for arch in ${arches[@]}; do - ../db-remove ${pkgs[0]} extra ${arch} + ../db-remove extra ${arch} ${pkgs[0]} done ../cron-jobs/ftpdir-cleanup >/dev/null diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index 11bd0f4..fdcf08c 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -73,7 +73,7 @@ testSourceballsCleanup() { ../cron-jobs/sourceballs for arch in ${arches[@]}; do - ../db-remove pkg-simple-a extra ${arch} + ../db-remove extra ${arch} pkg-simple-a done ../cron-jobs/sourceballs -- cgit v1.2.3-54-g00ecf From 6159269bfbb850b2aed25e335fc5d538a2d4de4f Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 5 Nov 2011 16:34:53 +0100 Subject: db-remove: support removing multiple packages at once --- db-remove | 33 ++++++++++++++++++--------------- test/test.d/db-remove.sh | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/db-remove b/db-remove index 7e2282a..a3e03e6 100755 --- a/db-remove +++ b/db-remove @@ -10,7 +10,7 @@ fi repo="$1" arch="$2" -pkgbase="$3" +pkgbases=(${@:3}) ftppath="$FTP_BASE/$repo/os" svnrepo="$repo-$arch" @@ -29,21 +29,24 @@ for tarch in ${tarches[@]}; do repo_lock $repo $tarch || exit 1 done -msg "Removing $pkgbase from [$repo]..." -/usr/bin/svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null - -if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then - pkgnames=($(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) - /usr/bin/svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" - /usr/bin/svn commit -q "${WORKDIR}/svn/$pkgbase" -m "$(basename $0): $pkgbase removed by $(id -un)" -else - warning "$pkgbase not found in $svnrepo" - warning "Removing only $pkgbase from the repo" - warning "If it was a split package you have to remove the others yourself!" - pkgnames=($pkgbase) -fi +remove_pkgs=() +for pkgbase in ${pkgbases[@]}; do + msg "Removing $pkgbase from [$repo]..." + /usr/bin/svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null + + if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then + remove_pkgs=(${remove_pkgs[@]} $(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) + /usr/bin/svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" + /usr/bin/svn commit -q "${WORKDIR}/svn/$pkgbase" -m "$(basename $0): $pkgbase removed by $(id -un)" + else + warning "$pkgbase not found in $svnrepo" + warning "Removing only $pkgbase from the repo" + warning "If it was a split package you have to remove the others yourself!" + remove_pkgs[${#remove_pkgs[*]}]=$pkgbase + fi +done for tarch in ${tarches[@]}; do - arch_repo_remove "${repo}" "${tarch}" ${pkgnames[@]} + arch_repo_remove "${repo}" "${tarch}" ${remove_pkgs[@]} repo_unlock $repo $tarch done diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index 945ca62..416e693 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -30,6 +30,31 @@ testRemovePackages() { done } +testRemoveMultiplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for arch in ${arches[@]}; do + ../db-remove extra ${arch} ${pkgs[@]} + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkRemovedPackage extra ${pkgbase} ${arch} + done + done +} + testRemoveAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase -- cgit v1.2.3-54-g00ecf From 5c614ddd8ba74bca6a2dfe83a599601533d9ddc7 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 5 Nov 2011 17:38:16 +0100 Subject: check svn entry for any packages --- test/lib/common.inc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index c96e677..61e57d0 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -158,6 +158,11 @@ checkAnyPackage() { [ -r "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" [ -r "${FTP_BASE}/${repo}/os/any/${pkg}.sig" ] && fail "${repo}/os/any/${pkg}.sig should not exist" + + local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") + svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ + || fail "svn-packages-copy/${pkgbase}/repos/${repo}-any does not exist" } checkPackage() { -- cgit v1.2.3-54-g00ecf From 449f67604bad8794b3da80f2bc49d7e87c226048 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 5 Nov 2011 17:49:17 +0100 Subject: Split package database test functions from check* functions This way we can check consitency of databases independent from a svn repo --- test/lib/common.inc | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 61e57d0..a2dee10 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -125,7 +125,7 @@ releasePackage() { fi } -checkAnyPackage() { +checkAnyPackageDB() { local repo=$1 local pkg=$2 local arch @@ -158,6 +158,13 @@ checkAnyPackage() { [ -r "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" [ -r "${FTP_BASE}/${repo}/os/any/${pkg}.sig" ] && fail "${repo}/os/any/${pkg}.sig should not exist" +} + +checkAnyPackage() { + local repo=$1 + local pkg=$2 + + checkAnyPackageDB $repo $pkg local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" @@ -165,7 +172,7 @@ checkAnyPackage() { || fail "svn-packages-copy/${pkgbase}/repos/${repo}-any does not exist" } -checkPackage() { +checkPackageDB() { local repo=$1 local pkg=$2 local arch=$3 @@ -192,6 +199,14 @@ checkPackage() { && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done +} + +checkPackage() { + local repo=$1 + local pkg=$2 + local arch=$3 + + checkPackageDB $repo $pkg $arch local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" @@ -199,7 +214,7 @@ checkPackage() { || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" } -checkRemovedPackage() { +checkRemovedPackageDB() { local repo=$1 local pkgbase=$2 local arch=$3 @@ -210,13 +225,21 @@ checkRemovedPackage() { && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done +} + +checkRemovedPackage() { + local repo=$1 + local pkgbase=$2 + local arch=$3 + + checkRemovedPackageDB $repo $pkgbase $arch svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist" } -checkRemovedAnyPackage() { +checkRemovedAnyPackageDB() { local repo=$1 local pkgbase=$2 local arch @@ -229,6 +252,13 @@ checkRemovedAnyPackage() { && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done +} + +checkRemovedAnyPackage() { + local repo=$1 + local pkgbase=$2 + + checkRemovedAnyPackageDB $repo $pkgbase svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ -- cgit v1.2.3-54-g00ecf From 0c8c401b9638087e3f7127f83a2cb0b5cfdd3269 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 5 Nov 2011 17:56:29 +0100 Subject: Add test for moving multiple packages at once --- test/test.d/db-move.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 40b40de..9d7c1f6 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -27,6 +27,30 @@ testMoveSimplePackages() { done } +testMoveMultiplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage testing ${pkgbase} ${arch} + done + done + + ../db-update + + ../db-move testing extra pkg-simple-a pkg-simple-b + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkPackage extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + checkRemovedPackage testing ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + done + done +} + testMoveEpochPackages() { local arches=('i686' 'x86_64') local pkgs=('pkg-simple-epoch') -- cgit v1.2.3-54-g00ecf From 3084db6f3c6678eeb27ba0d532db0007432bfed1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 5 Nov 2011 18:37:51 +0100 Subject: Add simple tests for db-repo-add and db-repo-remove --- test/test.d/db-repo-add.sh | 54 ++++++++++++++++++++++++++++++++++++++++ test/test.d/db-repo-remove.sh | 58 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100755 test/test.d/db-repo-add.sh create mode 100755 test/test.d/db-repo-remove.sh (limited to 'test') diff --git a/test/test.d/db-repo-add.sh b/test/test.d/db-repo-add.sh new file mode 100755 index 0000000..8603104 --- /dev/null +++ b/test/test.d/db-repo-add.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testAddSimplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" + touch "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" + ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/extra/os/${arch}/" + ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" "${FTP_BASE}/extra/os/${arch}/" + ../db-repo-add extra ${arch} ${pkgbase}-1-1-${arch}.pkg.tar.xz + done + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkPackageDB extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + done + done +} + +testAddMultiplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b') + local pkgbase + local arch + + for arch in ${arches[@]}; do + add_pkgs=() + for pkgbase in ${pkgs[@]}; do + cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" + touch "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" + ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/extra/os/${arch}/" + ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" "${FTP_BASE}/extra/os/${arch}/" + add_pkgs[${#add_pkgs[*]}]=${pkgbase}-1-1-${arch}.pkg.tar.xz + done + ../db-repo-add extra ${arch} ${add_pkgs[@]} + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkPackageDB extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + done + done +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/db-repo-remove.sh b/test/test.d/db-repo-remove.sh new file mode 100755 index 0000000..315d63d --- /dev/null +++ b/test/test.d/db-repo-remove.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $0)) +. "${curdir}/../lib/common.inc" + +testRemovePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + ../db-repo-remove extra ${arch} ${pkgbase} + done + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkRemovedPackageDB extra ${pkgbase} ${arch} + done + done +} + +testRemoveMultiplePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') + local pkgbase + local arch + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update + + for arch in ${arches[@]}; do + ../db-repo-remove extra ${arch} ${pkgs[@]} + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkRemovedPackageDB extra ${pkgbase} ${arch} + done + done +} + +. "${curdir}/../lib/shunit2" -- cgit v1.2.3-54-g00ecf