New testcase 'verify_smb_linux'#4184
Conversation
|
Depended on PR #4182 |
cfb9c2e to
4ac2dad
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a new test case verify_smb_linux to validate CIFS module and SMB share functionality between two Linux VMs. The test creates two VMs in Azure, configures one as an SMB server and the other as a client, then validates SMB mounting and file I/O operations across multiple SMB versions (2.0, 2.1, 3.0, 3.1.1).
Critical Issue: The test cannot execute as written because it depends on SmbClient and SmbServer tools that do not exist in the codebase. These tools must be implemented before the test can be functional.
Key Changes
- Adds comprehensive SMB/CIFS testing between two Linux VMs
- Tests multiple SMB protocol versions (2.0, 2.1, 3.0, 3.1.1)
- Validates bidirectional file I/O through SMB shares
| timeout=TIME_OUT, | ||
| requirement=simple_requirement( | ||
| min_count=2, | ||
| unsupported_os=[Redhat, CBLMariner, AlmaLinux, BSD, Windows], |
There was a problem hiding this comment.
Why is Redhat, CBLMariner and Alma unsupported?
In the SMBTool, the below line exists
if isinstance(self.node.os, (CBLMariner, Redhat, Fedora, Oracle, Suse)):
There was a problem hiding this comment.
SMB "server" packages are not officially supported by Mariner. Redhat family have issues SELinux etc.
Only Ubuntu, Debian and SUSE are supported for this test case now.
There was a problem hiding this comment.
Only Ubuntu, Debian and SUSE are supported for this test case now.
Do you want to rather use supported_os requirement in that case?
There was a problem hiding this comment.
Redhat has issues because of SELinux, we can't make it work in test code?
Do we have a link for SMB "server" packages are not officially supported by Mariner
| smb_client.unmount_share(mount_point) | ||
| smb_client.cleanup_mount_point(mount_point) | ||
| except Exception as e: | ||
| log.warning( |
There was a problem hiding this comment.
changed to "log.error()"
There was a problem hiding this comment.
Use log.info or log.debug. If you need to exit, you can raise an Exception
| smb_server.stop() | ||
| smb_server.remove_share(share_path) | ||
| except Exception as e: | ||
| log.warning( |
There was a problem hiding this comment.
changed to "log.error()"
| smb_server = server_node.tools[SmbServer] | ||
| smb_server.stop() | ||
| smb_server.remove_share(share_path) | ||
| except Exception as e: |
There was a problem hiding this comment.
If cleanup fails, mark node as dirty
There was a problem hiding this comment.
Fixed as suggested.
| smb_server.create_share(share_name, share_path) | ||
|
|
||
| # Step 8: Repeat for different SMB versions | ||
| for smb_version in smb_versions: |
There was a problem hiding this comment.
In the current logic, if one version fails, the case fails and exits.
Is that the expected? or do you want to verify each version independently?
| for role_name, role_node in (("server", server_node), ("client", client_node)): | ||
| if not role_node.tools[KernelConfig].is_enabled("CONFIG_CIFS"): | ||
| raise LisaException( | ||
| f"CIFS module must be present for SMB testing on {role_name} node" |
There was a problem hiding this comment.
Since we are not printing the node being assigned as server and client, printing the role_name does not add value in the logging.
Do you rather want to print the node name? or I think it's fine to just have it like "CIFS module must be present on the node", as both nodes are identical
There was a problem hiding this comment.
Since both the nodes are identical its okay this way.
There was a problem hiding this comment.
In that case "{role_name}" does not add any value in the logging statement, you can replace it with "CIFS module must be present" ?
|
@SRIKKANTH please make the two PRs into one PR, so that we can validate it. |
Merged both PRs. |
| ) | ||
| bad_cleanup = True | ||
| if bad_cleanup: | ||
| raise BadEnvironmentStateException("SMB test cleanup encountered errors.") |
There was a problem hiding this comment.
raising BadEnvironmentStateException in the case will cause test case failure.
You are running the cleanup in the case itself, hence even if your test logic succeeds, but the cleanup fails, the case will fail.
You can move the cleanup to after case, or ensure that cleanup does not raise an Exception within the case.
If you are moving the cleanup to after case, use self.node.mark_dirty() because BadEnvironmentStateException does not mark the env as dirty in after case
| # Install client utilities | ||
| if isinstance( | ||
| self.node.os, | ||
| (Ubuntu, Debian, CBLMariner, CoreOs, Fedora, Oracle, Redhat, Suse, Alpine), |
There was a problem hiding this comment.
The _install method for SmbClient includes CBLMariner in the supported distributions list, but the test case excludes CBLMariner in its requirements (line 624 of storage.py). This creates an inconsistency in which distributions are actually supported for SMB client functionality.
| (Ubuntu, Debian, CBLMariner, CoreOs, Fedora, Oracle, Redhat, Suse, Alpine), | |
| (Ubuntu, Debian, CoreOs, Fedora, Oracle, Redhat, Suse, Alpine), |
| mount_options = [ | ||
| f"vers={smb_version}", | ||
| "file_mode=0777", | ||
| "dir_mode=0777", | ||
| "guest", | ||
| ] | ||
|
|
There was a problem hiding this comment.
The mount options use hardcoded permissions (file_mode=0777, dir_mode=0777) which create a security risk. Consider making these configurable via the options parameter or using more restrictive defaults like 0755.
| mount_options = [ | |
| f"vers={smb_version}", | |
| "file_mode=0777", | |
| "dir_mode=0777", | |
| "guest", | |
| ] | |
| mount_options: List[str] = [ | |
| f"vers={smb_version}", | |
| "guest", | |
| ] | |
| # Apply default permissions only if not specified by caller | |
| caller_options = options or [] | |
| if not any(opt.startswith("file_mode=") for opt in caller_options): | |
| mount_options.append("file_mode=0755") | |
| if not any(opt.startswith("dir_mode=") for opt in caller_options): | |
| mount_options.append("dir_mode=0755") |
| unsupported_os=[Redhat, CBLMariner, AlmaLinux, BSD, Windows], | ||
| ), |
There was a problem hiding this comment.
The test excludes Redhat, CBLMariner, and AlmaLinux from the supported_os list, but there's no clear documentation explaining why these distributions are unsupported. Consider adding a comment explaining the technical reason (e.g., package availability issues, known bugs, or version compatibility problems) to help future maintainers understand this decision.
| elif isinstance(self.node.os, (Debian, CoreOs, Fedora, Oracle, Redhat, Suse)): | ||
| self.node.os.install_packages(["samba", "cifs-utils"]) |
There was a problem hiding this comment.
The _install method includes CBLMariner in the installation logic, but the test case explicitly excludes CBLMariner in its requirements (line 624 of storage.py). Either CBLMariner should be removed from this installation list to match the test requirements, or the test should support CBLMariner. This inconsistency could lead to confusion about which distributions are actually supported.
| # Set permissions for the share directory | ||
| self.node.tools[Chmod].chmod(share_path, "777", sudo=True) |
There was a problem hiding this comment.
Setting directory permissions to 777 creates a security risk by allowing any user to read, write, and execute files in the share directory. While this might be acceptable for testing purposes, consider using more restrictive permissions (e.g., 755 or 775) and document the security implications, especially if this code could be used as a reference for production setups.
| # Set permissions for the share directory | |
| self.node.tools[Chmod].chmod(share_path, "777", sudo=True) | |
| # Set permissions for the share directory. | |
| # Use 775 to avoid world-writable permissions (777) while still | |
| # allowing group members to write to the share directory. | |
| self.node.tools[Chmod].chmod(share_path, "775", sudo=True) |
b58aa41 to
8a9b6c4
Compare
❌ AI Test Selection — FAILED74 test case(s) selected (view run) Marketplace image: suse sles-15-sp6 gen2 latest
Test case details
|
| self.node.tools[Echo].write_to_file( | ||
| smb_config, PurePosixPath(self.SMB_CONF_FILE), sudo=True |
| # stop firewall to allow SMB traffic | ||
| self.node.tools[Firewall].stop() | ||
|
|
| # Check if CONFIG_CIFS is enabled in KCONFIG on both nodes | ||
| for role_node in (server_node, client_node): | ||
| if not role_node.tools[KernelConfig].is_enabled("CONFIG_CIFS"): | ||
| raise LisaException( | ||
| "CIFS module must be present for SMB testing" | ||
| ) |
| # Step 7: Cleanup between version tests | ||
| try: | ||
| smb_client.unmount_share(mount_point) | ||
| except Exception: | ||
| pass |
|
| Count | |
|---|---|
| ✅ Passed | 23 |
| ❌ Failed | 2 |
| ⏭️ Skipped | 4 |
| Total | 29 |
Test case details
| Test Case | Status | Time (s) | Message |
|---|---|---|---|
| smoke_test_check_serial_console_pattern (lisa_0_2) | ✅ PASSED | 56.737 | |
| verify_deployment_provision_standard_ssd_disk (lisa_0_4) | ✅ PASSED | 58.105 | |
| verify_deployment_provision_synthetic_nic (lisa_0_3) | ✅ PASSED | 50.684 | |
| smoke_test (lisa_0_1) | ✅ PASSED | 77.132 | |
| verify_deployment_provision_ephemeral_managed_disk (lisa_0_5) | ✅ PASSED | 54.225 | |
| verify_deployment_provision_premium_disk (lisa_0_6) | ✅ PASSED | 56.054 | |
| verify_vmbus_devices_channels_bsd (lisa_0_14) | ⏭️ SKIPPED | 0.000 | check skipped: OS type mismatch: ["requires [<class 'lisa.operating_system.BSD'>] but VM supports [<class 'lisa.operatin |
| verify_serial_console (lisa_0_0) | ✅ PASSED | 42.157 | |
| verify_default_targetpw (lisa_0_36) | ✅ PASSED | 7.713 | |
| verify_grub (lisa_0_37) | ✅ PASSED | 4.658 | |
| verify_network_file_configuration (lisa_0_39) | ⏭️ SKIPPED | 1.592 | skipped: unsupported distro type: <class 'lisa.operating_system.SLES'> |
| verify_ifcfg_eth0 (lisa_0_40) | ⏭️ SKIPPED | 0.279 | skipped: unsupported distro type: <class 'lisa.operating_system.SLES'> |
| verify_udev_rules_moved (lisa_0_41) | ⏭️ SKIPPED | 0.353 | skipped: Unsupported distro type : <class 'lisa.operating_system.SLES'> |
| verify_dhcp_file_configuration (lisa_0_42) | ✅ PASSED | 2.260 | |
| verify_repository_installed (lisa_0_46) | ✅ PASSED | 32.718 | |
| verify_serial_console_is_enabled (lisa_0_47) | ✅ PASSED | 2.555 | |
| verify_no_pre_exist_users (lisa_0_52) | ✅ PASSED | 4.342 | |
| verify_resource_disk_file_system (lisa_0_54) | ✅ PASSED | 8.699 | |
| verify_waagent_version (lisa_0_55) | ✅ PASSED | 0.258 | |
| verify_python_version (lisa_0_56) | ❌ FAILED | 1.890 | failed. LisaException: The Python version 3.6.15 is lower than the required version 3.9. Please update Python to a versi |
| verify_openssl_version (lisa_0_57) | ✅ PASSED | 1.934 | |
| verify_azure_64bit_os (lisa_0_58) | ✅ PASSED | 2.074 | |
| verify_omi_version (lisa_0_59) | ✅ PASSED | 2.718 | |
| verify_no_swap_on_osdisk (lisa_0_60) | ✅ PASSED | 1.897 | |
| verify_essential_kernel_modules (lisa_0_61) | ❌ FAILED | 2.805 | failed. AssertionError: [Not enabled essential kernel modules for Hyper-V / Azure platform found.] Expected <['wdt']> to |
| verify_l3_cache (lisa_0_33) | ✅ PASSED | 2.070 | |
| verify_cpu_count (lisa_0_34) | ✅ PASSED | 0.237 | |
| verify_dhcp_client_timeout (lisa_0_22) | ✅ PASSED | 3.121 | |
| verify_dns_name_resolution (lisa_0_71) | ✅ PASSED | 3.171 |
❌ AI Test Selection — FAILED74 test case(s) selected (view run) Marketplace image: suse sles-15-sp6 gen2 latest
Test case details
|
b76d302 to
d3374d2
Compare
| smb_config = f""" | ||
| [global] | ||
| workgroup = {workgroup} | ||
| server string = {server_string} | ||
| security = user | ||
| map to guest = bad user | ||
| dns proxy = no | ||
|
|
||
| [{share_name}] | ||
| path = {share_path} | ||
| browsable = yes | ||
| writable = yes | ||
| guest ok = yes | ||
| guest only = yes | ||
| read only = no | ||
| create mask = 0666 | ||
| directory mask = 0777 | ||
| """ |
| # Write SMB configuration | ||
| self.node.tools[Echo].write_to_file( | ||
| smb_config, PurePosixPath(self.SMB_CONF_FILE), sudo=True | ||
| ) |
| failed_versions.append(smb_version) | ||
| finally: | ||
| # Step 7: Cleanup between version tests | ||
| try: | ||
| smb_client.unmount_share(mount_point) | ||
| except Exception: |
New testcase 'verify_smb_linux' A test to verify CIFS module and SMB share functionality between two Linux VMs. SMB server and client tools are added which are useful in validating samba file share with Linux OS and CIFS module in kernel.
d8abd87 to
de1e2fd
Compare
|
❌ AI Test Selection — FAILED74 test case(s) selected (view run) Marketplace image: suse sles-15-sp6 gen2 latest
Test case details
|
|
Created a fresh PR with all the above comments above. |
A comprehensive test to verify CIFS module and SMB share functionality between two Linux VMs.