Skip to content

Commit e44e6b8

Browse files
committed
Choose a local SR that was already in the pool before the tests
The test may create a local SR that should be used only for the test. Using it for something else, like caching the VMs, it prevents the SR being destroyed in the tear down. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 69dc883 commit e44e6b8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/host.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,12 @@ def main_sr_uuid(self):
665665
self.xe('sr-list', {'host': hostname, 'content-type': 'user', 'minimal': 'true'}),
666666
','
667667
)
668-
assert local_sr_uuids, f"DEFAULT_SR=='local' so there must be a local SR on host {self}"
669-
sr_uuid = local_sr_uuids[0]
668+
# We don't want a SR added by the test, so choose one that already existed
669+
pre_existing_local_sr_uuids = sorted(set(self.pool.pre_existing_sr_uuids) & set(local_sr_uuids))
670+
assert pre_existing_local_sr_uuids, (
671+
f"DEFAULT_SR=='local' so there must be a pre-existing local SR on host {self}"
672+
)
673+
sr_uuid = pre_existing_local_sr_uuids[0]
670674
elif DEFAULT_SR == 'default':
671675
sr_uuid = self.pool.param_get('default-SR')
672676
assert sr_uuid, f"DEFAULT_SR='default' so there must be a default SR on the pool of host {self}"

lib/pool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self, master_hostname_or_ip: HostAddress) -> None:
3535
self.hosts.append(host)
3636
self.uuid = self.master.xe('pool-list', minimal=True)
3737
self.saved_uefi_certs: Optional[Dict[str, Any]] = None
38+
self.pre_existing_sr_uuids = safe_split(self.master.xe('sr-list', {'minimal': 'true'}), ',')
3839

3940
def param_get(self, param_name, key=None, accept_unknown_key=False):
4041
return _param_get(self.master, Pool.xe_prefix, self.uuid, param_name, key, accept_unknown_key)

0 commit comments

Comments
 (0)