mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
reenable lost tests
This commit is contained in:
@@ -1,14 +1,3 @@
|
||||
"""
|
||||
Test aptly version
|
||||
"""
|
||||
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class VersionTest(BaseTest):
|
||||
"""
|
||||
version should match
|
||||
"""
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
runCmd = "aptly version"
|
||||
|
||||
14
system/t01_version/version.py
Normal file
14
system/t01_version/version.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""
|
||||
Test aptly version
|
||||
"""
|
||||
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class VersionTest(BaseTest):
|
||||
"""
|
||||
version should match
|
||||
"""
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
runCmd = "aptly version"
|
||||
@@ -1,66 +1,3 @@
|
||||
"""
|
||||
Test config file
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import inspect
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class CreateConfigTest(BaseTest):
|
||||
"""
|
||||
new file is generated if missing
|
||||
"""
|
||||
runCmd = "aptly mirror list"
|
||||
checkedFile = os.path.join(os.environ["HOME"], ".aptly.conf")
|
||||
|
||||
check = BaseTest.check_file
|
||||
gold_processor = BaseTest.expand_environ
|
||||
prepare = BaseTest.prepare_remove_all
|
||||
|
||||
|
||||
class BadConfigTest(BaseTest):
|
||||
"""
|
||||
broken config file
|
||||
"""
|
||||
runCmd = "aptly mirror list"
|
||||
expectedCode = 1
|
||||
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def prepare(self):
|
||||
self.prepare_remove_all()
|
||||
|
||||
f = open(os.path.join(os.environ["HOME"], ".aptly.conf"), "w")
|
||||
f.write("{some crap")
|
||||
f.close()
|
||||
|
||||
|
||||
class ConfigInFileTest(BaseTest):
|
||||
"""
|
||||
config in other file test
|
||||
"""
|
||||
runCmd = ["aptly", "mirror", "list",
|
||||
"-config=%s" % (os.path.join(os.path.dirname(inspect.getsourcefile(BadConfigTest)), "aptly.conf"), )]
|
||||
prepare = BaseTest.prepare_remove_all
|
||||
|
||||
def outputMatchPrepare(_, s):
|
||||
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
|
||||
|
||||
|
||||
class ConfigInMissingFileTest(BaseTest):
|
||||
"""
|
||||
config in other file test
|
||||
"""
|
||||
runCmd = ["aptly", "mirror", "list", "-config=nosuchfile.conf"]
|
||||
expectedCode = 1
|
||||
prepare = BaseTest.prepare_remove_all
|
||||
|
||||
|
||||
class ConfigShowTest(BaseTest):
|
||||
"""
|
||||
config showing
|
||||
"""
|
||||
runCmd = ["aptly", "config", "show"]
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
66
system/t02_config/config.py
Normal file
66
system/t02_config/config.py
Normal file
@@ -0,0 +1,66 @@
|
||||
"""
|
||||
Test config file
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import inspect
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class CreateConfigTest(BaseTest):
|
||||
"""
|
||||
new file is generated if missing
|
||||
"""
|
||||
runCmd = "aptly mirror list"
|
||||
checkedFile = os.path.join(os.environ["HOME"], ".aptly.conf")
|
||||
|
||||
check = BaseTest.check_file
|
||||
gold_processor = BaseTest.expand_environ
|
||||
prepare = BaseTest.prepare_remove_all
|
||||
|
||||
|
||||
class BadConfigTest(BaseTest):
|
||||
"""
|
||||
broken config file
|
||||
"""
|
||||
runCmd = "aptly mirror list"
|
||||
expectedCode = 1
|
||||
|
||||
gold_processor = BaseTest.expand_environ
|
||||
|
||||
def prepare(self):
|
||||
self.prepare_remove_all()
|
||||
|
||||
f = open(os.path.join(os.environ["HOME"], ".aptly.conf"), "w")
|
||||
f.write("{some crap")
|
||||
f.close()
|
||||
|
||||
|
||||
class ConfigInFileTest(BaseTest):
|
||||
"""
|
||||
config in other file test
|
||||
"""
|
||||
runCmd = ["aptly", "mirror", "list",
|
||||
"-config=%s" % (os.path.join(os.path.dirname(inspect.getsourcefile(BadConfigTest)), "aptly.conf"), )]
|
||||
prepare = BaseTest.prepare_remove_all
|
||||
|
||||
def outputMatchPrepare(_, s):
|
||||
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
|
||||
|
||||
|
||||
class ConfigInMissingFileTest(BaseTest):
|
||||
"""
|
||||
config in other file test
|
||||
"""
|
||||
runCmd = ["aptly", "mirror", "list", "-config=nosuchfile.conf"]
|
||||
expectedCode = 1
|
||||
prepare = BaseTest.prepare_remove_all
|
||||
|
||||
|
||||
class ConfigShowTest(BaseTest):
|
||||
"""
|
||||
config showing
|
||||
"""
|
||||
runCmd = ["aptly", "config", "show"]
|
||||
gold_processor = BaseTest.expand_environ
|
||||
@@ -1,65 +1,3 @@
|
||||
"""
|
||||
Test help screens
|
||||
"""
|
||||
|
||||
import re
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class MainTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
expectedCode = 2
|
||||
runCmd = "aptly"
|
||||
|
||||
def outputMatchPrepare(_, s):
|
||||
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
|
||||
|
||||
|
||||
class MirrorTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
expectedCode = 2
|
||||
runCmd = "aptly mirror"
|
||||
|
||||
|
||||
class MirrorCreateTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
expectedCode = 2
|
||||
runCmd = "aptly mirror create"
|
||||
|
||||
|
||||
class MainHelpTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
runCmd = "aptly help"
|
||||
|
||||
def outputMatchPrepare(_, s):
|
||||
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
|
||||
|
||||
|
||||
class MirrorHelpTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
runCmd = "aptly help mirror"
|
||||
|
||||
|
||||
class MirrorCreateHelpTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
runCmd = "aptly help mirror create"
|
||||
|
||||
|
||||
class WrongFlagTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
expectedCode = 2
|
||||
runCmd = "aptly mirror create -fxz=sss"
|
||||
|
||||
65
system/t03_help/help.py
Normal file
65
system/t03_help/help.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""
|
||||
Test help screens
|
||||
"""
|
||||
|
||||
import re
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class MainTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
expectedCode = 2
|
||||
runCmd = "aptly"
|
||||
|
||||
def outputMatchPrepare(_, s):
|
||||
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
|
||||
|
||||
|
||||
class MirrorTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
expectedCode = 2
|
||||
runCmd = "aptly mirror"
|
||||
|
||||
|
||||
class MirrorCreateTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
expectedCode = 2
|
||||
runCmd = "aptly mirror create"
|
||||
|
||||
|
||||
class MainHelpTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
runCmd = "aptly help"
|
||||
|
||||
def outputMatchPrepare(_, s):
|
||||
return re.sub(r' -(cpuprofile|memprofile|memstats|meminterval)=.*\n', '', s, flags=re.MULTILINE)
|
||||
|
||||
|
||||
class MirrorHelpTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
runCmd = "aptly help mirror"
|
||||
|
||||
|
||||
class MirrorCreateHelpTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
runCmd = "aptly help mirror create"
|
||||
|
||||
|
||||
class WrongFlagTest(BaseTest):
|
||||
"""
|
||||
main
|
||||
"""
|
||||
expectedCode = 2
|
||||
runCmd = "aptly mirror create -fxz=sss"
|
||||
@@ -1,81 +1,3 @@
|
||||
"""
|
||||
Testing serving public repo
|
||||
"""
|
||||
|
||||
import http.client
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import shlex
|
||||
import time
|
||||
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class RootDirInaccessible(BaseTest):
|
||||
"""
|
||||
serve command aborts if rootDir is inaccessible
|
||||
"""
|
||||
skipTest = 'User is root' if os.environ['USER'] == 'root' else False
|
||||
fixtureDB = False
|
||||
fixturePool = False
|
||||
|
||||
configOverride = {
|
||||
"rootDir": "/root" # any directory that exists but is not writable
|
||||
}
|
||||
|
||||
runCmd = "aptly serve -listen=127.0.0.1:8765"
|
||||
expectedCode = 1
|
||||
|
||||
|
||||
class Serve1Test(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-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"
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
proc = subprocess.Popen(shlex.split(self.runCmd), stderr=subprocess.STDOUT, stdout=subprocess.PIPE, bufsize=0)
|
||||
|
||||
try:
|
||||
time.sleep(1)
|
||||
|
||||
conn = http.client.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 and proc.returncode != 2:
|
||||
raise Exception("exit code %d != %d (output: %s)" % (proc.returncode, -2, output))
|
||||
self.output = output
|
||||
except Exception as 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, match_prepare=lambda s: "\n".join(sorted(s.split("\n"))))
|
||||
|
||||
|
||||
class Serve2Test(BaseTest):
|
||||
"""
|
||||
serve public: no publishes
|
||||
"""
|
||||
runCmd = "aptly serve -listen=127.0.0.1:8765"
|
||||
|
||||
81
system/t07_serve/serve.py
Normal file
81
system/t07_serve/serve.py
Normal file
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
Testing serving public repo
|
||||
"""
|
||||
|
||||
import http.client
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import shlex
|
||||
import time
|
||||
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class RootDirInaccessible(BaseTest):
|
||||
"""
|
||||
serve command aborts if rootDir is inaccessible
|
||||
"""
|
||||
skipTest = 'User is root' if os.environ['USER'] == 'root' else False
|
||||
fixtureDB = False
|
||||
fixturePool = False
|
||||
|
||||
configOverride = {
|
||||
"rootDir": "/root" # any directory that exists but is not writable
|
||||
}
|
||||
|
||||
runCmd = "aptly serve -listen=127.0.0.1:8765"
|
||||
expectedCode = 1
|
||||
|
||||
|
||||
class Serve1Test(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-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"
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
proc = subprocess.Popen(shlex.split(self.runCmd), stderr=subprocess.STDOUT, stdout=subprocess.PIPE, bufsize=0)
|
||||
|
||||
try:
|
||||
time.sleep(1)
|
||||
|
||||
conn = http.client.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 and proc.returncode != 2:
|
||||
raise Exception("exit code %d != %d (output: %s)" % (proc.returncode, -2, output))
|
||||
self.output = output
|
||||
except Exception as 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, match_prepare=lambda s: "\n".join(sorted(s.split("\n"))))
|
||||
|
||||
|
||||
class Serve2Test(BaseTest):
|
||||
"""
|
||||
serve public: no publishes
|
||||
"""
|
||||
runCmd = "aptly serve -listen=127.0.0.1:8765"
|
||||
@@ -6,7 +6,7 @@ import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from lib import BaseTest
|
||||
from api_lib import AptlyStream
|
||||
from testout import TestOut
|
||||
|
||||
|
||||
class UnixSocketAPITest(BaseTest):
|
||||
@@ -18,7 +18,7 @@ class UnixSocketAPITest(BaseTest):
|
||||
|
||||
def prepare(self):
|
||||
if self.aptly_server is None:
|
||||
UnixSocketAPITest.aptly_out = AptlyStream()
|
||||
UnixSocketAPITest.aptly_out = TestOut()
|
||||
self.aptly_server = self._start_process("aptly api serve -no-lock -listen=%s" % (self.base_url), stdout=UnixSocketAPITest.aptly_out, stderr=UnixSocketAPITest.aptly_out)
|
||||
time.sleep(1)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user