mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-20 19:38:39 +00:00
aptly mirror create system tests.
This commit is contained in:
@@ -33,13 +33,17 @@ class BaseTest(object):
|
||||
f.close()
|
||||
|
||||
def run(self):
|
||||
self.output = self.run_cmd(self.runCmd, self.expectedCode)
|
||||
|
||||
def run_cmd(self, command, expected_code=0):
|
||||
try:
|
||||
proc = subprocess.Popen(self.runCmd.split(" "), stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
|
||||
self.output, _ = proc.communicate()
|
||||
if proc.returncode != self.expectedCode:
|
||||
raise Exception("exit code %d != %d" % (proc.returncode, self.expectedCode))
|
||||
proc = subprocess.Popen(command.split(" "), stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
|
||||
output, _ = proc.communicate()
|
||||
if proc.returncode != expected_code:
|
||||
raise Exception("exit code %d != %d" % (proc.returncode, expected_code))
|
||||
return output
|
||||
except Exception, e:
|
||||
raise Exception("Running command %s failed: %s" % (self.runCmd, str(e)))
|
||||
raise Exception("Running command %s failed: %s" % (command, str(e)))
|
||||
|
||||
def gold_processor(self, gold):
|
||||
return gold
|
||||
@@ -47,13 +51,16 @@ class BaseTest(object):
|
||||
def expand_environ(self, gold):
|
||||
return string.Template(gold).substitute(os.environ)
|
||||
|
||||
def get_gold(self):
|
||||
gold = os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__ + "_gold")
|
||||
def get_gold(self, gold_name="gold"):
|
||||
gold = os.path.join(os.path.dirname(inspect.getsourcefile(self.__class__)), self.__class__.__name__ + "_" + gold_name)
|
||||
return self.gold_processor(open(gold, "r").read())
|
||||
|
||||
def check_output(self):
|
||||
self.verify_match(self.get_gold(), self.output)
|
||||
|
||||
def check_cmd_output(self, command, gold_name):
|
||||
self.verify_match(self.get_gold(gold_name), self.run_cmd(command))
|
||||
|
||||
def verify_match(self, a, b):
|
||||
if a != b:
|
||||
diff = "".join(difflib.unified_diff([l + "\n" for l in a.split("\n")], [l + "\n" for l in b.split("\n")]))
|
||||
|
||||
@@ -38,7 +38,7 @@ def run():
|
||||
except BaseException, e:
|
||||
numFailed += 1
|
||||
fails.append((test, t, e, testModule))
|
||||
sys.stdout.write("FAIL\n")
|
||||
sys.stdout.write(colored("FAIL\n", color="red"))
|
||||
else:
|
||||
sys.stdout.write(colored("OK\n", color="green"))
|
||||
|
||||
|
||||
4
system/t04_mirror/CreateMirror1Test_gold
Normal file
4
system/t04_mirror/CreateMirror1Test_gold
Normal file
@@ -0,0 +1,4 @@
|
||||
Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release...
|
||||
|
||||
Mirror [mirror1]: http://mirror.yandex.ru/debian/ wheezy successfully added.
|
||||
You can run 'aptly mirror update mirror1' to download repository contents.
|
||||
18
system/t04_mirror/CreateMirror1Test_mirror_show
Normal file
18
system/t04_mirror/CreateMirror1Test_mirror_show
Normal file
@@ -0,0 +1,18 @@
|
||||
Name: mirror1
|
||||
Archive Root URL: http://mirror.yandex.ru/debian/
|
||||
Distribution: wheezy
|
||||
Components: main, contrib, non-free
|
||||
Architectures: amd64, armel, armhf, i386, ia64, kfreebsd-amd64, kfreebsd-i386, mips, mipsel, powerpc, s390, s390x, sparc
|
||||
Last update: never
|
||||
|
||||
Information from release file:
|
||||
Architectures: amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc
|
||||
Codename: wheezy
|
||||
Components: main contrib non-free
|
||||
Date: Sat, 14 Dec 2013 10:51:30 UTC
|
||||
Description: Debian 7.3 Released 14 December 2013
|
||||
|
||||
Label: Debian
|
||||
Origin: Debian
|
||||
Suite: stable
|
||||
Version: 7.3
|
||||
4
system/t04_mirror/CreateMirror2Test_gold
Normal file
4
system/t04_mirror/CreateMirror2Test_gold
Normal file
@@ -0,0 +1,4 @@
|
||||
Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release...
|
||||
|
||||
Mirror [mirror2]: http://mirror.yandex.ru/debian/ wheezy successfully added.
|
||||
You can run 'aptly mirror update mirror2' to download repository contents.
|
||||
18
system/t04_mirror/CreateMirror2Test_mirror_show
Normal file
18
system/t04_mirror/CreateMirror2Test_mirror_show
Normal file
@@ -0,0 +1,18 @@
|
||||
Name: mirror2
|
||||
Archive Root URL: http://mirror.yandex.ru/debian/
|
||||
Distribution: wheezy
|
||||
Components: main
|
||||
Architectures: amd64, armel, armhf, i386, ia64, kfreebsd-amd64, kfreebsd-i386, mips, mipsel, powerpc, s390, s390x, sparc
|
||||
Last update: never
|
||||
|
||||
Information from release file:
|
||||
Architectures: amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc
|
||||
Codename: wheezy
|
||||
Components: main contrib non-free
|
||||
Date: Sat, 14 Dec 2013 10:51:30 UTC
|
||||
Description: Debian 7.3 Released 14 December 2013
|
||||
|
||||
Label: Debian
|
||||
Origin: Debian
|
||||
Suite: stable
|
||||
Version: 7.3
|
||||
4
system/t04_mirror/CreateMirror3Test_gold
Normal file
4
system/t04_mirror/CreateMirror3Test_gold
Normal file
@@ -0,0 +1,4 @@
|
||||
Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release...
|
||||
|
||||
Mirror [mirror3]: http://mirror.yandex.ru/debian/ wheezy successfully added.
|
||||
You can run 'aptly mirror update mirror3' to download repository contents.
|
||||
18
system/t04_mirror/CreateMirror3Test_mirror_show
Normal file
18
system/t04_mirror/CreateMirror3Test_mirror_show
Normal file
@@ -0,0 +1,18 @@
|
||||
Name: mirror3
|
||||
Archive Root URL: http://mirror.yandex.ru/debian/
|
||||
Distribution: wheezy
|
||||
Components: main, contrib
|
||||
Architectures: i386, amd64
|
||||
Last update: never
|
||||
|
||||
Information from release file:
|
||||
Architectures: amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 s390x sparc
|
||||
Codename: wheezy
|
||||
Components: main contrib non-free
|
||||
Date: Sat, 14 Dec 2013 10:51:30 UTC
|
||||
Description: Debian 7.3 Released 14 December 2013
|
||||
|
||||
Label: Debian
|
||||
Origin: Debian
|
||||
Suite: stable
|
||||
Version: 7.3
|
||||
2
system/t04_mirror/CreateMirror4Test_gold
Normal file
2
system/t04_mirror/CreateMirror4Test_gold
Normal file
@@ -0,0 +1,2 @@
|
||||
Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release...
|
||||
ERROR: unable to fetch mirror: component life not available in repo [mirror4]: http://mirror.yandex.ru/debian/ wheezy
|
||||
2
system/t04_mirror/CreateMirror5Test_gold
Normal file
2
system/t04_mirror/CreateMirror5Test_gold
Normal file
@@ -0,0 +1,2 @@
|
||||
Downloading http://mirror.yandex.ru/debian/dists/wheezy/Release...
|
||||
ERROR: unable to fetch mirror: architecture nano68 not available in repo [mirror5]: http://mirror.yandex.ru/debian/ wheezy
|
||||
2
system/t04_mirror/CreateMirror6Test_gold
Normal file
2
system/t04_mirror/CreateMirror6Test_gold
Normal file
@@ -0,0 +1,2 @@
|
||||
Downloading http://mirror.yandex.ru/debian/dists/suslik/Release...
|
||||
ERROR: unable to fetch mirror: HTTP code 404 while fetching http://mirror.yandex.ru/debian/dists/suslik/Release
|
||||
5
system/t04_mirror/__init__.py
Normal file
5
system/t04_mirror/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""
|
||||
Testing mirror management
|
||||
"""
|
||||
|
||||
from .create import *
|
||||
61
system/t04_mirror/create.py
Normal file
61
system/t04_mirror/create.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from lib import BaseTest
|
||||
|
||||
|
||||
class CreateMirror1Test(BaseTest):
|
||||
"""
|
||||
create mirror: all architectures + all components
|
||||
"""
|
||||
runCmd = "aptly mirror create mirror1 http://mirror.yandex.ru/debian/ wheezy"
|
||||
|
||||
def check(self):
|
||||
self.check_output()
|
||||
self.check_cmd_output("aptly mirror show mirror1", "mirror_show")
|
||||
|
||||
|
||||
class CreateMirror2Test(BaseTest):
|
||||
"""
|
||||
create mirror: all architectures and 1 component
|
||||
"""
|
||||
runCmd = "aptly mirror create mirror2 http://mirror.yandex.ru/debian/ wheezy main"
|
||||
|
||||
def check(self):
|
||||
self.check_output()
|
||||
self.check_cmd_output("aptly mirror show mirror2", "mirror_show")
|
||||
|
||||
|
||||
class CreateMirror3Test(BaseTest):
|
||||
"""
|
||||
create mirror: some architectures and 2 components
|
||||
"""
|
||||
runCmd = "aptly -architectures=i386,amd64 mirror create mirror3 http://mirror.yandex.ru/debian/ wheezy main contrib"
|
||||
|
||||
def check(self):
|
||||
self.check_output()
|
||||
self.check_cmd_output("aptly mirror show mirror3", "mirror_show")
|
||||
|
||||
|
||||
class CreateMirror4Test(BaseTest):
|
||||
"""
|
||||
create mirror: missing component
|
||||
"""
|
||||
expectedCode = 1
|
||||
|
||||
runCmd = "aptly -architectures=i386,amd64 mirror create mirror4 http://mirror.yandex.ru/debian/ wheezy life"
|
||||
|
||||
|
||||
class CreateMirror5Test(BaseTest):
|
||||
"""
|
||||
create mirror: missing architecture
|
||||
"""
|
||||
expectedCode = 1
|
||||
|
||||
runCmd = "aptly -architectures=i386,nano68 mirror create mirror5 http://mirror.yandex.ru/debian/ wheezy"
|
||||
|
||||
|
||||
class CreateMirror6Test(BaseTest):
|
||||
"""
|
||||
create mirror: missing release
|
||||
"""
|
||||
expectedCode = 1
|
||||
|
||||
runCmd = "aptly mirror create mirror6 http://mirror.yandex.ru/debian/ suslik"
|
||||
Reference in New Issue
Block a user