Skip to content

Commit

Permalink
system tests: use repository mirrors on S3 for reproducibility
Browse files Browse the repository at this point in the history
no direct internet download from apt repositories,
which over time will change or cease to exist.

also migrate to gpg2 on newer ubuntu.
  • Loading branch information
neolynx committed Feb 5, 2024
1 parent a69aa7c commit d7cc9b8
Show file tree
Hide file tree
Showing 98 changed files with 1,435 additions and 1,481 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[flake8]
max-line-length = 200
max-line-length = 240
ignore = E126,E241,E741,W504
include =
system
exclude =
system/env
system/env
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
*.o
*.a
*.so
unit.out

# Folders
_obj
_test

tmp/

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ TESTS?=
BINPATH?=$(GOPATH)/bin
RUN_LONG_TESTS?=yes
COVERAGE_DIR?=$(shell mktemp -d)
# Uncomment to update test outputs
# CAPTURE := "--capture"

all: modules test bench check system-test

Expand Down Expand Up @@ -47,7 +49,7 @@ ifeq ($(RUN_LONG_TESTS), yes)
go test -v -coverpkg="./..." -c -tags testruncli
if [ ! -e ~/aptly-fixture-db ]; then git clone https://github.com/aptly-dev/aptly-fixture-db.git ~/aptly-fixture-db/; fi
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
PATH=$(BINPATH)/:$(PATH) && . system/env/bin/activate && APTLY_VERSION=$(VERSION) $(PYTHON) system/run.py --long $(TESTS) --coverage-dir $(COVERAGE_DIR)
PATH=$(BINPATH)/:$(PATH) && . system/env/bin/activate && APTLY_VERSION=$(VERSION) $(PYTHON) system/run.py --long $(TESTS) --coverage-dir $(COVERAGE_DIR) $(CAPTURE)
endif

test:
Expand Down
2 changes: 1 addition & 1 deletion api/gpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func apiGPGAddKey(c *gin.Context) {
args = append(args, keys...)
}

