sssd_test_framework.utils.automount
Testing autofs/automount.
Classes
|
Methods for testing automount. |
- class sssd_test_framework.utils.automount.AutomountUtils(*args, **kwargs)
Bases:
MultihostUtility[MultihostHost]Methods for testing automount.
Example usage@pytest.mark.topology(KnownTopologyGroup.AnyProvider) def test_example_(client: Client, provider: GenericProvider, nfs: NFS): nfs_export1 = nfs.export('export1').add() nfs_export2 = nfs.export('export2').add() nfs_export3 = nfs.export('sub/export3').add() # Create automount maps auto_master = provider.automount.map('auto.master').add() auto_home = provider.automount.map('auto.home').add() auto_sub = provider.automount.map('auto.sub').add() # Create mount points auto_master.key('/ehome').add(info=auto_home) auto_master.key('/esub/sub1/sub2').add(info=auto_sub) # Create mount keys key1 = auto_home.key('export1').add(info=nfs_export1) key2 = auto_home.key('export2').add(info=nfs_export2) key3 = auto_sub.key('export3').add(info=nfs_export3) # Start SSSD client.sssd.common.autofs() client.sssd.start() # Reload automounter in order to fetch updated maps client.automount.reload() # Check that we can mount all directories on correct locations assert client.automount.mount('/ehome/export1', nfs_export1) assert client.automount.mount('/ehome/export2', nfs_export2) assert client.automount.mount('/esub/sub1/sub2/export3', nfs_export3) # Check that the maps are correctly fetched assert client.automount.dumpmaps() == { '/ehome': { 'map': 'auto.home', 'keys': [str(key1), str(key2)] }, '/esub/sub1/sub2': { 'map': 'auto.sub', 'keys': [str(key3)] }, }
Note
All changes are automatically reverted when a test is finished.
- Parameters:
host (MultihostHost) – Remote host instance.
- reload() None
Reload autofs maps.
- mount(path: str, export: NFSExport) bool
Try to mount the autofs directory by accessing it. Returns
Trueif the mount was successful,Falseotherwise.- Parameters:
path (str) – Path to the autofs mount point.
export (NFSExport) – Expected NFS location that should be mounted on the mount point.
- Returns:
Trueif the mount was successful,Falseotherwise.- Return type:
bool
- dumpmaps() dict[str, dict[str, str | list[str]]]
Calls
automount -m, parses its output into a dictionary and returns the dictionary.Dictionary format{ '$mountpoint': { 'map': '$mapname', 'keys': ['$key1', '$key2'] } }
Example{ '/ehome': { 'map': 'auto.home', 'keys': [ 'export1 | -fstype=nfs,rw,sync,no_root_squash nfs.test:/dev/shm/exports/export1', 'export2 | -fstype=nfs,rw,sync,no_root_squash nfs.test:/dev/shm/exports/export2' ] }, '/esub/sub1/sub2': { 'map': 'auto.sub', 'keys': ['export3 | -fstype=nfs,rw,sync,no_root_squash nfs.test:/dev/shm/exports/sub/export3'] }, }
Note
Only mountpoints defined by SSSD are present in the output.
- Returns:
Parsed
automount -moutput.- Return type:
dict[str, dict[str, list[str]]]