Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
11 changes: 9 additions & 2 deletions tests/storage/ext/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
7 changes: 5 additions & 2 deletions tests/storage/ext/test_ext_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down