From 61d8639a8acb663c8296a2b049cd6dd0f3bb2842 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 1 Sep 2014 22:25:17 +0400 Subject: [PATCH] System tests for aptly snapshot filter. #82 --- system/t05_snapshot/FilterSnapshot1Test_gold | 5 + .../FilterSnapshot1Test_snapshot_show | 8 ++ system/t05_snapshot/FilterSnapshot2Test_gold | 5 + .../FilterSnapshot2Test_snapshot_show | 13 ++ system/t05_snapshot/FilterSnapshot3Test_gold | 5 + .../FilterSnapshot3Test_snapshot_show | 127 ++++++++++++++++++ system/t05_snapshot/FilterSnapshot4Test_gold | 4 + .../FilterSnapshot4Test_snapshot_list | 4 + system/t05_snapshot/FilterSnapshot5Test_gold | 1 + system/t05_snapshot/FilterSnapshot6Test_gold | 3 + system/t05_snapshot/FilterSnapshot7Test_gold | 5 + .../FilterSnapshot7Test_snapshot_show | 14 ++ system/t05_snapshot/__init__.py | 1 + system/t05_snapshot/filter.py | 113 ++++++++++++++++ 14 files changed, 308 insertions(+) create mode 100644 system/t05_snapshot/FilterSnapshot1Test_gold create mode 100644 system/t05_snapshot/FilterSnapshot1Test_snapshot_show create mode 100644 system/t05_snapshot/FilterSnapshot2Test_gold create mode 100644 system/t05_snapshot/FilterSnapshot2Test_snapshot_show create mode 100644 system/t05_snapshot/FilterSnapshot3Test_gold create mode 100644 system/t05_snapshot/FilterSnapshot3Test_snapshot_show create mode 100644 system/t05_snapshot/FilterSnapshot4Test_gold create mode 100644 system/t05_snapshot/FilterSnapshot4Test_snapshot_list create mode 100644 system/t05_snapshot/FilterSnapshot5Test_gold create mode 100644 system/t05_snapshot/FilterSnapshot6Test_gold create mode 100644 system/t05_snapshot/FilterSnapshot7Test_gold create mode 100644 system/t05_snapshot/FilterSnapshot7Test_snapshot_show create mode 100644 system/t05_snapshot/filter.py diff --git a/system/t05_snapshot/FilterSnapshot1Test_gold b/system/t05_snapshot/FilterSnapshot1Test_gold new file mode 100644 index 00000000..63cad56b --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot1Test_gold @@ -0,0 +1,5 @@ +Loading packages (661)... +Building indexes... + +Snapshot snap2 successfully filtered. +You can run 'aptly publish snapshot snap2' to publish snapshot as Debian repository. diff --git a/system/t05_snapshot/FilterSnapshot1Test_snapshot_show b/system/t05_snapshot/FilterSnapshot1Test_snapshot_show new file mode 100644 index 00000000..bd085c4d --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot1Test_snapshot_show @@ -0,0 +1,8 @@ +Name: snap2 +Description: Filtered 'snap1', query was: 'mame unrar' +Number of packages: 4 +Packages: + mame_0.146-5_amd64 + unrar_1:4.1.4-1_amd64 + mame_0.146-5_i386 + unrar_1:4.1.4-1_i386 diff --git a/system/t05_snapshot/FilterSnapshot2Test_gold b/system/t05_snapshot/FilterSnapshot2Test_gold new file mode 100644 index 00000000..a2956341 --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot2Test_gold @@ -0,0 +1,5 @@ +Loading packages (4742)... +Building indexes... + +Snapshot snap2 successfully filtered. +You can run 'aptly publish snapshot snap2' to publish snapshot as Debian repository. diff --git a/system/t05_snapshot/FilterSnapshot2Test_snapshot_show b/system/t05_snapshot/FilterSnapshot2Test_snapshot_show new file mode 100644 index 00000000..677c33d1 --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot2Test_snapshot_show @@ -0,0 +1,13 @@ +Name: snap2 +Description: Filtered 'snap1', query was: 'rsyslog (>= 7.4.4)' +Number of packages: 9 +Packages: + init-system-helpers_1.18~bpo70+1_all + libestr0_0.1.9-1~bpo70+1_amd64 + libjson-c2_0.11-3~bpo7+1_amd64 + liblogging-stdlog0_1.0.4-1~bpo70+1_amd64 + rsyslog_7.6.3-2~bpo70+1_amd64 + libestr0_0.1.9-1~bpo70+1_i386 + libjson-c2_0.11-3~bpo7+1_i386 + liblogging-stdlog0_1.0.4-1~bpo70+1_i386 + rsyslog_7.6.3-2~bpo70+1_i386 diff --git a/system/t05_snapshot/FilterSnapshot3Test_gold b/system/t05_snapshot/FilterSnapshot3Test_gold new file mode 100644 index 00000000..391ea639 --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot3Test_gold @@ -0,0 +1,5 @@ +Loading packages (56121)... +Building indexes... + +Snapshot snap2 successfully filtered. +You can run 'aptly publish snapshot snap2' to publish snapshot as Debian repository. diff --git a/system/t05_snapshot/FilterSnapshot3Test_snapshot_show b/system/t05_snapshot/FilterSnapshot3Test_snapshot_show new file mode 100644 index 00000000..680283f2 --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot3Test_snapshot_show @@ -0,0 +1,127 @@ +Name: snap2 +Description: Filtered 'snap1', query was: 'Priority (required) nginx xyz' +Number of packages: 123 +Packages: + debconf_1.5.49_all + debconf-i18n_1.5.49_all + libpam-runtime_1.1.3-7.1_all + libtext-wrapi18n-perl_0.06-7_all + lsb-base_4.1+Debian8+deb7u1_all + ncurses-base_5.9-10_all + nginx_1.2.1-2.2+wheezy2_all + nginx-naxsi-ui_1.2.1-2.2+wheezy2_all + sensible-utils_0.0.7_all + sysv-rc_2.88dsf-41+deb7u1_all + tzdata_2014a-0wheezy1_all + base-files_7.1wheezy5_amd64 + base-passwd_3.5.26_amd64 + bash_4.2+dfsg-0.1_amd64 + bsdutils_1:2.20.1-5.3_amd64 + coreutils_8.13-3.5_amd64 + dash_0.5.7-3_amd64 + debianutils_4.3.2_amd64 + diffutils_1:3.2-6_amd64 + dpkg_1.16.12_amd64 + e2fslibs_1.42.5-1.1_amd64 + e2fsprogs_1.42.5-1.1_amd64 + findutils_4.4.2-4_amd64 + gcc-4.7-base_4.7.2-5_amd64 + grep_2.12-2_amd64 + gzip_1.5-1.1_amd64 + hostname_3.11_amd64 + initscripts_2.88dsf-41+deb7u1_amd64 + libacl1_2.2.51-8_amd64 + libattr1_1:2.4.46-8_amd64 + libblkid1_2.20.1-5.3_amd64 + libc-bin_2.13-38+deb7u1_amd64 + libc6_2.13-38+deb7u1_amd64 + libcomerr2_1.42.5-1.1_amd64 + libgcc1_1:4.7.2-5_amd64 + liblocale-gettext-perl_1.05-7+b1_amd64 + liblzma5_5.1.1alpha+20120614-2_amd64 + libmount1_2.20.1-5.3_amd64 + libncurses5_5.9-10_amd64 + libpam-modules_1.1.3-7.1_amd64 + libpam-modules-bin_1.1.3-7.1_amd64 + libpam0g_1.1.3-7.1_amd64 + libselinux1_2.1.9-5_amd64 + libsepol1_2.1.4-3_amd64 + libss2_1.42.5-1.1_amd64 + libtext-charwidth-perl_0.04-7+b1_amd64 + libtext-iconv-perl_1.7-5_amd64 + libtinfo5_5.9-10_amd64 + libuuid1_2.20.1-5.3_amd64 + login_1:4.1.5.1-1_amd64 + mawk_1.3.3-17_amd64 + mount_2.20.1-5.3_amd64 + multiarch-support_2.13-38+deb7u1_amd64 + ncurses-bin_5.9-10_amd64 + nginx-extras_1.2.1-2.2+wheezy2_amd64 + nginx-full_1.2.1-2.2+wheezy2_amd64 + nginx-light_1.2.1-2.2+wheezy2_amd64 + nginx-naxsi_1.2.1-2.2+wheezy2_amd64 + passwd_1:4.1.5.1-1_amd64 + perl-base_5.14.2-21+deb7u1_amd64 + sed_4.2.1-10_amd64 + sysvinit_2.88dsf-41+deb7u1_amd64 + sysvinit-utils_2.88dsf-41+deb7u1_amd64 + tar_1.26+dfsg-0.1_amd64 + util-linux_2.20.1-5.3_amd64 + xz-utils_5.1.1alpha+20120614-2_amd64 + zlib1g_1:1.2.7.dfsg-13_amd64 + base-files_7.1wheezy5_i386 + base-passwd_3.5.26_i386 + bash_4.2+dfsg-0.1_i386 + bsdutils_1:2.20.1-5.3_i386 + coreutils_8.13-3.5_i386 + dash_0.5.7-3_i386 + debianutils_4.3.2_i386 + diffutils_1:3.2-6_i386 + dpkg_1.16.12_i386 + e2fslibs_1.42.5-1.1_i386 + e2fsprogs_1.42.5-1.1_i386 + findutils_4.4.2-4_i386 + gcc-4.7-base_4.7.2-5_i386 + grep_2.12-2_i386 + gzip_1.5-1.1_i386 + hostname_3.11_i386 + initscripts_2.88dsf-41+deb7u1_i386 + libacl1_2.2.51-8_i386 + libattr1_1:2.4.46-8_i386 + libblkid1_2.20.1-5.3_i386 + libc-bin_2.13-38+deb7u1_i386 + libc6_2.13-38+deb7u1_i386 + libcomerr2_1.42.5-1.1_i386 + libgcc1_1:4.7.2-5_i386 + liblocale-gettext-perl_1.05-7+b1_i386 + liblzma5_5.1.1alpha+20120614-2_i386 + libmount1_2.20.1-5.3_i386 + libncurses5_5.9-10_i386 + libpam-modules_1.1.3-7.1_i386 + libpam-modules-bin_1.1.3-7.1_i386 + libpam0g_1.1.3-7.1_i386 + libselinux1_2.1.9-5_i386 + libsepol1_2.1.4-3_i386 + libss2_1.42.5-1.1_i386 + libtext-charwidth-perl_0.04-7+b1_i386 + libtext-iconv-perl_1.7-5_i386 + libtinfo5_5.9-10_i386 + libuuid1_2.20.1-5.3_i386 + login_1:4.1.5.1-1_i386 + mawk_1.3.3-17_i386 + mount_2.20.1-5.3_i386 + multiarch-support_2.13-38+deb7u1_i386 + ncurses-bin_5.9-10_i386 + nginx-extras_1.2.1-2.2+wheezy2_i386 + nginx-full_1.2.1-2.2+wheezy2_i386 + nginx-light_1.2.1-2.2+wheezy2_i386 + nginx-naxsi_1.2.1-2.2+wheezy2_i386 + passwd_1:4.1.5.1-1_i386 + perl-base_5.14.2-21+deb7u1_i386 + sed_4.2.1-10_i386 + sysvinit_2.88dsf-41+deb7u1_i386 + sysvinit-utils_2.88dsf-41+deb7u1_i386 + tar_1.26+dfsg-0.1_i386 + util-linux_2.20.1-5.3_i386 + xz-utils_5.1.1alpha+20120614-2_i386 + zlib1g_1:1.2.7.dfsg-13_i386 diff --git a/system/t05_snapshot/FilterSnapshot4Test_gold b/system/t05_snapshot/FilterSnapshot4Test_gold new file mode 100644 index 00000000..1da93884 --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot4Test_gold @@ -0,0 +1,4 @@ +Loading packages (4742)... +Building indexes... + +Not creating snapshot, as dry run was requested. diff --git a/system/t05_snapshot/FilterSnapshot4Test_snapshot_list b/system/t05_snapshot/FilterSnapshot4Test_snapshot_list new file mode 100644 index 00000000..a1473ec3 --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot4Test_snapshot_list @@ -0,0 +1,4 @@ +List of snapshots: + * [snap1]: Snapshot from mirror [wheezy-backports]: http://mirror.yandex.ru/debian/ wheezy-backports + +To get more information about snapshot, run `aptly snapshot show `. diff --git a/system/t05_snapshot/FilterSnapshot5Test_gold b/system/t05_snapshot/FilterSnapshot5Test_gold new file mode 100644 index 00000000..c5297b7d --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot5Test_gold @@ -0,0 +1 @@ +ERROR: unable to filter: snapshot with name snap1 not found diff --git a/system/t05_snapshot/FilterSnapshot6Test_gold b/system/t05_snapshot/FilterSnapshot6Test_gold new file mode 100644 index 00000000..dc77e3f2 --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot6Test_gold @@ -0,0 +1,3 @@ +Loading packages (56121)... +Building indexes... +ERROR: unable to create snapshot: snapshot with name snap2 already exists diff --git a/system/t05_snapshot/FilterSnapshot7Test_gold b/system/t05_snapshot/FilterSnapshot7Test_gold new file mode 100644 index 00000000..703595ce --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot7Test_gold @@ -0,0 +1,5 @@ +Loading packages (5550)... +Building indexes... + +Snapshot snap2 successfully filtered. +You can run 'aptly publish snapshot snap2' to publish snapshot as Debian repository. diff --git a/system/t05_snapshot/FilterSnapshot7Test_snapshot_show b/system/t05_snapshot/FilterSnapshot7Test_snapshot_show new file mode 100644 index 00000000..b5e57038 --- /dev/null +++ b/system/t05_snapshot/FilterSnapshot7Test_snapshot_show @@ -0,0 +1,14 @@ +Name: snap2 +Description: Filtered 'snap1', query was: 'rsyslog (>= 7.4.4), $Architecture (i386)' +Number of packages: 10 +Packages: + init-system-helpers_1.18~bpo70+1_all + libestr0_0.1.9-1~bpo70+1_i386 + libjson-c2_0.11-3~bpo7+1_i386 + liblogging-stdlog0_1.0.4-1~bpo70+1_i386 + rsyslog_7.6.3-2~bpo70+1_i386 + init-system-helpers_1.18~bpo70+1_source + json-c_0.11-3~bpo7+1_source + libestr_0.1.9-1~bpo70+1_source + liblogging_1.0.4-1~bpo70+1_source + rsyslog_7.6.3-2~bpo70+1_source diff --git a/system/t05_snapshot/__init__.py b/system/t05_snapshot/__init__.py index a61f3aa4..4e1995e9 100644 --- a/system/t05_snapshot/__init__.py +++ b/system/t05_snapshot/__init__.py @@ -12,3 +12,4 @@ from .merge import * from .drop import * from .rename import * from .search import * +from .filter import * \ No newline at end of file diff --git a/system/t05_snapshot/filter.py b/system/t05_snapshot/filter.py new file mode 100644 index 00000000..53befe81 --- /dev/null +++ b/system/t05_snapshot/filter.py @@ -0,0 +1,113 @@ +from lib import BaseTest +import re + + +class FilterSnapshot1Test(BaseTest): + """ + filter snapshot: simple filter + """ + fixtureDB = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror wheezy-non-free", + ] + runCmd = "aptly snapshot filter snap1 snap2 mame unrar" + + def check(self): + def remove_created_at(s): + return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s) + + self.check_output() + self.check_cmd_output("aptly snapshot show -with-packages snap2", "snapshot_show", match_prepare=remove_created_at) + + +class FilterSnapshot2Test(BaseTest): + """ + filter snapshot: play with versions + """ + fixtureDB = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror wheezy-backports", + ] + runCmd = "aptly snapshot filter -with-deps snap1 snap2 'rsyslog (>= 7.4.4)'" + + def check(self): + def remove_created_at(s): + return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s) + + self.check_output() + self.check_cmd_output("aptly snapshot show -with-packages snap2", "snapshot_show", match_prepare=remove_created_at) + + +class FilterSnapshot3Test(BaseTest): + """ + filter snapshot: complex condition + """ + fixtureDB = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror wheezy-main", + ] + runCmd = "aptly snapshot filter snap1 snap2 'Priority (required)' nginx xyz" + + def check(self): + def remove_created_at(s): + return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s) + + self.check_output() + self.check_cmd_output("aptly snapshot show -with-packages snap2", "snapshot_show", match_prepare=remove_created_at) + + +class FilterSnapshot4Test(BaseTest): + """ + filter snapshot: dry-run + """ + fixtureDB = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror wheezy-backports", + ] + runCmd = "aptly snapshot filter -dry-run snap1 snap2 'rsyslog (>= 7.4.4)'" + + def check(self): + self.check_output() + self.check_cmd_output("aptly snapshot list", "snapshot_list") + + +class FilterSnapshot5Test(BaseTest): + """ + filter snapshot: no such snapshot + """ + fixtureDB = True + fixtureCmds = [ + ] + runCmd = "aptly snapshot filter snap1 snap2 'rsyslog (>= 7.4.4)'" + expectedCode = 1 + + +class FilterSnapshot6Test(BaseTest): + """ + filter snapshot: duplicate snapshot + """ + fixtureDB = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror wheezy-main", + "aptly snapshot merge snap2 snap1", + ] + runCmd = "aptly snapshot filter snap1 snap2 'rsyslog (>= 7.4.4)'" + expectedCode = 1 + + +class FilterSnapshot7Test(BaseTest): + """ + filter snapshot: follow sources + """ + fixtureDB = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror wheezy-backports-src", + ] + runCmd = "aptly -dep-follow-source snapshot filter -with-deps snap1 snap2 'rsyslog (>= 7.4.4), $$Architecture (i386)'" + + def check(self): + def remove_created_at(s): + return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s) + + self.check_output() + self.check_cmd_output("aptly snapshot show --with-packages snap2", "snapshot_show", match_prepare=remove_created_at)