Commit 25054e1b authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Thomas Leymonerie

software/kvm: Switch to python3 only

There is no reason to keep python2 compatibility, as python3 flavour of the
KVM software release is good enough.
parent 9375992a
[buildout]
extends =
software.cfg
[python]
part = python3
......@@ -40,6 +40,9 @@ parts = ${:common-parts}
#XXX-Cedric : add list of keyboard layouts (azerty/us querty/...) parameter to qemu
[python]
part = python3
[python-with-eggs]
recipe = zc.recipe.egg
interpreter = ${:_buildout_section_name_}
......
......@@ -60,8 +60,7 @@ skipUnlessKvm = unittest.skipUnless(has_kvm, 'kvm not loaded or not allowed')
if has_kvm:
setUpModule, InstanceTestCase = makeModuleSetUpAndTestCaseClass(
os.path.abspath(
os.path.join(os.path.dirname(__file__), '..',
'software%s.cfg' % ("-py3" if six.PY3 else ""))))
os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))
# XXX Keep using slapos node instance --all, because of missing promises
InstanceTestCase.slap._force_slapos_node_instance_all = True
else:
......@@ -1792,14 +1791,28 @@ class TestExternalDisk(InstanceTestCase, KvmMixin):
'w') as fh:
json.dump(slapos_resource, fh, indent=2)
# above is not enough: the presence of parameter is required in slapos.cfg
slapos_config = []
with open(cls.slap._slapos_config) as fh:
slapos_config = fh.read()
slapos_config += '\n' + """
[slapos]
instance_storage_home = %s
""" % (external_storage_path,)
for line in fh.readlines():
if line.strip() == '[slapos]':
slapos_config.append('[slapos]\n')
slapos_config.append(
'instance_storage_home = %s\n' % (external_storage_path,))
else:
slapos_config.append(line)
with open(cls.slap._slapos_config, 'w') as fh:
fh.write(''.join(slapos_config))
@classmethod
def _dropExternalStorageList(cls):
slapos_config = []
with open(cls.slap._slapos_config) as fh:
for line in fh.readlines():
if line.startswith("instance_storage_home ="):
continue
slapos_config.append(line)
with open(cls.slap._slapos_config, 'w') as fh:
fh.write(slapos_config)
fh.write(''.join(slapos_config))
@classmethod
def _setUpClass(cls):
......@@ -1812,13 +1825,12 @@ instance_storage_home = %s
@classmethod
def tearDownClass(cls):
cls._dropExternalStorageList()
super(TestExternalDisk, cls).tearDownClass()
shutil.rmtree(cls.working_directory)
def getRunningDriveList(
self, kvm_instance_partition,
_match_drive=re.compile('file=(.+),if=virtio$').match
):
def getRunningDriveList(self, kvm_instance_partition):
_match_drive = re.compile('file=(.+),if=virtio').match
with self.slap.instance_supervisor_rpc as instance_supervisor:
kvm_pid = next(q for q in instance_supervisor.getAllProcessInfo()
if 'kvm-' in q['name'])['pid']
......@@ -1837,9 +1849,12 @@ instance_storage_home = %s
self.slap.instance_directory, self.kvm_instance_partition_reference)
drive_list = self.getRunningDriveList(kvm_instance_partition)
# Note: Do to unknown set of drives it's impossible to directly check
# drive paths, thus the count is important
self.assertEqual(
1 + 2, # 1 the default drive, 2 additional ones
len(drive_list))
len(drive_list)
)
# restart the VM
self.requestDefaultInstance(state='stopped')
......
......@@ -19,6 +19,7 @@ extra =
helloworld ${slapos.test.helloworld-setup:setup}
hugo ${slapos.test.hugo-setup:setup}
jupyter ${slapos.test.jupyter-setup:setup}
kvm ${slapos.test.kvm-setup:setup}
matomo ${slapos.test.matomo-setup:setup}
monitor ${slapos.test.monitor-setup:setup}
nextcloud ${slapos.test.nextcloud-setup:setup}
......
......@@ -350,7 +350,6 @@ tests =
# here, to check there's no promise issue when slapos node runs with Python 2.
erp5 ${slapos.test.erp5-setup:setup}
fluentd ${slapos.test.fluentd-setup:setup}
kvm ${slapos.test.kvm-setup:setup}
metabase ${slapos.test.metabase-setup:setup}
###
${:extra}
......
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