Skip to content

Commit d08ab7a

Browse files
committed
Added wait to delete pv
Signed-off-by: Avdhoot <[email protected]>
1 parent 587d42e commit d08ab7a

File tree

3 files changed

+28
-37
lines changed

3 files changed

+28
-37
lines changed

ocs_ci/ocs/cnv/virtual_machine.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -655,18 +655,21 @@ def delete(self):
655655
if self.volume_interface == constants.VM_VOLUME_PVC:
656656
# Deletes only when PVC & VIS obj exists
657657
if self.pvc_obj:
658+
self.pvc_obj.reload()
659+
pv_name = self.pvc_obj.data.get("spec").get("volumeName")
658660
self.pvc_obj.delete()
659661
self.pvc_obj.ocp.wait_for_delete(
660662
resource_name=self.pvc_obj.name, timeout=180
661663
)
664+
self.pvc_obj.ocp.wait_for_delete(resource_name=pv_name, timeout=300)
662665
if self.volumeimportsource_obj:
663666
self.volumeimportsource_obj.delete()
664667
elif self.volume_interface == constants.VM_VOLUME_DV:
665668
# Deletes only when DV obj exists
666669
if self.dv_obj:
667670
self.dv_obj.delete()
668671
self.dv_obj.ocp.wait_for_delete(
669-
resource_name=self.dv_obj.name, timeout=180
672+
resource_name=self.dv_obj.name, timeout=300
670673
)
671674
if self.ns_obj:
672675
self.ns_obj.delete_project(project_name=self.namespace)

ocs_ci/templates/cnv-vm-workload/vm.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
architecture: amd64
1818
domain:
1919
cpu:
20-
cores: 1
20+
cores: 2
2121
sockets: 1
2222
threads: 1
2323
devices:
@@ -37,7 +37,7 @@ spec:
3737
networkInterfaceMultiqueue: true
3838
rng: {}
3939
memory:
40-
guest: 2Gi
40+
guest: 6Gi
4141
resources: {}
4242
evictionStrategy: LiveMigrate
4343
networks:

tests/conftest.py

+22-34
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import threading
1010
import json
1111
from concurrent.futures.thread import ThreadPoolExecutor
12-
from concurrent.futures import as_completed
1312
from datetime import datetime
1413
from math import floor
1514
from shutil import copyfile, rmtree
@@ -7314,42 +7313,31 @@ def factory(namespace=None):
73147313
# Load VM configs from cnv_vm_workload yaml
73157314
vm_configs = templating.load_yaml(constants.CNV_VM_WORKLOADS)
73167315

7317-
# Function to create a VM using cnv_workload
7318-
def create_vm(index, vm_config, sc_obj_def_compr, sc_obj_aggressive, namespace):
7319-
# Determine the storage class based on the compression type
7320-
if vm_config["sc_compression"] == "default":
7321-
storageclass = sc_obj_def_compr.name
7322-
elif vm_config["sc_compression"] == "aggressive":
7323-
storageclass = sc_obj_aggressive.name
7324-
7325-
return cnv_workload(
7326-
volume_interface=vm_config["volume_interface"],
7327-
access_mode=vm_config["access_mode"],
7328-
storageclass=storageclass,
7329-
pvc_size="30Gi", # Assuming pvc_size is fixed for all
7330-
source_url=constants.CNV_FEDORA_SOURCE, # Assuming source_url is the same for all VMs
7331-
namespace=namespace,
7332-
)[index]
7333-
7334-
# Use ThreadPoolExecutor for parallel execution
7316+
# Use ThreadPoolExecutor to create VMs parallel
73357317
with ThreadPoolExecutor() as executor:
7336-
future_to_vm = {
7337-
executor.submit(
7338-
create_vm,
7339-
index,
7340-
vm_config,
7341-
sc_obj_def_compr,
7342-
sc_obj_aggressive,
7343-
namespace,
7344-
): vm_config
7345-
for index, vm_config in enumerate(vm_configs["cnv_vm_configs"])
7346-
}
7318+
futures = []
7319+
for vm_config in vm_configs["cnv_vm_configs"]:
7320+
# Determine the storage class based on the compression type
7321+
if vm_config["sc_compression"] == "default":
7322+
storageclass = sc_obj_def_compr.name
7323+
elif vm_config["sc_compression"] == "aggressive":
7324+
storageclass = sc_obj_aggressive.name
7325+
future = executor.submit(
7326+
cnv_workload,
7327+
volume_interface=vm_config["volume_interface"],
7328+
access_mode=vm_config["access_mode"],
7329+
storageclass=storageclass,
7330+
pvc_size="30Gi", # Assuming pvc_size is fixed for all
7331+
source_url=constants.CNV_FEDORA_SOURCE, # Assuming source_url is the same for all VMs
7332+
namespace=namespace,
7333+
)
7334+
7335+
futures.append((future, vm_config["sc_compression"]))
73477336

7348-
for future in as_completed(future_to_vm):
7349-
vm_config = future_to_vm[future]
7337+
for future, sc_compression in futures:
73507338
try:
7351-
vm_obj = future.result()
7352-
if vm_config["sc_compression"] == "aggressive":
7339+
vm_obj = future.result()[0]
7340+
if sc_compression == "aggressive":
73537341
vm_list_agg_compr.append(vm_obj)
73547342
else:
73557343
vm_list_default_compr.append(vm_obj)

0 commit comments

Comments
 (0)