Skip to content

Commit 9633b3e

Browse files
Fix the s390x tier2 storage tests which are failing due to missing DEFAULT_DV_SIZE. (RedHatQE#2143)
##### Short description: - Some of the tests are failing in s390x as they are using less size than the required size. So i have changed those tests to use DEFAULT_DV_SIZE constant which will give the required size based on the Architecture. - Test test_disk_falloc is not working with /dev/zero on s390x due to some issue. So I am using /dev/urandom for s390x. ##### More details: ##### What this PR does / why we need it: ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Standardized default DataVolume sizes across storage tests by using a shared image size constant. - Updated upload and virtctl upload tests to use the centralized default size. - Harmonized an HTTP import disk-fill test: switched to an Alpine image/source, updated image/size/wait parameters, changed disk-fill to use non-zero data, and generalized the expected "No space left on device" message. - Expanded console prompt tests to accept both root (#) and user ($) prompts. - **Chores** - Added Alpine OS flavor, normalized Alpine image names, and excluded Alpine from cloud-init by default. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Vamsi Krishna Siddu <vamsikrishna.siddu@ibm.com>
1 parent 2367b27 commit 9633b3e

10 files changed

Lines changed: 40 additions & 33 deletions

File tree

tests/storage/cdi_import/test_import_http.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
)
3131
from utilities import console
3232
from utilities.constants import (
33+
OS_FLAVOR_ALPINE,
3334
OS_FLAVOR_RHEL,
3435
TIMEOUT_1MIN,
3536
TIMEOUT_5MIN,
@@ -532,29 +533,33 @@ def test_blank_disk_import_validate_status(data_volume_multi_storage_scope_funct
532533

533534

534535
@pytest.mark.parametrize(
535-
"dv_from_http_import",
536+
"data_volume_multi_storage_scope_function",
536537
[
537538
pytest.param(
538539
{
539540
"dv_name": "cnv-3065",
540-
"file_name": Images.Cdi.QCOW2_IMG,
541-
"source": HTTPS,
542-
"size": "100Mi",
543-
"configmap_name": INTERNAL_HTTP_CONFIGMAP_NAME,
541+
"source": HTTP,
542+
"image": f"{Images.Alpine.DIR}/{Images.Alpine.QCOW2_IMG}",
543+
"dv_size": Images.Alpine.DEFAULT_DV_SIZE,
544+
"wait": True,
544545
},
545546
marks=pytest.mark.polarion("CNV-3065"),
546547
),
547548
],
548549
indirect=True,
549550
)
550551
@pytest.mark.sno
551-
def test_disk_falloc(internal_http_configmap, dv_from_http_import):
552-
dv_from_http_import.wait_for_dv_success()
553-
with create_vm_from_dv(dv=dv_from_http_import) as vm_dv:
552+
def test_disk_falloc(data_volume_multi_storage_scope_function):
553+
data_volume_multi_storage_scope_function.wait_for_dv_success()
554+
with create_vm_from_dv(
555+
dv=data_volume_multi_storage_scope_function,
556+
os_flavor=OS_FLAVOR_ALPINE,
557+
memory_guest=Images.Alpine.DEFAULT_MEMORY_SIZE,
558+
) as vm_dv:
554559
with console.Console(vm=vm_dv) as vm_console:
555560
LOGGER.info("Fill disk space.")
556-
vm_console.sendline("dd if=/dev/zero of=file bs=1M")
557-
vm_console.expect("dd: writing 'file': No space left on device", timeout=TIMEOUT_1MIN)
561+
vm_console.sendline("dd if=/dev/urandom of=file bs=1M")
562+
vm_console.expect("No space left on device", timeout=TIMEOUT_1MIN)
558563

559564

560565
@pytest.mark.destructive

tests/storage/cdi_upload/test_upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def test_successful_upload_with_supported_formats(
188188
{
189189
"dv_name": "cnv-2018",
190190
"source": "upload",
191-
"dv_size": "3Gi",
191+
"dv_size": Images.Cirros.DEFAULT_DV_SIZE,
192192
"wait": False,
193193
},
194194
marks=(pytest.mark.polarion("CNV-2018")),

tests/storage/cdi_upload/test_upload_virtctl.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_successful_virtctl_upload_no_url(namespace, tmpdir):
6767
with virtctl_upload_dv(
6868
namespace=namespace.name,
6969
name=pvc_name,
70-
size="1Gi",
70+
size=DEFAULT_DV_SIZE,
7171
storage_class=py_config["default_storage_class"],
7272
image_path=local_name,
7373
insecure=True,
@@ -120,7 +120,7 @@ def test_image_upload_with_overridden_url(
120120
with virtctl_upload_dv(
121121
namespace=namespace.name,
122122
name=pvc_name,
123-
size="1Gi",
123+
size=DEFAULT_DV_SIZE,
124124
storage_class=py_config["default_storage_class"],
125125
image_path=local_name,
126126
insecure=True,
@@ -144,7 +144,7 @@ def test_virtctl_image_upload_with_ca(
144144
with virtctl_upload_dv(
145145
namespace=namespace.name,
146146
name=pvc_name,
147-
size="1Gi",
147+
size=DEFAULT_DV_SIZE,
148148
storage_class=py_config["default_storage_class"],
149149
image_path=local_path,
150150
) as res:
@@ -263,7 +263,7 @@ def test_virtctl_image_upload_with_exist_dv(download_image, namespace, storage_c
263263
source="upload",
264264
dv_name=dv_name,
265265
namespace=namespace.name,
266-
size="1Gi",
266+
size=DEFAULT_DV_SIZE,
267267
storage_class=storage_class_name_scope_module,
268268
) as dv:
269269
dv.wait_for_status(status=DataVolume.Status.UPLOAD_READY, timeout=120)
@@ -295,7 +295,7 @@ def empty_pvc(
295295
storage_class=storage_class_name_scope_module,
296296
volume_mode=storage_class_matrix__module__[storage_class_name_scope_module]["volume_mode"],
297297
accessmodes=storage_class_matrix__module__[storage_class_name_scope_module]["access_mode"],
298-
size="1Gi",
298+
size=DEFAULT_DV_SIZE,
299299
hostpath_node=worker_node1.name
300300
if sc_is_hpp_with_immediate_volume_binding(sc=storage_class_name_scope_module)
301301
else None,

tests/storage/test_cdi_certificate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_upload_after_certs_renewal(
194194
with virtctl_upload_dv(
195195
namespace=namespace.name,
196196
name=dv_name,
197-
size="1Gi",
197+
size=Images.Cirros.DEFAULT_DV_SIZE,
198198
image_path=LOCAL_QCOW2_IMG_PATH,
199199
storage_class=storage_class_name_immediate_binding_scope_module,
200200
insecure=True,
@@ -213,7 +213,7 @@ def test_upload_after_certs_renewal(
213213
{
214214
"dv_name": "dv-source",
215215
"image": f"{Images.Cirros.DIR}/{Images.Cirros.QCOW2_IMG}",
216-
"dv_size": "1Gi",
216+
"dv_size": Images.Cirros.DEFAULT_DV_SIZE,
217217
"wait": True,
218218
},
219219
),
@@ -258,7 +258,7 @@ def test_upload_after_validate_aggregated_api_cert(
258258
with virtctl_upload_dv(
259259
namespace=namespace.name,
260260
name=dv_name,
261-
size="1Gi",
261+
size=Images.Cirros.DEFAULT_DV_SIZE,
262262
image_path=LOCAL_QCOW2_IMG_PATH,
263263
storage_class=storage_class_name_immediate_binding_scope_module,
264264
insecure=True,
@@ -314,7 +314,7 @@ def test_cert_exposure_rotation(
314314
with virtctl_upload_dv(
315315
namespace=namespace.name,
316316
name="cnv-5708",
317-
size="1Gi",
317+
size=Images.Cirros.DEFAULT_DV_SIZE,
318318
storage_class=py_config["default_storage_class"],
319319
image_path=downloaded_cirros_image,
320320
insecure=False,

tests/storage/test_disk_preallocation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_preallocation_dv(
114114
"dv_name": "cnv-5513",
115115
"source": "http",
116116
"image": f"{Images.Cirros.DIR}/{Images.Cirros.QCOW2_IMG}",
117-
"dv_size": "100Mi",
117+
"dv_size": Images.Cirros.DEFAULT_DV_SIZE,
118118
},
119119
marks=pytest.mark.polarion("CNV-5513"),
120120
),
@@ -142,7 +142,7 @@ def test_preallocation_globally_dv_spec_without_preallocation(
142142
"dv_name": "cnv-5741",
143143
"source": "http",
144144
"image": f"{Images.Cirros.DIR}/{Images.Cirros.QCOW2_IMG}",
145-
"dv_size": "200Mi",
145+
"dv_size": Images.Cirros.DEFAULT_DV_SIZE,
146146
"preallocation": False,
147147
},
148148
marks=pytest.mark.polarion("CNV-5741"),

tests/storage/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def upload_image_to_dv(dv_name, storage_ns_name, storage_class, client, consume_
8686
source="upload",
8787
dv_name=dv_name,
8888
namespace=storage_ns_name,
89-
size="3Gi",
89+
size=Images.Cirros.DEFAULT_DV_SIZE,
9090
storage_class=storage_class,
9191
client=client,
9292
consume_wffc=consume_wffc,

utilities/console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(
4848
self.timeout = timeout
4949
self.child = None
5050
self.login_prompt = "login:"
51-
self.prompt = prompt if prompt else [r"\$"]
51+
self.prompt = prompt if prompt else [r"#", r"\$"]
5252
self.cmd = self._generate_cmd()
5353
self.base_dir = get_data_collector_base_directory()
5454

utilities/constants.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
# OS constants
4646
OS_FLAVOR_CIRROS = "cirros"
47+
OS_FLAVOR_ALPINE = "alpine"
4748
OS_FLAVOR_WINDOWS = "win"
4849
OS_FLAVOR_RHEL = "rhel"
4950
OS_FLAVOR_FEDORA = "fedora"
@@ -52,7 +53,7 @@
5253
class ArchImages:
5354
class X86_64: # noqa: N801
5455
BASE_CIRROS_NAME = "cirros-0.4.0-x86_64-disk"
55-
BASE_ALPINE_NAME = "alpine-3.20.1-x86_64-disk"
56+
BASE_ALPINE_NAME = "alpine-x86_64-disk"
5657
Cirros = Cirros(
5758
RAW_IMG=f"{BASE_CIRROS_NAME}.raw",
5859
RAW_IMG_GZ=f"{BASE_CIRROS_NAME}.raw.gz",
@@ -109,7 +110,7 @@ class X86_64: # noqa: N801
109110
Cdi = Cdi(QCOW2_IMG="cirros-qcow2.img")
110111

111112
class ARM64:
112-
BASE_ALPINE_NAME = "alpine-3.20.1-aarch64-disk"
113+
BASE_ALPINE_NAME = "alpine-aarch64-disk"
113114
Cirros = Cirros(
114115
RAW_IMG_XZ="cirros-0.4.0-aarch64-disk.raw.xz",
115116
)
@@ -130,7 +131,7 @@ class ARM64:
130131
Cdi = Cdi()
131132

132133
class S390X:
133-
BASE_ALPINE_NAME = "alpine-3.20.1-s390x-disk"
134+
BASE_ALPINE_NAME = "alpine-s390x-disk"
134135
Cirros = Cirros(
135136
# TODO: S390X does not support Cirros; this is a workaround until tests are moved to Fedora
136137
RAW_IMG="Fedora-Cloud-Base-Generic-41-1.4.s390x.raw",

utilities/unittests/test_console.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_console_init_with_defaults(self, mock_vm_no_namespace):
2424
assert console.timeout == 30
2525
assert console.child is None
2626
assert console.login_prompt == "login:"
27-
assert console.prompt == [r"\$"]
27+
assert console.prompt == [r"#", r"\$"]
2828

2929
def test_console_init_with_custom_values(self, mock_vm_no_namespace):
3030
"""Test Console initialization with custom values"""
@@ -207,7 +207,7 @@ def test_console_connect_with_username_and_password(self, mock_get_dir):
207207
console.child.sendline.assert_any_call("testuser")
208208
console.child.expect.assert_any_call("Password:")
209209
console.child.sendline.assert_any_call("testpass")
210-
console.child.expect.assert_any_call([r"\$"])
210+
console.child.expect.assert_any_call([r"#", r"\$"])
211211

212212
@patch("console.get_data_collector_base_directory")
213213
def test_console_connect_username_only(self, mock_get_dir):
@@ -251,7 +251,7 @@ def test_console_connect_no_username(self, mock_get_dir):
251251

252252
# Should only send newlines and expect prompt
253253
console.child.send.assert_any_call("\n\n")
254-
console.child.expect.assert_any_call([r"\$"])
254+
console.child.expect.assert_any_call([r"#", r"\$"])
255255
# Should not expect login prompt
256256
login_calls = [call for call in console.child.expect.call_args_list if "login:" in str(call)]
257257
assert len(login_calls) == 0
@@ -274,7 +274,7 @@ def test_console_disconnect_with_username(self, mock_get_dir):
274274
console.disconnect()
275275

276276
console.child.send.assert_any_call("\n\n")
277-
console.child.expect.assert_any_call([r"\$"])
277+
console.child.expect.assert_any_call([r"#", r"\$"])
278278
console.child.send.assert_any_call("exit")
279279
console.child.send.assert_any_call("\n\n")
280280
console.child.expect.assert_any_call("login:")
@@ -297,7 +297,7 @@ def test_console_disconnect_no_username(self, mock_get_dir):
297297
console.disconnect()
298298

299299
console.child.send.assert_any_call("\n\n")
300-
console.child.expect.assert_any_call([r"\$"])
300+
console.child.expect.assert_any_call([r"#", r"\$"])
301301
# Should not send exit command
302302
exit_calls = [call for call in console.child.send.call_args_list if "exit" in str(call)]
303303
assert len(exit_calls) == 0

utilities/virt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
IP_FAMILY_POLICY_PREFER_DUAL_STACK,
5757
LINUX_AMD_64,
5858
LINUX_STR,
59+
OS_FLAVOR_ALPINE,
5960
OS_FLAVOR_CIRROS,
6061
OS_FLAVOR_FEDORA,
6162
OS_FLAVOR_WINDOWS,
@@ -94,7 +95,7 @@
9495
K8S_TAINT = "node.kubernetes.io/unschedulable"
9596
NO_SCHEDULE = "NoSchedule"
9697
CIRROS_IMAGE = "kubevirt/cirros-container-disk-demo:latest"
97-
FLAVORS_EXCLUDED_FROM_CLOUD_INIT = (OS_FLAVOR_WINDOWS, OS_FLAVOR_CIRROS)
98+
FLAVORS_EXCLUDED_FROM_CLOUD_INIT = (OS_FLAVOR_WINDOWS, OS_FLAVOR_CIRROS, OS_FLAVOR_ALPINE)
9899
VM_ERROR_STATUSES = [
99100
VirtualMachine.Status.CRASH_LOOPBACK_OFF,
100101
VirtualMachine.Status.ERROR_UNSCHEDULABLE,

0 commit comments

Comments
 (0)