Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cnv related fixes and dir restructure #10668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 ocs_ci/helpers/cnv_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def create_volume_import_source(name=None, url=constants.CNV_CENTOS_SOURCE):
source_data_obj: The created VolumeImportSource object

"""
source_data = templating.load_yaml(constants.CNV_VM_STANDALONE_PVC_SOURCE_YAML)
source_data = templating.load_yaml(constants.CNV_VM_SOURCE_YAML)
name = name if name else create_unique_resource_name("source", "volumeimportsource")
source_data["metadata"]["name"] = name
source_data["spec"]["source"]["registry"]["url"] = url
Expand Down Expand Up @@ -153,7 +153,7 @@ def create_pvc_using_data_source(
pvc_obj: PVC object

"""
pvc_data = templating.load_yaml(constants.CNV_VM_STANDALONE_PVC_PVC_YAML)
pvc_data = templating.load_yaml(constants.CNV_VM_PVC_YAML)
pvc_name = create_unique_resource_name("test", "pvc")
pvc_data["metadata"]["name"] = pvc_name
pvc_data["metadata"]["namespace"] = namespace
Expand Down Expand Up @@ -189,7 +189,7 @@ def create_dv(
dv_obj: DV object

"""
dv_data = templating.load_yaml(constants.CNV_VM_STANDALONE_DV_YAML)
dv_data = templating.load_yaml(constants.CNV_VM_DV_YAML)
dv_name = create_unique_resource_name("test", "dv")
dv_data["metadata"]["name"] = dv_name
dv_data["metadata"]["namespace"] = namespace
Expand Down
23 changes: 13 additions & 10 deletions ocs_ci/ocs/cnv/virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ def create_vm_workload(
except CommandFailed as ex:
if "(AlreadyExists)" in str(ex):
logger.warning(f"The namespace: {self.namespace} already exists!")
vm_dict_path = (
vm_dict_path if vm_dict_path else constants.CNV_VM_STANDALONE_PVC_VM_YAML
)
vm_dict_path = vm_dict_path if vm_dict_path else constants.CNV_VM_TEMPLATE_YAML
vm_data = templating.load_yaml(vm_dict_path)
vm_data["metadata"]["name"] = self._vm_name
vm_data["metadata"]["namespace"] = self.namespace
Expand Down Expand Up @@ -148,7 +146,6 @@ def create_vm_workload(
wait_for_resource_state(
resource=self.pvc_obj, state=constants.STATUS_BOUND, timeout=300
)

if volume_interface == constants.VM_VOLUME_DV:
self.dv_obj = create_dv(
pvc_size=pvc_size,
Expand All @@ -157,9 +154,12 @@ def create_vm_workload(
namespace=self.namespace,
source_url=source_url,
)
vm_data["spec"]["template"]["spec"]["volumes"][0]["persistentVolumeClaim"][
"claimName"
] = self.dv_obj.name
del vm_data["spec"]["template"]["spec"]["volumes"][0][
"persistentVolumeClaim"
]
vm_data["spec"]["template"]["spec"]["volumes"][0]["dataVolume"] = {
"name": f"{self.dv_obj.name}"
}

if volume_interface == constants.VM_VOLUME_DVT:
# Define the dataVolumeTemplates content with parameters
Expand All @@ -181,9 +181,12 @@ def create_vm_workload(
vm_data["spec"]["dataVolumeTemplates"].append(
{"metadata": metadata, "spec": storage_spec}
)
vm_data["spec"]["template"]["spec"]["volumes"][0]["persistentVolumeClaim"][
"claimName"
] = dvt_name
del vm_data["spec"]["template"]["spec"]["volumes"][0][
"persistentVolumeClaim"
]
vm_data["spec"]["template"]["spec"]["volumes"][0]["dataVolume"] = {
"name": f"{dvt_name}"
}

vm_ocs_obj = create_resource(**vm_data)
logger.info(f"Successfully created VM: {vm_ocs_obj.name}")
Expand Down
17 changes: 4 additions & 13 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@
TEMPLATE_AUTHENTICATION_DIR = os.path.join(TEMPLATE_DIR, "authentication")
KREW_INSTALL_DIR = os.path.join(TEMPLATE_DIR, "krew_plugin")
TEMPLATE_CNV_VM_WORKLOAD_DIR = os.path.join(TEMPLATE_DIR, "cnv-vm-workload")
TEMPLATE_CNV_VM_STANDALONE_PVC_DIR = os.path.join(
TEMPLATE_CNV_VM_WORKLOAD_DIR, "vm-standalone-pvc"
)
DATA_DIR = os.getenv("OCSCI_DATA_DIR") or os.path.join(TOP_DIR, "data")
ROOK_REPO_DIR = os.path.join(DATA_DIR, "rook")
ROOK_EXAMPLES_DIR = os.path.join(
Expand Down Expand Up @@ -977,16 +974,10 @@
CNV_VM_SECRET_YAML = os.path.join(TEMPLATE_DEPLOYMENT_DIR_CNV, "vm-secret.yaml")

# CNV VM workload yamls
CNV_VM_STANDALONE_PVC_SOURCE_YAML = os.path.join(
TEMPLATE_CNV_VM_STANDALONE_PVC_DIR, "source.yaml"
)
CNV_VM_STANDALONE_PVC_PVC_YAML = os.path.join(
TEMPLATE_CNV_VM_STANDALONE_PVC_DIR, "pvc.yaml"
)
CNV_VM_STANDALONE_DV_YAML = os.path.join(TEMPLATE_CNV_VM_STANDALONE_PVC_DIR, "dv.yaml")
CNV_VM_STANDALONE_PVC_VM_YAML = os.path.join(
TEMPLATE_CNV_VM_STANDALONE_PVC_DIR, "vm.yaml"
)
CNV_VM_SOURCE_YAML = os.path.join(TEMPLATE_CNV_VM_WORKLOAD_DIR, "source.yaml")
CNV_VM_PVC_YAML = os.path.join(TEMPLATE_CNV_VM_WORKLOAD_DIR, "pvc.yaml")
CNV_VM_DV_YAML = os.path.join(TEMPLATE_CNV_VM_WORKLOAD_DIR, "dv.yaml")
CNV_VM_TEMPLATE_YAML = os.path.join(TEMPLATE_CNV_VM_WORKLOAD_DIR, "vm.yaml")

METALLB = "metallb-operator"
METALLB_CONTROLLER_MANAGER_PREFIX = "metallb-operator-controller-manager"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: centos-stream8
name: vm-template
namespace: default
spec:
running: true
template:
metadata:
annotations:
vm.kubevirt.io/flavor: small
vm.kubevirt.io/os: centos-stream8
vm.kubevirt.io/workload: server
creationTimestamp: null
labels:
kubevirt.io/domain: centos-stream8
kubevirt.io/domain: vm
kubevirt.io/size: small
spec:
architecture: amd64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def test_vm_lifecycle_and_io(self, cnv_workload, setup_cnv):
constants.VM_VOLUME_DVT,
]
for index, vl_if in enumerate(volume_interface):
vm_obj = cnv_workload(volume_interface=vl_if)[index]
vm_obj = cnv_workload(
volume_interface=vl_if, source_url=constants.CNV_FEDORA_SOURCE
)[index]
vm_obj.run_ssh_cmd(
command="dd if=/dev/zero of=/dd_file.txt bs=1024 count=102400"
)
Expand Down
Loading