-
Notifications
You must be signed in to change notification settings - Fork 236
New testcase 'verify_smb_linux' for CIFS module validation #4503
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
Open
SRIKKANTH
wants to merge
11
commits into
main
Choose a base branch
from
smyakam/verify_smb_linux/2026_05_29
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+422
−2
Open
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
aa54983
New testcase 'verify_smb_linux'
SRIKKANTH 7d03a8d
flake issue fix
SRIKKANTH a01601e
comments addressed
SRIKKANTH ca3e63c
Potential fix for pull request finding
SRIKKANTH 9a85a9d
Potential fix for pull request finding
SRIKKANTH 3b3148d
flake8
SRIKKANTH d4bb1b5
Merge branch 'smyakam/verify_smb_linux/2026_05_29' of https://github.…
SRIKKANTH a20ecfc
Address comments
SRIKKANTH 5deeb3b
Update storage.py
SRIKKANTH 7ec9e33
Update storage.py
SRIKKANTH 5d17808
Update storage.py
SRIKKANTH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ | |
| SecurityProfileType, | ||
| ) | ||
| from lisa.node import Node | ||
| from lisa.operating_system import BSD, Fedora, Posix, Windows | ||
| from lisa.operating_system import BSD, Debian, Fedora, Posix, Windows | ||
| from lisa.schema import DiskControllerType, DiskOptionSettings, DiskType | ||
| from lisa.sut_orchestrator import AZURE, HYPERV | ||
| from lisa.sut_orchestrator.azure.features import ( | ||
|
|
@@ -42,7 +42,21 @@ | |
| FileShareProtocol, | ||
| ) | ||
| from lisa.sut_orchestrator.azure.tools import Waagent | ||
| from lisa.tools import Blkid, Cat, Dmesg, Echo, Lsblk, Mount, NFSClient, Swap, Sysctl | ||
| from lisa.tools import ( | ||
| Blkid, | ||
| Cat, | ||
| Dmesg, | ||
| Echo, | ||
| Ls, | ||
| Lsblk, | ||
| Mount, | ||
| NFSClient, | ||
| Rm, | ||
| SmbClient, | ||
| SmbServer, | ||
| Swap, | ||
| Sysctl, | ||
| ) | ||
| from lisa.tools.blkid import PartitionInfo | ||
| from lisa.tools.journalctl import Journalctl | ||
| from lisa.tools.kernel_config import KernelConfig | ||
|
|
@@ -659,6 +673,205 @@ def after_case(self, log: Logger, **kwargs: Any) -> None: | |
| except Exception: | ||
| raise BadEnvironmentStateException | ||
|
|
||
| @TestCaseMetadata( | ||
| description=""" | ||
| A comprehensive test to verify CIFS module and SMB share functionality between | ||
| two Linux VMs. | ||
| This test case will | ||
| 1. Create 2 VMs in Azure | ||
| 2. Check if CONFIG_CIFS is enabled in KCONFIG | ||
| 3. Configure one VM as SMB server and create a share | ||
| 4. Mount the other VM to the SMB share | ||
| 5. Verify mount is successful | ||
| 6. Write a test file to the SMB share and read it back to verify IO | ||
| 7. Clean up the SMB share and unmount | ||
| 8. repeat steps 4-7 for SMB versions ["2.0", "2.1", "3.0", "3.1.1"] | ||
| """, | ||
| timeout=TIME_OUT, | ||
| requirement=simple_requirement( | ||
| min_count=2, | ||
| supported_os=[Debian], | ||
| ), | ||
|
SRIKKANTH marked this conversation as resolved.
|
||
| priority=1, | ||
| ) | ||
| def verify_smb_linux( | ||
| self, log: Logger, node: Node, environment: Environment | ||
| ) -> None: | ||
| # Assign server and client roles to the 2 VMs | ||
| server_node = cast(RemoteNode, environment.nodes[0]) | ||
| client_node = cast(RemoteNode, environment.nodes[1]) | ||
|
|
||
| # 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") | ||
| # Install and setup SMB tools on both nodes | ||
| smb_server = server_node.tools[SmbServer] | ||
| smb_client = client_node.tools[SmbClient] | ||
|
|
||
| # SMB versions to test | ||
| smb_versions = ["3.0", "3.1.1", "2.1", "2.0"] | ||
|
|
||
| # Test configuration | ||
| share_name = "testshare" | ||
| share_path = f"/tmp/{share_name}" | ||
| mount_point = f"/mnt/{share_name}" | ||
|
|
||
| failed_versions: List[str] = [] | ||
| try: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This try doesn't have except.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed as suggeested |
||
| # Step 3: Configure SMB server and create a share | ||
| smb_server.create_share(share_name, share_path) | ||
|
|
||
| # Step 8: Repeat for different SMB versions | ||
| for smb_version in smb_versions: | ||
| log.info(f"Testing SMB version {smb_version}") | ||
| try: | ||
| # Step 4: Mount the SMB share on client | ||
| smb_client.mount_share( | ||
| server_node.internal_address, | ||
| share_name, | ||
| mount_point, | ||
| smb_version, | ||
| ) | ||
|
|
||
| # Step 5 & 6: Verify mount is successful | ||
| self._verify_smb_mount( | ||
| client_node, | ||
| mount_point, | ||
| server_node, | ||
| share_path, | ||
| log, | ||
| ) | ||
| except (LisaException, AssertionError) as e: | ||
| log.info(f"SMB version {smb_version} failed: {e}") | ||
| failed_versions.append(smb_version) | ||
| finally: | ||
| # Step 7: Cleanup between version tests | ||
| try: | ||
| smb_client.unmount_share(mount_point) | ||
| except LisaException as e: | ||
| log.info( | ||
| f"Failed to unmount SMB share for version " | ||
| f"{smb_version}: {e}" | ||
| ) | ||
| client_node.mark_dirty() | ||
| except (LisaException, AssertionError): | ||
| log.info( | ||
| "SMB Linux test failed due to unexpected error. See logs for details." | ||
| ) | ||
| client_node.mark_dirty() | ||
|
SRIKKANTH marked this conversation as resolved.
Outdated
|
||
| finally: | ||
| # Cleanup | ||
| self._cleanup_smb_test( | ||
| server_node, client_node, share_path, mount_point, log | ||
| ) | ||
|
|
||
| if failed_versions: | ||
| raise LisaException( | ||
| f"SMB test failed for versions: {', '.join(failed_versions)}" | ||
| ) | ||
|
|
||
| def _verify_smb_mount( | ||
| self, | ||
| client_node: RemoteNode, | ||
| mount_point: str, | ||
| server_node: RemoteNode, | ||
| share_path: str, | ||
| log: Logger, | ||
| ) -> None: | ||
| """ | ||
| Verify SMB mount is working by creating and reading a file from | ||
| both client and server. | ||
| """ | ||
| test_file = "smb_test.txt" | ||
| test_content = "SMB test content" | ||
| mount = client_node.tools[Mount] | ||
|
|
||
| # Verify mount point exists and is mounted | ||
| mount_point_exists = mount.check_mount_point_exist(mount_point) | ||
| if not mount_point_exists: | ||
| raise LisaException( | ||
| f"Mount point {mount_point} does not exist or is not mounted" | ||
| ) | ||
|
|
||
| # Create test file on mounted share from client | ||
| test_file_path = f"{mount_point}/{test_file}" | ||
| echo = client_node.tools[Echo] | ||
| echo.write_to_file( | ||
| test_content, | ||
| client_node.get_pure_path(test_file_path), | ||
| sudo=True, | ||
| ignore_error=False, | ||
| ) | ||
|
|
||
| # Read and verify file content from client side | ||
| file_content_client = client_node.tools[Cat].read( | ||
| test_file_path, sudo=True, force_run=True | ||
| ).rstrip("\n") | ||
|
|
||
| assert_that(file_content_client.strip()).described_as( | ||
| "SMB file content should match written content on client" | ||
| ).is_equal_to(test_content) | ||
| log.info(f"Successfully verified file content on client: '{test_content}'") | ||
|
|
||
| # Read and verify file content from server side | ||
| # Verify content from server VM | ||
| server_file_path = f"{share_path}/{test_file}" | ||
|
|
||
| # Check if file exists on server | ||
| if not server_node.tools[Ls].path_exists(server_file_path, sudo=True): | ||
| raise LisaException(f"Test file {server_file_path} not found on server VM") | ||
|
|
||
| # Read file content directly from server VM | ||
| file_content_server = server_node.tools[Cat].read( | ||
| server_file_path, sudo=True, force_run=True | ||
| ).rstrip("\n") | ||
|
|
||
| assert_that(file_content_server.strip()).described_as( | ||
| "SMB file content should match on server VM" | ||
| ).is_equal_to(test_content) | ||
|
|
||
| log.info( | ||
| f"Successfully verified file content on both client and server: " | ||
| f"'{test_content}'" | ||
| ) | ||
| # Clean up test file from client (will also remove from server via SMB) | ||
| client_node.tools[Rm].remove_file(test_file_path, sudo=True) | ||
|
|
||
| def _cleanup_smb_test( | ||
| self, | ||
| server_node: RemoteNode, | ||
| client_node: RemoteNode, | ||
| share_path: str, | ||
| mount_point: str, | ||
| log: Logger, | ||
| ) -> None: | ||
| """Clean up SMB test resources.""" | ||
| # Cleanup on client | ||
| try: | ||
| smb_client = client_node.tools[SmbClient] | ||
| if smb_client.is_mounted(mount_point): | ||
| smb_client.unmount_share(mount_point) | ||
| smb_client.cleanup_mount_point(mount_point) | ||
| except LisaException as e: | ||
| log.info( | ||
| f"Failed to cleanup SMB client mount point {mount_point}: " | ||
| f"{e}. Continuing cleanup..." | ||
| ) | ||
| client_node.mark_dirty() | ||
|
|
||
| # Cleanup on server | ||
| try: | ||
| smb_server = server_node.tools[SmbServer] | ||
| smb_server.stop() | ||
| smb_server.remove_share(share_path) | ||
| except LisaException as e: | ||
| log.info( | ||
| f"Failed to remove share {share_path} from SMB server: " | ||
| f"{e}. Finishing cleanup..." | ||
| ) | ||
| server_node.mark_dirty() | ||
|
|
||
| @TestCaseMetadata( | ||
| description=""" | ||
| This test case will | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| "mkfs", | ||
| [ | ||
| "xfs", | ||
| "cifs", | ||
| "ext2", | ||
| "ext3", | ||
| "ext4", | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.