diff --git a/lib/host.py b/lib/host.py index d7031a9bc..4876a82b6 100644 --- a/lib/host.py +++ b/lib/host.py @@ -201,13 +201,13 @@ def execute_script(self, script_contents, shebang='sh', simple_output=True): script.write('#!/usr/bin/env ' + shebang + '\n') script.write(script_contents) script.flush() - self.scp(script.name, script.name) + self.scp(script.name, "/tmp/" + script.name.split('/')[-1]) try: logging.debug(f"[{self}] # Will execute this temporary script:\n{script_contents.strip()}") - return self.ssh([script.name], simple_output=simple_output) + return self.ssh(["/tmp/" + script.name.split('/')[-1]], simple_output=simple_output) finally: - self.ssh(['rm', '-f', script.name]) + self.ssh(['rm', '-f', "/tmp/" + script.name.split('/')[-1]]) def _get_xensource_inventory(self) -> Dict[str, str]: output = self.ssh(['cat', '/etc/xensource-inventory']) diff --git a/tests/storage/ext/conftest.py b/tests/storage/ext/conftest.py index 3b09f0819..020d332e2 100644 --- a/tests/storage/ext/conftest.py +++ b/tests/storage/ext/conftest.py @@ -2,9 +2,12 @@ import pytest @pytest.fixture(scope='package') -def ext_sr(host, sr_disk): +def ext_sr(host, sr_disk, vdi_image_format): """ An EXT SR on first host. """ - sr = host.sr_create('ext', "EXT-local-SR-test", {'device': '/dev/' + sr_disk}) + sr = host.sr_create('ext', "EXT-local-SR-test", { + 'device': '/dev/' + sr_disk, + 'preferred-image-formats': vdi_image_format + }) yield sr # teardown sr.destroy() @@ -22,3 +25,7 @@ def vm_on_ext_sr(host, ext_sr, vm_ref): # teardown logging.info("<< Destroy VM") vm.destroy(verify=True) + +@pytest.fixture(params=["qcow2", "vhd"], scope="session") +def vdi_image_format(request): + return request.param diff --git a/tests/storage/ext/test_ext_sr.py b/tests/storage/ext/test_ext_sr.py index 8697219c7..88762161b 100644 --- a/tests/storage/ext/test_ext_sr.py +++ b/tests/storage/ext/test_ext_sr.py @@ -15,9 +15,12 @@ class TestEXTSRCreateDestroy: def test_create_sr_with_missing_device(self, host): try_to_create_sr_with_missing_device('ext', 'EXT-local-SR-test', host) - def test_create_and_destroy_sr(self, host, sr_disk): + def test_create_and_destroy_sr(self, host, vdi_image_format, sr_disk): # Create and destroy tested in the same test to leave the host as unchanged as possible - sr = host.sr_create('ext', "EXT-local-SR-test", {'device': '/dev/' + sr_disk}, verify=True) + sr = host.sr_create('ext', "EXT-local-SR-test", { + 'device': '/dev/' + sr_disk, + 'preferred-image-formats': vdi_image_format + }, verify=True) # import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in # the next tests, because errors in fixtures break teardown vm = host.import_vm(vm_image('mini-linux-x86_64-bios'), sr_uuid=sr.uuid)