Commit 9f94f585 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Thomas Leymonerie

kvm: flak8ize test

parent 25054e1b
...@@ -455,8 +455,8 @@ class TestAccessDefaultBootstrap(MonitorAccessMixin, InstanceTestCase): ...@@ -455,8 +455,8 @@ class TestAccessDefaultBootstrap(MonitorAccessMixin, InstanceTestCase):
self.slap.waitForInstance(max_retry=10) self.slap.waitForInstance(max_retry=10)
# END: mock .slapos-resource with tap.ipv4_addr # END: mock .slapos-resource with tap.ipv4_addr
connection_parameter_dict = self.computer_partition\ cp = self.computer_partition
.getConnectionParameterDict() connection_parameter_dict = cp.getConnectionParameterDict()
result = requests.get(connection_parameter_dict['url'], verify=False) result = requests.get(connection_parameter_dict['url'], verify=False)
self.assertEqual( self.assertEqual(
...@@ -887,13 +887,14 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin): ...@@ -887,13 +887,14 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin):
self.slap.waitForInstance(max_retry=10) self.slap.waitForInstance(max_retry=10)
super(InstanceTestCase, self).tearDown() super(InstanceTestCase, self).tearDown()
def getRunningImageList(self, kvm_instance_partition, def getRunningImageList(
self, kvm_instance_partition,
_match_cdrom=re.compile('file=(.+),media=cdrom$').match, _match_cdrom=re.compile('file=(.+),media=cdrom$').match,
_sub_iso=re.compile(r'(/debian)(-[^-/]+)(-[^/]+-netinst\.iso)$').sub, _sub_iso=re.compile(r'(/debian)(-[^-/]+)(-[^/]+-netinst\.iso)$').sub,
): ):
with self.slap.instance_supervisor_rpc as instance_supervisor: with self.slap.instance_supervisor_rpc as instance_supervisor:
kvm_pid = next(q for q in instance_supervisor.getAllProcessInfo() kvm_pid = next(q for q in instance_supervisor.getAllProcessInfo()
if 'kvm-' in q['name'])['pid'] if 'kvm-' in q['name'])['pid']
sub_shared = re.compile(r'^%s/[^/]+/[0-9a-f]{32}/' sub_shared = re.compile(r'^%s/[^/]+/[0-9a-f]{32}/'
% re.escape(self.slap.shared_directory)).sub % re.escape(self.slap.shared_directory)).sub
image_list = [] image_list = []
...@@ -902,10 +903,12 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin): ...@@ -902,10 +903,12 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin):
if m: if m:
path = m.group(1) path = m.group(1)
image_list.append( image_list.append(
_sub_iso(r'\1-${ver}\3', _sub_iso(
sub_shared(r'${shared}/', r'\1-${ver}\3',
path.replace(kvm_instance_partition, '${inst}') sub_shared(
))) r'${shared}/',
path.replace(kvm_instance_partition, '${inst}')
)))
return image_list return image_list
def test(self): def test(self):
...@@ -1039,6 +1042,7 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin): ...@@ -1039,6 +1042,7 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin):
@skipUnlessKvm @skipUnlessKvm
class TestBootImageUrlListResilient(TestBootImageUrlList): class TestBootImageUrlListResilient(TestBootImageUrlList):
kvm_instance_partition_reference = 'biul2' kvm_instance_partition_reference = 'biul2'
@classmethod @classmethod
def getInstanceSoftwareType(cls): def getInstanceSoftwareType(cls):
return 'kvm-resilient' return 'kvm-resilient'
...@@ -1149,6 +1153,7 @@ class TestBootImageUrlSelect(TestBootImageUrlList): ...@@ -1149,6 +1153,7 @@ class TestBootImageUrlSelect(TestBootImageUrlList):
@skipUnlessKvm @skipUnlessKvm
class TestBootImageUrlSelectResilient(TestBootImageUrlSelect): class TestBootImageUrlSelectResilient(TestBootImageUrlSelect):
kvm_instance_partition_reference = 'bius2' kvm_instance_partition_reference = 'bius2'
@classmethod @classmethod
def getInstanceSoftwareType(cls): def getInstanceSoftwareType(cls):
return 'kvm-resilient' return 'kvm-resilient'
...@@ -1264,6 +1269,7 @@ class TestNatRulesKvmCluster(InstanceTestCase): ...@@ -1264,6 +1269,7 @@ class TestNatRulesKvmCluster(InstanceTestCase):
__partition_reference__ = 'nrkc' __partition_reference__ = 'nrkc'
nat_rules = ["100", "200", "300"] nat_rules = ["100", "200", "300"]
@classmethod @classmethod
def getInstanceSoftwareType(cls): def getInstanceSoftwareType(cls):
return 'kvm-cluster' return 'kvm-cluster'
...@@ -1340,6 +1346,7 @@ class TestWhitelistFirewall(InstanceTestCase): ...@@ -1340,6 +1346,7 @@ class TestWhitelistFirewall(InstanceTestCase):
@skipUnlessKvm @skipUnlessKvm
class TestWhitelistFirewallRequest(TestWhitelistFirewall): class TestWhitelistFirewallRequest(TestWhitelistFirewall):
whitelist_domains = '2.2.2.2 3.3.3.3\n4.4.4.4' whitelist_domains = '2.2.2.2 3.3.3.3\n4.4.4.4'
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return { return {
...@@ -1655,7 +1662,7 @@ class TestParameterDefault(InstanceTestCase, KvmMixin): ...@@ -1655,7 +1662,7 @@ class TestParameterDefault(InstanceTestCase, KvmMixin):
def _test(self, parameter_dict, expected): def _test(self, parameter_dict, expected):
self.rerequestInstance(self.mangleParameterDict(parameter_dict)) self.rerequestInstance(self.mangleParameterDict(parameter_dict))
self.slap.waitForInstance(max_retry=10) self.slap.waitForInstance(max_retry=10)
kvm_raw = glob.glob(os.path.join( kvm_raw = glob.glob(os.path.join(
self.slap.instance_directory, '*', 'bin', 'kvm_raw')) self.slap.instance_directory, '*', 'bin', 'kvm_raw'))
self.assertEqual(len(kvm_raw), 1) self.assertEqual(len(kvm_raw), 1)
...@@ -1704,6 +1711,7 @@ class TestParameterDefault(InstanceTestCase, KvmMixin): ...@@ -1704,6 +1711,7 @@ class TestParameterDefault(InstanceTestCase, KvmMixin):
@skipUnlessKvm @skipUnlessKvm
class TestParameterResilient(TestParameterDefault): class TestParameterResilient(TestParameterDefault):
__partition_reference__ = 'pr' __partition_reference__ = 'pr'
@classmethod @classmethod
def getInstanceSoftwareType(cls): def getInstanceSoftwareType(cls):
return 'kvm-resilient' return 'kvm-resilient'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment