From: Varsha Rao Date: Fri, 14 May 2021 15:29:45 +0000 (+0530) Subject: qa/tasks/nfs: add test to check if cmds fail on not passing required arguments X-Git-Tag: v17.1.0~1956^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=94644d1e5f68a0dc02686cbe826d34751b005f93;p=ceph.git qa/tasks/nfs: add test to check if cmds fail on not passing required arguments Signed-off-by: Varsha Rao --- diff --git a/qa/tasks/cephfs/test_nfs.py b/qa/tasks/cephfs/test_nfs.py index b7390cc12ab35..b6fcd33b492ba 100644 --- a/qa/tasks/cephfs/test_nfs.py +++ b/qa/tasks/cephfs/test_nfs.py @@ -583,3 +583,29 @@ class TestNFS(MgrTestCase): update_with_invalid_values('user_id', 'testing_export', True) update_with_invalid_values('fs_name', 'b', True) self._test_delete_cluster() + + def test_cmds_without_reqd_args(self): + ''' + Test that cmd fails on not passing required arguments + ''' + def exec_cmd_invalid(*cmd): + try: + self._nfs_cmd(*cmd) + self.fail(f"nfs {cmd} command executed successfully without required arguments") + except CommandFailedError as e: + # Command should fail for test to pass + if e.exitstatus != errno.EINVAL: + raise + + exec_cmd_invalid('cluster', 'create') + exec_cmd_invalid('cluster', 'delete') + exec_cmd_invalid('cluster', 'config', 'set') + exec_cmd_invalid('cluster', 'config', 'reset') + exec_cmd_invalid('export', 'create', 'cephfs') + exec_cmd_invalid('export', 'create', 'cephfs', 'a_fs') + exec_cmd_invalid('export', 'create', 'cephfs', 'a_fs', 'clusterid') + exec_cmd_invalid('export', 'ls') + exec_cmd_invalid('export', 'delete') + exec_cmd_invalid('export', 'delete', 'clusterid') + exec_cmd_invalid('export', 'get') + exec_cmd_invalid('export', 'get', 'clusterid')