@@ -109,30 +109,42 @@ def test_copy_data_set_or_member_should_be_possible(self):
109109 self .assertTrue (command_output == None )
110110
111111 def test_mount_unmount_zfs_file_system (self ):
112- """Mounting a zfs filesystem should be possible"""
113- username = self .user_name .lower ()
112+ """Test mounting and unmounting, with safety nets."""
114113 mount_point = self .files_fixtures ["TEST_USS_MOUNT" ]
114+
115+ # Create and register safety cleanup
116+ self .files .fs .create (self .test2_zfs_file_system , self .create_zfs_options )
117+ self .addCleanup (self ._safe_delete_fs , self .test2_zfs_file_system )
115118
116- # Create a zfs file system
117- zfs_file_system = self .files .fs .create (self .test2_zfs_file_system , self .create_zfs_options )
119+ # Mount and register safety cleanup
120+ self .files .fs .mount (self .test2_zfs_file_system , mount_point , self .mount_zfs_file_system_options )
121+ self .addCleanup (self ._safe_unmount_fs , self .test2_zfs_file_system )
118122
119- # Mount file system
120- command_output = self .files .fs .mount (
121- self .test2_zfs_file_system , mount_point , self .mount_zfs_file_system_options
122- )
123- self .assertTrue (command_output == None )
124-
125- # List a zfs file system
123+ # Verify mount success
126124 command_output = self .files .fs .list (file_system_name = self .test2_zfs_file_system .upper ())
127- self .assertTrue (len (command_output ["items" ]) > 0 )
128-
129- # Unmount file system
130- command_output = self .files .fs .unmount (self .test2_zfs_file_system )
131- self .assertTrue (command_output == None )
132-
133- # Delete file system
134- command_output = self .files .fs .delete (self .test2_zfs_file_system )
135- self .assertTrue (command_output == None )
125+ self .assertGreater (len (command_output ["items" ]), 0 )
126+
127+ # Verify unmount success
128+ unmount_response = self .files .fs .unmount (self .test2_zfs_file_system )
129+ self .assertIsNone (unmount_response )
130+
131+ # Verify delete success
132+ delete_response = self .files .fs .delete (self .test2_zfs_file_system )
133+ self .assertIsNone (delete_response )
134+
135+ def _safe_unmount_fs (self , fs_name ):
136+ """Idempotent helper: Unmounts but ignores errors if already unmounted."""
137+ try :
138+ self .files .fs .unmount (fs_name )
139+ except Exception :
140+ pass
141+
142+ def _safe_delete_fs (self , fs_name ):
143+ """Idempotent helper: Deletes but ignores errors if already deleted."""
144+ try :
145+ self .files .fs .delete (fs_name )
146+ except Exception :
147+ pass
136148
137149 def test_upload_download_delete_dataset (self ):
138150 self .files .ds .upload_file (SAMPLE_JCL_FIXTURE_PATH , self .test_ds_upload )
0 commit comments