aptly serve command: handle publishing of repositories, with system test.

This commit is contained in:
Andrey Smirnov
2014-01-30 13:10:19 +04:00
parent 0271456ca4
commit 043ed13c18
6 changed files with 185 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
Serving published repositories, recommended apt sources list:
# ./maverick (main) [amd64, i386] publishes [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick
deb http://127.0.0.1:8765/ maverick main
# debian/maverick (main) [amd64, i386] publishes [snap2]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick
deb http://127.0.0.1:8765/debian/ maverick main
Starting web server at: 127.0.0.1:8765 (press Ctrl+C to quit)...

View File

@@ -0,0 +1,5 @@
<pre>
<a href="debian/">debian/</a>
<a href="dists/">dists/</a>
<a href="pool/">pool/</a>
</pre>

View File

@@ -0,0 +1 @@
No published repositories, unable to serve.

View File

@@ -0,0 +1,64 @@
"""
Testing serving public repo
"""
import httplib
import os
import signal
import subprocess
import shlex
import time
from lib import BaseTest
class VerifySnapshot1Test(BaseTest):
"""
serve public: two publishes, verify HTTP
"""
fixtureDB = True
fixturePool = True
fixtureCmds = [
"aptly snapshot create snap1 from mirror gnuplot-maverick",
"aptly snapshot create snap2 from mirror gnuplot-maverick",
"aptly publish snapshot snap1",
"aptly publish snapshot snap2 debian",
]
runCmd = "aptly serve -listen=127.0.0.1:8765"
def run(self):
try:
proc = subprocess.Popen(shlex.split(self.runCmd), stderr=subprocess.STDOUT, stdout=subprocess.PIPE, bufsize=0)
try:
time.sleep(1)
conn = httplib.HTTPConnection("127.0.0.1", 8765)
conn.request("GET", "/")
r = conn.getresponse()
if r.status != 200:
raise Exception("Expected status 200 != %d" % r.status)
self.http_response = r.read()
output = os.read(proc.stdout.fileno(), 8192)
finally:
proc.send_signal(signal.SIGINT)
proc.wait()
if proc.returncode != 2:
raise Exception("exit code %d != %d (output: %s)" % (proc.returncode, 2, output))
self.output = output
except Exception, e:
raise Exception("Running command %s failed: %s" % (self.runCmd, str(e)))
def check(self):
self.check_output()
self.verify_match(self.get_gold('http'), self.http_response)
class VerifySnapshot2Test(BaseTest):
"""
serve public: no publishes
"""
runCmd = "aptly serve -listen=127.0.0.1:8765"