From 8830354027e5faa8ee80d16b466a4edcf30aa107 Mon Sep 17 00:00:00 2001 From: Gordian Schoenherr Date: Fri, 20 Dec 2024 09:39:20 +0900 Subject: [PATCH] Extend system tests for @file filter syntax --- system/t04_mirror/CreateMirror36Test_gold | 4 ++ .../t04_mirror/CreateMirror36Test_mirror_show | 22 ++++++++++ system/t04_mirror/CreateMirror37Test_gold | 4 ++ .../t04_mirror/CreateMirror37Test_mirror_show | 22 ++++++++++ system/t04_mirror/create.py | 43 +++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 system/t04_mirror/CreateMirror36Test_gold create mode 100644 system/t04_mirror/CreateMirror36Test_mirror_show create mode 100644 system/t04_mirror/CreateMirror37Test_gold create mode 100644 system/t04_mirror/CreateMirror37Test_mirror_show diff --git a/system/t04_mirror/CreateMirror36Test_gold b/system/t04_mirror/CreateMirror36Test_gold new file mode 100644 index 00000000..eb089d7e --- /dev/null +++ b/system/t04_mirror/CreateMirror36Test_gold @@ -0,0 +1,4 @@ +Downloading: http://repo.aptly.info/system-tests/archive.debian.org/debian-security/dists/stretch/updates/Release + +Mirror [mirror36]: http://repo.aptly.info/system-tests/archive.debian.org/debian-security/ stretch/updates successfully added. +You can run 'aptly mirror update mirror36' to download repository contents. diff --git a/system/t04_mirror/CreateMirror36Test_mirror_show b/system/t04_mirror/CreateMirror36Test_mirror_show new file mode 100644 index 00000000..c6188417 --- /dev/null +++ b/system/t04_mirror/CreateMirror36Test_mirror_show @@ -0,0 +1,22 @@ +Name: mirror36 +Archive Root URL: http://repo.aptly.info/system-tests/archive.debian.org/debian-security/ +Distribution: stretch/updates +Components: main +Architectures: amd64, arm64, armel, armhf, i386 +Download Sources: no +Download .udebs: no +Filter: nginx | Priority (required) +Filter With Deps: no +Last update: never + +Information from release file: +Acquire-By-Hash: yes +Architectures: amd64 arm64 armel armhf i386 +Codename: stretch +Components: updates/main updates/contrib updates/non-free +Description: Debian 9 Security Updates + +Label: Debian-Security +Origin: Debian +Suite: oldoldstable +Version: 9 diff --git a/system/t04_mirror/CreateMirror37Test_gold b/system/t04_mirror/CreateMirror37Test_gold new file mode 100644 index 00000000..ef68aabc --- /dev/null +++ b/system/t04_mirror/CreateMirror37Test_gold @@ -0,0 +1,4 @@ +Downloading: http://repo.aptly.info/system-tests/archive.debian.org/debian-security/dists/stretch/updates/Release + +Mirror [mirror37]: http://repo.aptly.info/system-tests/archive.debian.org/debian-security/ stretch/updates successfully added. +You can run 'aptly mirror update mirror37' to download repository contents. diff --git a/system/t04_mirror/CreateMirror37Test_mirror_show b/system/t04_mirror/CreateMirror37Test_mirror_show new file mode 100644 index 00000000..aa2750a2 --- /dev/null +++ b/system/t04_mirror/CreateMirror37Test_mirror_show @@ -0,0 +1,22 @@ +Name: mirror37 +Archive Root URL: http://repo.aptly.info/system-tests/archive.debian.org/debian-security/ +Distribution: stretch/updates +Components: main +Architectures: amd64, arm64, armel, armhf, i386 +Download Sources: no +Download .udebs: no +Filter: nginx | Priority (required) +Filter With Deps: no +Last update: never + +Information from release file: +Acquire-By-Hash: yes +Architectures: amd64 arm64 armel armhf i386 +Codename: stretch +Components: updates/main updates/contrib updates/non-free +Description: Debian 9 Security Updates + +Label: Debian-Security +Origin: Debian +Suite: oldoldstable +Version: 9 diff --git a/system/t04_mirror/create.py b/system/t04_mirror/create.py index ecf3b6d4..a2cdbf74 100644 --- a/system/t04_mirror/create.py +++ b/system/t04_mirror/create.py @@ -1,3 +1,4 @@ +from pathlib import Path import re import os @@ -489,3 +490,45 @@ class CreateMirror35Test(BaseTest): def check(self): self.check_output() self.check_cmd_output("aptly mirror show mirror35", "mirror_show") + + +class CreateMirror36Test(BaseTest): + """ + create mirror: mirror with filter read from file + """ + filterFilePath = os.path.join(os.environ["HOME"], ".aptly-filter.tmp") + fixtureCmds = [f"bash -c \"echo -n 'nginx | Priority (required)' > {filterFilePath}\""] + runCmd = f"aptly mirror create -ignore-signatures -filter='@{filterFilePath}' mirror36 http://repo.aptly.info/system-tests/archive.debian.org/debian-security/ stretch/updates main" + + def check(self): + def removeDates(s): + return re.sub(r"(Date|Valid-Until): [,0-9:+A-Za-z -]+\n", "", s) + + self.check_output() + self.check_cmd_output("aptly mirror show mirror36", + "mirror_show", match_prepare=removeDates) + + +class CreateMirror37Test(BaseTest): + """ + create mirror: mirror with filter read from stdin + """ + aptly_testing_bin = Path(__file__).parent.parent.parent / "aptly.test" + # Hack: Normally the test system detects if runCmd is an aptly command and then + # substitutes the aptly_testing_bin path and deletes the last three lines of output. + # However, I need to run it in bash to control stdin, so I have to do it manually. + runCmd = [ + "bash", + "-c", + f"echo -n 'nginx | Priority (required)' | {aptly_testing_bin} mirror create " + + "-ignore-signatures -filter='@-' mirror37 http://repo.aptly.info/system-tests/archive.debian.org/debian-security/ stretch/updates main " + + "| grep -vE '^(EXIT|PASS|coverage:)'" + ] + + def check(self): + def removeDates(s): + return re.sub(r"(Date|Valid-Until): [,0-9:+A-Za-z -]+\n", "", s) + + self.check_output() + self.check_cmd_output("aptly mirror show mirror37", + "mirror_show", match_prepare=removeDates)