Tests for multi-component and aptly publish list/snapshot/repo, aptly serve. #36

This commit is contained in:
Andrey Smirnov
2014-06-06 02:09:13 +04:00
parent 2dae9b01a1
commit 1957c811e8
23 changed files with 428 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
Published repositories:
* ./maverick [amd64, i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}
* ppa/maverick [amd64, i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {contrib: [snap2]: Merged from sources: 'snap1'}
* ppa/smira/wheezy [amd64] publishes {contrib: [snap2]: Merged from sources: 'snap1'}
* ppa/tr1/maverick (origin: origin1) [amd64, i386] publishes {main: [snap2]: Merged from sources: 'snap1'}
* ppa/tr2/maverick (label: label1) [amd64, i386] publishes {main: [snap2]: Merged from sources: 'snap1'}
+13
View File
@@ -0,0 +1,13 @@
Loading packages...
Generating metadata files and linking package files...
Signing file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted:
Clearsigning file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted:
Local repos repo1, repo2 have been successfully published.
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
Now you can add following line to apt sources:
deb http://your-server/ maverick contrib main
deb-src http://your-server/ maverick contrib main
Don't forget to add your GPG key to apt with apt-key.
You can also use `aptly serve` to publish your repositories over HTTP quickly.
@@ -0,0 +1,9 @@
Origin: . maverick
Label: . maverick
Codename: maverick
Architectures: i386 source
Components: contrib main
Description: Generated by aptly
MD5Sum:
SHA1:
SHA256:
+13
View File
@@ -0,0 +1,13 @@
Loading packages...
Generating metadata files and linking package files...
Signing file '${HOME}/.aptly/public/dists/squeeze/Release' with gpg, please enter your passphrase when prompted:
Clearsigning file '${HOME}/.aptly/public/dists/squeeze/Release' with gpg, please enter your passphrase when prompted:
Local repos repo1, repo2 have been successfully published.
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
Now you can add following line to apt sources:
deb http://your-server/ squeeze contrib main
deb-src http://your-server/ squeeze contrib main
Don't forget to add your GPG key to apt with apt-key.
You can also use `aptly serve` to publish your repositories over HTTP quickly.
@@ -0,0 +1 @@
ERROR: unable to publish: duplicate component name: contrib
@@ -0,0 +1,2 @@
Warning: publishing from empty source, architectures list should be complete, it can't be changed after publishing (use -architectures flag)
ERROR: unable to publish: duplicate component name: b
@@ -0,0 +1,2 @@
Warning: publishing from empty source, architectures list should be complete, it can't be changed after publishing (use -architectures flag)
ERROR: unable to publish: unable to guess distribution name, please specify explicitly
@@ -0,0 +1 @@
ERROR: unable to publish: local repo with name repo2 not found
@@ -0,0 +1 @@
ERROR: unable to parse command
@@ -0,0 +1,13 @@
Loading packages...
Generating metadata files and linking package files...
Signing file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted:
Clearsigning file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted:
Snapshots snap26.1, snap26.2 have been successfully published.
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
Now you can add following line to apt sources:
deb http://your-server/ maverick contrib main
deb-src http://your-server/ maverick contrib main
Don't forget to add your GPG key to apt with apt-key.
You can also use `aptly serve` to publish your repositories over HTTP quickly.
@@ -0,0 +1,9 @@
Origin: . maverick
Label: . maverick
Codename: maverick
Architectures: amd64 i386 i386
Components: contrib main
Description: Generated by aptly
MD5Sum:
SHA1:
SHA256:
@@ -0,0 +1,13 @@
Loading packages...
Generating metadata files and linking package files...
Signing file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted:
Clearsigning file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted:
Snapshots snap27.1, snap27.2 have been successfully published.
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
Now you can add following line to apt sources:
deb http://your-server/ maverick contrib main
deb-src http://your-server/ maverick contrib main
Don't forget to add your GPG key to apt with apt-key.
You can also use `aptly serve` to publish your repositories over HTTP quickly.
@@ -0,0 +1 @@
ERROR: unable to publish: duplicate component name: main
@@ -0,0 +1,2 @@
Warning: publishing from empty source, architectures list should be complete, it can't be changed after publishing (use -architectures flag)
ERROR: unable to publish: duplicate component name: b
@@ -0,0 +1 @@
ERROR: unable to publish: unable to guess distribution name, please specify explicitly
@@ -0,0 +1 @@
ERROR: unable to publish: snapshot with name snap31.2 not found
@@ -0,0 +1 @@
ERROR: unable to parse command
+1
View File
@@ -21,6 +21,7 @@ class PublishList2Test(BaseTest):
"aptly -architectures=amd64 publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=contrib snap2 ppa/smira",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -origin=origin1 snap2 ppa/tr1",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -label=label1 snap2 ppa/tr2",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=main,contrib snap1 snap2 ppa",
]
runCmd = "aptly publish list"
+163
View File
@@ -382,3 +382,166 @@ class PublishRepo16Test(BaseTest):
self.check_exists('public/dists/maverick/main/source/Sources')
self.check_exists('public/dists/maverick/main/source/Sources.gz')
self.check_exists('public/dists/maverick/main/source/Sources.bz2')
class PublishRepo17Test(BaseTest):
"""
publish repo: multiple component
"""
fixtureCmds = [
"aptly repo create repo1",
"aptly repo create repo2",
"aptly repo add repo1 ${files}/libboost-program-options-dev_1.49.0.1_i386.deb ${files}/pyspi_0.6.1-1.3.dsc",
"aptly repo add repo2 ${files}/pyspi-0.6.1-1.3.stripped.dsc",
]
runCmd = "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=main,contrib -distribution=maverick repo1 repo2"
gold_processor = BaseTest.expand_environ
def check(self):
super(PublishRepo17Test, self).check()
self.check_exists('public/dists/maverick/InRelease')
self.check_exists('public/dists/maverick/Release')
self.check_exists('public/dists/maverick/Release.gpg')
self.check_exists('public/dists/maverick/main/binary-i386/Packages')
self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz')
self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2')
self.check_exists('public/dists/maverick/main/source/Sources')
self.check_exists('public/dists/maverick/main/source/Sources.gz')
self.check_exists('public/dists/maverick/main/source/Sources.bz2')
self.check_exists('public/dists/maverick/contrib/binary-i386/Packages')
self.check_exists('public/dists/maverick/contrib/binary-i386/Packages.gz')
self.check_exists('public/dists/maverick/contrib/binary-i386/Packages.bz2')
self.check_exists('public/dists/maverick/contrib/source/Sources')
self.check_exists('public/dists/maverick/contrib/source/Sources.gz')
self.check_exists('public/dists/maverick/contrib/source/Sources.bz2')
self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.dsc')
self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.diff.gz')
self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz')
self.check_exists('public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1-1.3.diff.gz')
self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1.orig.tar.gz')
self.check_exists('public/pool/contrib/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc')
# verify contents except of sums
self.check_file_contents('public/dists/maverick/Release', 'release', match_prepare=strip_processor)
# verify signatures
self.run_cmd(["gpg", "--no-auto-check-trustdb", "--keyring", os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "aptly.pub"),
"--verify", os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/InRelease')])
self.run_cmd(["gpg", "--no-auto-check-trustdb", "--keyring", os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "aptly.pub"),
"--verify", os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/Release.gpg'),
os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/Release')])
# verify sums
release = self.read_file('public/dists/maverick/Release').split("\n")
release = [l for l in release if l.startswith(" ")]
pathsSeen = set()
for l in release:
fileHash, fileSize, path = l.split()
pathsSeen.add(path)
fileSize = int(fileSize)
st = os.stat(os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/', path))
if fileSize != st.st_size:
raise Exception("file size doesn't match for %s: %d != %d" % (path, fileSize, st.st_size))
if len(fileHash) == 32:
h = hashlib.md5()
elif len(fileHash) == 40:
h = hashlib.sha1()
else:
h = hashlib.sha256()
h.update(self.read_file(os.path.join('public/dists/maverick', path)))
if h.hexdigest() != fileHash:
raise Exception("file hash doesn't match for %s: %s != %s" % (path, fileHash, h.hexdigest()))
if pathsSeen != set(['main/binary-i386/Packages', 'main/binary-i386/Packages.gz',
'main/binary-i386/Packages.bz2',
'main/source/Sources', 'main/source/Sources.gz', 'main/source/Sources.bz2',
'contrib/binary-i386/Packages', 'contrib/binary-i386/Packages.gz',
'contrib/binary-i386/Packages.bz2',
'contrib/source/Sources', 'contrib/source/Sources.gz', 'contrib/source/Sources.bz2']):
raise Exception("path seen wrong: %r" % (pathsSeen, ))
class PublishRepo18Test(BaseTest):
"""
publish repo: multiple component, guessing component names
"""
fixtureCmds = [
"aptly repo create -distribution=squeeze -component=main repo1",
"aptly repo create -distribution=squeeze -component=contrib repo2",
"aptly repo add repo1 ${files}/libboost-program-options-dev_1.49.0.1_i386.deb ${files}/pyspi_0.6.1-1.3.dsc",
"aptly repo add repo2 ${files}/pyspi-0.6.1-1.3.stripped.dsc",
]
runCmd = "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=, repo1 repo2"
gold_processor = BaseTest.expand_environ
class PublishRepo19Test(BaseTest):
"""
publish repo: duplicate component name (guessed)
"""
fixtureCmds = [
"aptly repo create -distribution=squeeze -component=contrib repo1",
"aptly repo create -distribution=squeeze -component=contrib repo2",
"aptly repo add repo1 ${files}/libboost-program-options-dev_1.49.0.1_i386.deb ${files}/pyspi_0.6.1-1.3.dsc",
"aptly repo add repo2 ${files}/pyspi-0.6.1-1.3.stripped.dsc",
]
runCmd = "aptly publish repo -component=, repo1 repo2"
expectedCode = 1
class PublishRepo20Test(BaseTest):
"""
publish repo: duplicate component name (manual)
"""
fixtureCmds = [
"aptly repo create -distribution=squeeze -component=main repo1",
"aptly repo create -distribution=squeeze -component=contrib repo2",
]
runCmd = "aptly publish repo -component=b,b repo1 repo2"
expectedCode = 1
class PublishRepo21Test(BaseTest):
"""
publish repo: distribution conflict
"""
fixtureCmds = [
"aptly repo create -distribution=squeeze -component=main repo1",
"aptly repo create -distribution=wheezy -component=contrib repo2",
]
runCmd = "aptly publish repo -component=, repo1 repo2"
expectedCode = 1
class PublishRepo22Test(BaseTest):
"""
publish reop: no such repo
"""
fixtureCmds = [
"aptly repo create -distribution=squeeze -component=main repo1",
]
runCmd = "aptly publish repo -component=, repo1 repo2"
expectedCode = 1
class PublishRepo23Test(BaseTest):
"""
publish repo: mismatch in count
"""
fixtureCmds = [
"aptly repo create -distribution=squeeze -component=main repo1",
]
runCmd = "aptly publish repo -component=main,contrib repo1"
expectedCode = 2
outputMatchPrepare = lambda _, s: "\n".join([l for l in s.split("\n") if l.startswith("ERROR")])
+175
View File
@@ -601,3 +601,178 @@ class PublishSnapshot25Test(BaseTest):
self.check_exists('public/dists/maverick/main/binary-amd64/Packages')
self.check_exists('public/dists/maverick/main/binary-amd64/Packages.gz')
self.check_exists('public/dists/maverick/main/binary-amd64/Packages.bz2')
class PublishSnapshot26Test(BaseTest):
"""
publish snapshot: multiple component
"""
fixtureDB = True
fixturePool = True
fixtureCmds = [
"aptly snapshot create snap26.1 from mirror gnuplot-maverick",
"aptly repo create local-repo",
"aptly repo add local-repo ${files}",
"aptly snapshot create snap26.2 from repo local-repo",
]
runCmd = "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=main,contrib snap26.1 snap26.2"
gold_processor = BaseTest.expand_environ
def check(self):
super(PublishSnapshot26Test, self).check()
self.check_exists('public/dists/maverick/InRelease')
self.check_exists('public/dists/maverick/Release')
self.check_exists('public/dists/maverick/Release.gpg')
self.check_exists('public/dists/maverick/main/binary-i386/Packages')
self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz')
self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2')
self.check_exists('public/dists/maverick/main/binary-amd64/Packages')
self.check_exists('public/dists/maverick/main/binary-amd64/Packages.gz')
self.check_exists('public/dists/maverick/main/binary-amd64/Packages.bz2')
self.check_exists('public/dists/maverick/main/source/Sources')
self.check_exists('public/dists/maverick/main/source/Sources.gz')
self.check_exists('public/dists/maverick/main/source/Sources.bz2')
self.check_exists('public/dists/maverick/contrib/binary-i386/Packages')
self.check_exists('public/dists/maverick/contrib/binary-i386/Packages.gz')
self.check_exists('public/dists/maverick/contrib/binary-i386/Packages.bz2')
self.check_exists('public/dists/maverick/contrib/binary-amd64/Packages')
self.check_exists('public/dists/maverick/contrib/binary-amd64/Packages.gz')
self.check_exists('public/dists/maverick/contrib/binary-amd64/Packages.bz2')
self.check_exists('public/dists/maverick/contrib/source/Sources')
self.check_exists('public/dists/maverick/contrib/source/Sources.gz')
self.check_exists('public/dists/maverick/contrib/source/Sources.bz2')
self.check_exists('public/pool/main/g/gnuplot/gnuplot-doc_4.6.1-1~maverick2_all.deb')
self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1-1.3.dsc')
self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1-1.3.diff.gz')
self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1.orig.tar.gz')
self.check_exists('public/pool/contrib/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc')
self.check_exists('public/pool/contrib/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb')
# verify contents except of sums
self.check_file_contents('public/dists/maverick/Release', 'release', match_prepare=strip_processor)
# verify signatures
self.run_cmd(["gpg", "--no-auto-check-trustdb", "--keyring", os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "aptly.pub"),
"--verify", os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/InRelease')])
self.run_cmd(["gpg", "--no-auto-check-trustdb", "--keyring", os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "aptly.pub"),
"--verify", os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/Release.gpg'),
os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/Release')])
# verify sums
release = self.read_file('public/dists/maverick/Release').split("\n")
release = [l for l in release if l.startswith(" ")]
pathsSeen = set()
for l in release:
fileHash, fileSize, path = l.split()
pathsSeen.add(path)
fileSize = int(fileSize)
st = os.stat(os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/', path))
if fileSize != st.st_size:
raise Exception("file size doesn't match for %s: %d != %d" % (path, fileSize, st.st_size))
if len(fileHash) == 32:
h = hashlib.md5()
elif len(fileHash) == 40:
h = hashlib.sha1()
else:
h = hashlib.sha256()
h.update(self.read_file(os.path.join('public/dists/maverick', path)))
if h.hexdigest() != fileHash:
raise Exception("file hash doesn't match for %s: %s != %s" % (path, fileHash, h.hexdigest()))
if pathsSeen != set(['main/binary-amd64/Packages', 'main/binary-i386/Packages', 'main/binary-i386/Packages.gz',
'main/binary-amd64/Packages.gz', 'main/binary-amd64/Packages.bz2', 'main/binary-i386/Packages.bz2',
'main/source/Sources', 'main/source/Sources.gz', 'main/source/Sources.bz2',
'contrib/binary-amd64/Packages', 'contrib/binary-i386/Packages', 'contrib/binary-i386/Packages.gz',
'contrib/binary-amd64/Packages.gz', 'contrib/binary-amd64/Packages.bz2', 'contrib/binary-i386/Packages.bz2',
'contrib/source/Sources', 'contrib/source/Sources.gz', 'contrib/source/Sources.bz2',]):
raise Exception("path seen wrong: %r" % (pathsSeen, ))
class PublishSnapshot27Test(BaseTest):
"""
publish snapshot: multiple component, guessing component names
"""
fixtureDB = True
fixturePool = True
fixtureCmds = [
"aptly snapshot create snap27.1 from mirror gnuplot-maverick",
"aptly repo create -component=contrib local-repo",
"aptly repo add local-repo ${files}",
"aptly snapshot create snap27.2 from repo local-repo",
]
runCmd = "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=, snap27.1 snap27.2"
gold_processor = BaseTest.expand_environ
class PublishSnapshot28Test(BaseTest):
"""
publish snapshot: duplicate component name (guessed)
"""
fixtureDB = True
fixtureCmds = [
"aptly snapshot create snap28.1 from mirror gnuplot-maverick",
"aptly repo create local-repo",
"aptly repo add local-repo ${files}",
"aptly snapshot create snap28.2 from repo local-repo",
]
runCmd = "aptly publish snapshot -component=, snap28.1 snap28.2"
expectedCode = 1
class PublishSnapshot29Test(BaseTest):
"""
publish snapshot: duplicate component name (manual)
"""
fixtureCmds = [
"aptly snapshot create snap29.1 empty",
"aptly snapshot create snap29.2 empty",
]
runCmd = "aptly publish snapshot -component=b,b snap29.1 snap29.2"
expectedCode = 1
class PublishSnapshot30Test(BaseTest):
"""
publish snapshot: distribution conflict
"""
fixtureDB = True
fixtureCmds = [
"aptly snapshot create snap30.1 from mirror gnuplot-maverick",
"aptly repo create -distribution=squeeze local-repo",
"aptly repo add local-repo ${files}",
"aptly snapshot create snap30.2 from repo local-repo",
]
runCmd = "aptly publish snapshot -component=main,contrib snap30.1 snap30.2"
expectedCode = 1
class PublishSnapshot31Test(BaseTest):
"""
publish snapshot: no such snapshot
"""
fixtureCmds = [
"aptly snapshot create snap31.1 empty",
]
runCmd = "aptly publish snapshot -component=main,contrib snap31.1 snap31.2"
expectedCode = 1
class PublishSnapshot32Test(BaseTest):
"""
publish snapshot: mismatch in count
"""
fixtureCmds = [
"aptly snapshot create snap32.1 empty",
]
runCmd = "aptly publish snapshot -component=main,contrib snap32.1"
expectedCode = 2
outputMatchPrepare = lambda _, s: "\n".join([l for l in s.split("\n") if l.startswith("ERROR")])
+3
View File
@@ -5,5 +5,8 @@ deb http://127.0.0.1:8765/ maverick main
# debian/maverick [amd64, i386, source] publishes {main: [snap2]: Snapshot from mirror [gnuplot-maverick-src]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick [src]}
deb http://127.0.0.1:8765/debian/ maverick main
deb-src http://127.0.0.1:8765/debian/ maverick main
# multi/maverick [amd64, i386, source] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {contrib: [snap2]: Snapshot from mirror [gnuplot-maverick-src]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick [src]}
deb http://127.0.0.1:8765/multi/ maverick contrib main
deb-src http://127.0.0.1:8765/multi/ maverick contrib main
Starting web server at: 127.0.0.1:8765 (press Ctrl+C to quit)...
+1
View File
@@ -1,5 +1,6 @@
<pre>
<a href="debian/">debian/</a>
<a href="dists/">dists/</a>
<a href="multi/">multi/</a>
<a href="pool/">pool/</a>
</pre>
+1
View File
@@ -23,6 +23,7 @@ class Serve1Test(BaseTest):
"aptly snapshot create snap2 from mirror gnuplot-maverick-src",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap1",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap2 debian",
"aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=main,contrib snap1 snap2 multi",
]
runCmd = "aptly serve -listen=127.0.0.1:8765"