finder := pgp.GPG1Finder()
finder := pgp.GPGDefaultFinder()
gpg, _, err := finder.FindGPG()
if err != nil {
AbortWithJSONError(c, 400, err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d
github.com/ugorji/go/codec v1.2.11
github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/sys v0.13.0
golang.org/x/term v0.13.0
golang.org/x/time v0.3.0
Expand Down Expand Up @@ -90,6 +89,7 @@ require (
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
golang.org/x/arch v0.5.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
6 changes: 3 additions & 3 deletions system/fixture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ aptly mirror update wheezy-non-free-src
aptly mirror update wheezy-updates-src
aptly mirror update wheezy-backports-src

aptly mirror create gnuplot-maverick http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick
aptly mirror create gnuplot-maverick http://repo.aptly.info/system-tests/ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick
aptly mirror update gnuplot-maverick

aptly mirror create -with-sources gnuplot-maverick-src http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick
aptly mirror create -with-sources gnuplot-maverick-src http://repo.aptly.info/system-tests/ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick
aptly mirror update gnuplot-maverick-src

aptly mirror create sensu http://repos.sensuapp.org/apt sensu
aptly mirror update sensu
aptly mirror update sensu
8 changes: 4 additions & 4 deletions system/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def sort_lines(self, output):
return "\n".join(sorted(self.ensure_utf8(output).split("\n")))

def run(self):
output = self.run_cmd(self.runCmd, self.expectedCode)
output = self.run_cmd(self.runCmd, self.expectedCode).decode("utf-8")
if self.sortOutput:
output = self.sort_lines(output)
self.output = self.output_processor(output)
Expand Down Expand Up @@ -342,7 +342,7 @@ def check_output(self):
try:
self.verify_match(self.get_gold(), self.output,
match_prepare=self.outputMatchPrepare)
except: # noqa: E722
except Exception: # noqa: E722
if self.captureResults:
if self.outputMatchPrepare is not None:
self.output = self.outputMatchPrepare(self.output)
Expand All @@ -352,7 +352,7 @@ def check_output(self):
raise

def check_cmd_output(self, command, gold_name, match_prepare=None, expected_code=0):
output = self.run_cmd(command, expected_code=expected_code)
output = self.run_cmd(command, expected_code=expected_code).decode("utf-8")
try:
self.verify_match(self.get_gold(gold_name), output, match_prepare)
except: # noqa: E722
Expand Down Expand Up @@ -439,7 +439,7 @@ def check_subset(self, a, b):
diff += "wrong value '%s' for key '%s', expected '%s'\n" % (
v, k, b[k])
if diff:
raise Exception("content doesn't match:\n" + diff)
raise Exception("content subset doesn't match:\n" + diff)

def ensure_utf8(self, a):
if isinstance(a, bytes):
Expand Down
12 changes: 6 additions & 6 deletions system/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def run(include_long_tests=False, capture_results=False, tests=None, filters=Non
if sys.version_info < PYTHON_MINIMUM_VERSION:
raise RuntimeError(f'Tests require Python {PYTHON_MINIMUM_VERSION} or higher.')

output = subprocess.check_output(['gpg1', '--version'], text=True)
if not output.startswith('gpg (GnuPG) 1'):
raise RuntimeError('Tests require gpg v1')
output = subprocess.check_output(['gpg', '--version'], text=True)
if not output.startswith('gpg (GnuPG) 2'):
raise RuntimeError('Tests require gpg v2')

output = subprocess.check_output(['gpgv1', '--version'], text=True)
if not output.startswith('gpgv (GnuPG) 1'):
raise RuntimeError('Tests require gpgv v1')
output = subprocess.check_output(['gpgv', '--version'], text=True)
if not output.startswith('gpgv (GnuPG) 2'):
raise RuntimeError('Tests require gpgv v2')

os.chdir(os.path.realpath(os.path.dirname(sys.argv[0])))
random.seed()
Expand Down
24 changes: 14 additions & 10 deletions system/t04_mirror/CreateMirror10Test_gold
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch-backports/InRelease...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch-backports/InRelease
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch-backports/InRelease...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch-backports/InRelease

gpgv: RSA key ID 22F3D138
gpgv: Signature made Thu Mar 30 14:21:34 2023 UTC
gpgv: using RSA key 0146DC6D4A0B2914BDED34DB648ACFD622F3D138

gpgv: RSA key ID 386FA1D9
gpgv: Signature made Thu Mar 30 14:22:13 2023 UTC
gpgv: using RSA key A7236886F3CCCAAD148A27F80E98404D386FA1D9

Downloading http://archive.debian.org/debian-archive/debian/dists/stretch-backports/Release...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch-backports/Release
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch-backports/Release.gpg...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch-backports/Release.gpg
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch-backports/Release...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch-backports/Release
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch-backports/Release.gpg...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch-backports/Release.gpg

gpgv: RSA key ID 22F3D138
gpgv: Signature made Thu Mar 30 14:20:54 2023 UTC
gpgv: using RSA key 0146DC6D4A0B2914BDED34DB648ACFD622F3D138

gpgv: RSA key ID 386FA1D9
gpgv: Signature made Thu Mar 30 14:21:30 2023 UTC
gpgv: using RSA key A7236886F3CCCAAD148A27F80E98404D386FA1D9

ERROR: unable to fetch mirror: verification of detached signature failed: exit status 2
32 changes: 19 additions & 13 deletions system/t04_mirror/CreateMirror11Test_gold
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Error downloading http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease: HTTP code 404 while fetching http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease retrying...
Retrying 0 http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Giving up on http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release.gpg...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release.gpg
gpgv: RSA key ID B7D453EC
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Error downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease: HTTP code 404 while fetching http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease retrying...
Retrying 0 http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Giving up on http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release.gpg...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release.gpg
gpgv: can't allocate lock for '/home/runner/.gnupg/aptlytest.gpg'
gpgv: Signature made Sat Aug 14 07:43:24 2021 UTC
gpgv: using RSA key 16E90B3FDF65EDE3AA7F323C04EE7237B7D453EC
gpgv: Good signature from "Debian Archive Automatic Signing Key (9/stretch) <ftpmaster@debian.org>"
gpgv: RSA key ID 22F3D138
gpgv: Signature made Sat Aug 14 07:43:25 2021 UTC
gpgv: using RSA key 0146DC6D4A0B2914BDED34DB648ACFD622F3D138
gpgv: Good signature from "Debian Archive Automatic Signing Key (10/buster) <ftpmaster@debian.org>"
gpgv: RSA key ID 386FA1D9
gpgv: Signature made Sat Aug 14 08:46:19 2021 UTC
gpgv: using RSA key A7236886F3CCCAAD148A27F80E98404D386FA1D9
gpgv: Good signature from "Debian Archive Automatic Signing Key (11/bullseye) <ftpmaster@debian.org>"
gpgv: RSA key ID 1A7B6500
gpgv: Signature made Sat Aug 14 08:26:43 2021 UTC
gpgv: using RSA key 067E3C456BAE240ACEE88F6FEF0F382A1A7B6500
gpgv: issuer "debian-release@lists.debian.org"
gpgv: Good signature from "Debian Stable Release Key (9/stretch) <debian-release@lists.debian.org>"

Mirror [mirror11]: http://archive.debian.org/debian-archive/debian/ stretch successfully added.
Mirror [mirror11]: http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/ stretch successfully added.
You can run 'aptly mirror update mirror11' to download repository contents.
2 changes: 1 addition & 1 deletion system/t04_mirror/CreateMirror11Test_mirror_show
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mirror11
Archive Root URL: http://archive.debian.org/debian-archive/debian/
Archive Root URL: http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/
Distribution: stretch
Components: main, contrib, non-free
Architectures: amd64, arm64, armel, armhf, i386, mips, mips64el, mipsel, ppc64el, s390x
Expand Down
29 changes: 17 additions & 12 deletions system/t04_mirror/CreateMirror12Test_gold
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Error downloading http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease: HTTP code 404 while fetching http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease retrying...
Retrying 0 http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Giving up on http://archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release.gpg...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release.gpg
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Error downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease: HTTP code 404 while fetching http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease retrying...
Retrying 0 http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Giving up on http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/InRelease...
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release.gpg...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release.gpg

gpgv: RSA key ID B7D453EC
gpgv: Signature made Sat Aug 14 07:43:24 2021 UTC
gpgv: using RSA key 16E90B3FDF65EDE3AA7F323C04EE7237B7D453EC

gpgv: RSA key ID 22F3D138
gpgv: Signature made Sat Aug 14 07:43:25 2021 UTC
gpgv: using RSA key 0146DC6D4A0B2914BDED34DB648ACFD622F3D138

gpgv: RSA key ID 386FA1D9
gpgv: Signature made Sat Aug 14 08:46:19 2021 UTC
gpgv: using RSA key A7236886F3CCCAAD148A27F80E98404D386FA1D9

gpgv: RSA key ID 1A7B6500
gpgv: Signature made Sat Aug 14 08:26:43 2021 UTC
gpgv: using RSA key 067E3C456BAE240ACEE88F6FEF0F382A1A7B6500
gpgv: issuer "debian-release@lists.debian.org"

ERROR: unable to fetch mirror: verification of detached signature failed: exit status 2
6 changes: 3 additions & 3 deletions system/t04_mirror/CreateMirror13Test_gold
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release

Mirror [mirror13]: http://archive.debian.org/debian-archive/debian/ stretch successfully added.
Mirror [mirror13]: http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/ stretch successfully added.
You can run 'aptly mirror update mirror13' to download repository contents.
2 changes: 1 addition & 1 deletion system/t04_mirror/CreateMirror13Test_mirror_show
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mirror13
Archive Root URL: http://archive.debian.org/debian-archive/debian/
Archive Root URL: http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/
Distribution: stretch
Components: main, contrib, non-free
Architectures: amd64, arm64, armel, armhf, i386, mips, mips64el, mipsel, ppc64el, s390x
Expand Down
10 changes: 6 additions & 4 deletions system/t04_mirror/CreateMirror14Test_gold
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Downloading https://cloud.r-project.org/bin/linux/debian/bullseye-cran40/InRelease...
Success downloading https://cloud.r-project.org/bin/linux/debian/bullseye-cran40/InRelease
gpgv: RSA key ID 73EACF41
Downloading http://repo.aptly.info/system-tests/cloud.r-project.org/bin/linux/debian/bullseye-cran40/InRelease...
Success downloading http://repo.aptly.info/system-tests/cloud.r-project.org/bin/linux/debian/bullseye-cran40/InRelease
gpgv: can't allocate lock for '/home/runner/.gnupg/aptlytest.gpg'
gpgv: Signature made Thu Nov 2 07:43:52 2023 UTC
gpgv: using RSA key 7BA040A510E4E66ED3743EC1B8F25A8A73EACF41
gpgv: Good signature from "Johannes Ranke <johannes.ranke@jrwb.de>"

Mirror [mirror14]: https://cloud.r-project.org/bin/linux/debian/ ./bullseye-cran40/ successfully added.
Mirror [mirror14]: http://repo.aptly.info/system-tests/cloud.r-project.org/bin/linux/debian/ ./bullseye-cran40/ successfully added.
You can run 'aptly mirror update mirror14' to download repository contents.
2 changes: 1 addition & 1 deletion system/t04_mirror/CreateMirror14Test_mirror_show
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mirror14
Archive Root URL: https://cloud.r-project.org/bin/linux/debian/
Archive Root URL: http://repo.aptly.info/system-tests/cloud.r-project.org/bin/linux/debian/
Distribution: ./bullseye-cran40/
Components:
Architectures:
Expand Down
6 changes: 3 additions & 3 deletions system/t04_mirror/CreateMirror16Test_gold
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release
ERROR: unable to fetch mirror: architecture source not available in repo [mirror16]: http://archive.debian.org/debian-archive/debian/ stretch, use -force-architectures to override
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release
ERROR: unable to fetch mirror: architecture source not available in repo [mirror16]: http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/ stretch, use -force-architectures to override
6 changes: 3 additions & 3 deletions system/t04_mirror/CreateMirror17Test_gold
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://archive.debian.org/debian-archive/debian/dists/stretch/Release
Downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release...
Success downloading http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/dists/stretch/Release

Mirror [mirror17]: http://archive.debian.org/debian-archive/debian/ stretch [src] successfully added.
Mirror [mirror17]: http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/ stretch [src] successfully added.
You can run 'aptly mirror update mirror17' to download repository contents.
2 changes: 1 addition & 1 deletion system/t04_mirror/CreateMirror17Test_mirror_show
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mirror17
Archive Root URL: http://archive.debian.org/debian-archive/debian/
Archive Root URL: http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/
Distribution: stretch
Components: main, contrib, non-free
Architectures: i386
Expand Down
4 changes: 3 additions & 1 deletion system/t04_mirror/CreateMirror18Test_gold
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Downloading http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/dists/maverick/
Success downloading http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/dists/maverick/Release
Downloading http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/dists/maverick/Release.gpg...
Success downloading http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/dists/maverick/Release.gpg
gpgv: RSA key ID 3B1F56C0
gpgv: can't allocate lock for '/home/runner/.gnupg/aptlytest.gpg'
gpgv: Signature made Mon Oct 22 13:19:50 2012 UTC
gpgv: using RSA key A5279A973B1F56C0
gpgv: Good signature from "Launchpad sim"

Mirror [mirror18]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick successfully added.
Expand Down
Loading

0 comments on commit d7cc9b8

Please sign in to comment.