tests: cover mirror update -max-versions in system and unit tests

This commit is contained in:
Rascalov authored and André Roth committed 2026-11-05 11:22:28 +01:00
1 parent 0609ac257a
commit 300837fe06
8 files changed
+230

No files matched your search

+11
View File
@@ -457,6 +457,17 @@ func (s *RemoteRepoSuite) TestFilterLatest(c *C) {
c.Check(size, Equals, int64(187518))
}
func (s *RemoteRepoSuite) TestFilterLatestErrors(c *C) {
_, _, err := s.repo.FilterLatest(1)
c.Assert(err, ErrorMatches, "package list is empty, please \\(re\\)download package indexes")
s.repo.packageList = NewPackageList()
oldLen, newLen, err := s.repo.FilterLatest(0)
c.Assert(err, ErrorMatches, "number of latest versions should be at least 1, got 0")
c.Check(oldLen, Equals, 0)
c.Check(newLen, Equals, 0)
}
func (s *RemoteRepoSuite) TestDownloadWithSources(c *C) {
s.repo.Architectures = []string{"i386"}
s.repo.DownloadSources = true
+32
View File
@@ -0,0 +1,32 @@
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/dists/wheezy/Release
Downloading & parsing package files...
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/dists/wheezy/main/binary-i386/Packages.bz2
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/dists/wheezy/main/binary-amd64/Packages.bz2
Keeping at most 2 versions of each package: 52 -> 23.
Building download queue...
Download queue: 23 items (8.41 MiB)
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.6-1%29/varnish_3.0.6-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish-agent%20%282.2.1%29/varnish-agent_2.2.1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish-agent%20%283.0.0%29/varnish-agent_3.0.0~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish-dbg_3.0.7-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.6-1%29/libvarnishapi1_3.0.6-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.7-1%29/libvarnishapi-dev_3.0.7-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.7-1%29/libvarnishapi1_3.0.7-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.6-1%29/libvarnishapi1_3.0.6-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish_3.0.7-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish-agent%20%282.2.0%29/varnish-agent_2.2.0~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.7-1%29/libvarnishapi-dev_3.0.7-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish_3.0.7-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.6-1%29/varnish_3.0.6-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.6-1%29/libvarnishapi-dev_3.0.6-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish-agent%20%283.0.1%29/varnish-agent_3.0.1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.6-1%29/varnish-dbg_3.0.6-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.6-1%29/libvarnishapi-dev_3.0.6-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish-dbg_3.0.7-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish-doc_3.0.7-1~wheezy_all.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.6-1%29/varnish-doc_3.0.6-1~wheezy_all.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.7-1%29/libvarnishapi1_3.0.7-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish-agent%20%281.16.0%29/varnish-agent_1.16.0~wheezy_all.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.6-1%29/varnish-dbg_3.0.6-1~wheezy_i386.deb
Mirror `varnish` has been updated successfully.
@@ -0,0 +1,45 @@
Name: varnish
Archive Root URL: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/
Distribution: wheezy
Components: main
Architectures: i386, amd64
Download Sources: no
Download .udebs: no
Download AppStream: no
Number of packages: 23
Information from release file:
Acquire-By-Hash: yes
Architectures: amd64 armel armhf i386 ia64 mips mipsel powerpc ppc64el s390 s390x sparc alpha avr32 hppa m32 m68k sh arm64
Codename: wheezy
Components: main
Date: Tue, 22 Jan 2019 00:28:39 +0000
Description:
Label: varnish30
Origin: packagecloud.io/varnishcache/varnish30
Suite: wheezy
Version: 1
Packages:
libvarnishapi-dev_3.0.7-1~wheezy_amd64
libvarnishapi-dev_3.0.7-1~wheezy_i386
libvarnishapi-dev_3.0.6-1~wheezy_amd64
libvarnishapi-dev_3.0.6-1~wheezy_i386
libvarnishapi1_3.0.7-1~wheezy_amd64
libvarnishapi1_3.0.7-1~wheezy_i386
libvarnishapi1_3.0.6-1~wheezy_amd64
libvarnishapi1_3.0.6-1~wheezy_i386
varnish_3.0.7-1~wheezy_amd64
varnish_3.0.7-1~wheezy_i386
varnish_3.0.6-1~wheezy_amd64
varnish_3.0.6-1~wheezy_i386
varnish-agent_3.0.1~wheezy_amd64
varnish-agent_3.0.0~wheezy_amd64
varnish-agent_2.2.1~wheezy_i386
varnish-agent_2.2.0~wheezy_i386
varnish-agent_1.16.0~wheezy_all
varnish-dbg_3.0.7-1~wheezy_amd64
varnish-dbg_3.0.7-1~wheezy_i386
varnish-dbg_3.0.6-1~wheezy_amd64
varnish-dbg_3.0.6-1~wheezy_i386
varnish-doc_3.0.7-1~wheezy_all
varnish-doc_3.0.6-1~wheezy_all
+21
View File
@@ -0,0 +1,21 @@
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/dists/wheezy/Release
Downloading & parsing package files...
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/dists/wheezy/main/binary-i386/Packages.bz2
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/dists/wheezy/main/binary-amd64/Packages.bz2
Keeping at most 1 version of each package: 52 -> 12.
Building download queue...
Download queue: 12 items (4.19 MiB)
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish-dbg_3.0.7-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.7-1%29/libvarnishapi1_3.0.7-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish-agent%20%281.16.0%29/varnish-agent_1.16.0~wheezy_all.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish-agent%20%283.0.1%29/varnish-agent_3.0.1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish_3.0.7-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish-dbg_3.0.7-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish_3.0.7-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.7-1%29/libvarnishapi-dev_3.0.7-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.7-1%29/libvarnishapi1_3.0.7-1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/libv/varnish%20%283.0.7-1%29/libvarnishapi-dev_3.0.7-1~wheezy_amd64.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish-agent%20%282.2.1%29/varnish-agent_2.2.1~wheezy_i386.deb
Downloading: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/pool/wheezy/main/v/varnish%20%283.0.7-1%29/varnish-doc_3.0.7-1~wheezy_all.deb
Mirror `varnish` has been updated successfully.
@@ -0,0 +1,34 @@
Name: varnish
Archive Root URL: http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/
Distribution: wheezy
Components: main
Architectures: i386, amd64
Download Sources: no
Download .udebs: no
Download AppStream: no
Number of packages: 12
Information from release file:
Acquire-By-Hash: yes
Architectures: amd64 armel armhf i386 ia64 mips mipsel powerpc ppc64el s390 s390x sparc alpha avr32 hppa m32 m68k sh arm64
Codename: wheezy
Components: main
Date: Tue, 22 Jan 2019 00:28:39 +0000
Description:
Label: varnish30
Origin: packagecloud.io/varnishcache/varnish30
Suite: wheezy
Version: 1
Packages:
libvarnishapi-dev_3.0.7-1~wheezy_amd64
libvarnishapi-dev_3.0.7-1~wheezy_i386
libvarnishapi1_3.0.7-1~wheezy_amd64
libvarnishapi1_3.0.7-1~wheezy_i386
varnish_3.0.7-1~wheezy_amd64
varnish_3.0.7-1~wheezy_i386
varnish-agent_3.0.1~wheezy_amd64
varnish-agent_2.2.1~wheezy_i386
varnish-agent_1.16.0~wheezy_all
varnish-dbg_3.0.7-1~wheezy_amd64
varnish-dbg_3.0.7-1~wheezy_i386
varnish-doc_3.0.7-1~wheezy_all
@@ -0,0 +1 @@
ERROR: unable to update: -max-versions should be a positive number
+42
View File
@@ -502,3 +502,45 @@ class UpdateMirror28Test(BaseTest):
self.check_output()
self.check_cmd_output("aptly mirror show appstream-test", "mirror_show",
match_prepare=lambda s: re.sub(r"Last update: [0-9:+A-Za-z -]+\n", "", s))
class UpdateMirror29Test(BaseTest):
"""
update mirrors: keep only the 2 most recent versions of each package
"""
sortOutput = True
fixtureCmds = [
"aptly -architectures=i386,amd64 mirror create --ignore-signatures varnish http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/ wheezy main",
]
runCmd = "aptly mirror update --ignore-signatures -max-versions=2 varnish"
outputMatchPrepare = filterOutRedirects
def check(self):
self.check_output()
self.check_cmd_output("aptly mirror show -with-packages varnish", "mirror_show",
match_prepare=lambda s: re.sub(r"Last update: [0-9:+A-Za-z -]+\n", "", s))
class UpdateMirror30Test(BaseTest):
"""
update mirrors: -latest keeps only the most recent version of each package
"""
sortOutput = True
fixtureCmds = [
"aptly -architectures=i386,amd64 mirror create --ignore-signatures varnish http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/ wheezy main",
]
runCmd = "aptly mirror update --ignore-signatures -latest varnish"
outputMatchPrepare = filterOutRedirects
def check(self):
self.check_output()
self.check_cmd_output("aptly mirror show -with-packages varnish", "mirror_show",
match_prepare=lambda s: re.sub(r"Last update: [0-9:+A-Za-z -]+\n", "", s))
class UpdateMirror31Test(BaseTest):
"""
update mirrors: negative -max-versions
"""
runCmd = "aptly mirror update -max-versions=-1 varnish"
expectedCode = 1
+44
View File
@@ -372,3 +372,47 @@ class MirrorsAPITestEditFlatMirrorUdebs(APITest):
resp = self.post("/api/mirrors/" + mirror_name, json=edit_params)
self.check_equal(resp.status_code, 400)
self.check_in("flat mirrors don't support udebs", resp.json()['error'])
class MirrorsAPITestUpdateMaxVersions(APITest):
"""
PUT /api/mirrors/:name with MaxVersions and LatestOnly
"""
def check(self):
mirror_name = self.random_name()
mirror_desc = {'Name': mirror_name,
'ArchiveURL': 'http://repo.aptly.info/system-tests/packagecloud.io/varnishcache/varnish30/debian/',
'Distribution': 'wheezy',
'Architectures': ["amd64"],
'Components': ['main'],
'IgnoreSignatures': True}
resp = self.post("/api/mirrors", json=mirror_desc)
self.check_equal(resp.status_code, 201)
def versions_per_package():
resp = self.get("/api/mirrors/" + mirror_name + "/packages")
self.check_equal(resp.status_code, 200)
versions = {}
for key in resp.json():
arch, name, version = key.split(" ")[:3]
versions.setdefault((arch, name), []).append(version)
return versions
resp = self.put("/api/mirrors/" + mirror_name, json={'IgnoreSignatures': True, 'MaxVersions': -1})
self.check_equal(resp.status_code, 400)
self.check_in("MaxVersions should be a positive number", resp.json()['error'])
resp = self.put_task("/api/mirrors/" + mirror_name, json={'IgnoreSignatures': True, 'MaxVersions': 2})
self.check_task(resp)
versions = versions_per_package()
self.check_equal(sorted(versions[("Pamd64", "varnish")]), ["3.0.6-1~wheezy", "3.0.7-1~wheezy"])
self.check_equal(max(len(v) for v in versions.values()), 2)
resp = self.put_task("/api/mirrors/" + mirror_name, json={'IgnoreSignatures': True, 'LatestOnly': True})
self.check_task(resp)
versions = versions_per_package()
self.check_equal(versions[("Pamd64", "varnish")], ["3.0.7-1~wheezy"])
self.check_equal(max(len(v) for v in versions.values()), 1)