From a6d646c37423f4e8fc25b21d4e15c2025eaed984 Mon Sep 17 00:00:00 2001 From: Derek D Date: Thu, 14 Nov 2024 13:06:52 +0000 Subject: [PATCH] [#7734] Add tests to ensure iadmin failures exit nonzero --- scripts/irods/test/test_iadmin.py | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/scripts/irods/test/test_iadmin.py b/scripts/irods/test/test_iadmin.py index b83e565034..530c607d4a 100644 --- a/scripts/irods/test/test_iadmin.py +++ b/scripts/irods/test/test_iadmin.py @@ -1685,6 +1685,12 @@ def test_iadmin_mkgroup_returns_correct_error_on_duplicate_group__issue_7599(sel finally: self.admin.run_icommand(['iadmin', 'rmgroup', test_group_name]) + def test_iadmin_exits_nonzero_on_nonexistent_command__issue_7734(self): + # Nonexistent command + ec, _, _ = self.admin.assert_icommand(['iadmin', 'nonexistentcommand'], 'STDERR'); + self.assertNotEqual(ec, 0) + + class Test_Iadmin_Resources(resource_suite.ResourceBase, unittest.TestCase): def setUp(self): @@ -2133,6 +2139,34 @@ def test_modrepl_as_rodsuser(self): if os.path.exists(original_file_path): os.unlink(original_file_path) + def test_iadmin_modrepl_exits_nonzero_on_failure__issue_7734(self): + # Bad parameters to modrepl + ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'foo', 'bar', 'baz'], 'STDERR'); + self.assertNotEqual(ec, 0) + + # Nonexistent data object + ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'logical_path', '/tempZone/object/does/not/exist', 'replica_number', '0', 'DATA_COMMENTS', 'something'], 'STDERR'); + self.assertNotEqual(ec, 0) + + test_file_name = 'test_file_name_issue_7734' + self.admin.assert_icommand(['itouch', test_file_name]) + + # Nonexistent replica number + ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'logical_path', self.admin.session_collection + '/' + test_file_name, 'replica_number', '123', 'DATA_COMMENTS', 'something'], 'STDERR'); + self.assertNotEqual(ec, 0) + + # Invalid replica number + ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'logical_path', self.admin.session_collection + '/' + test_file_name, 'replica_number', 'abc', 'DATA_COMMENTS', 'something'], 'STDERR'); + self.assertNotEqual(ec, 0) + + # Invalid data object ID + ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'data_id', 'abc', 'replica_number', '123456789', 'DATA_COMMENTS', 'something'], 'STDERR'); + self.assertNotEqual(ec, 0) + + # Nonexistent data object ID + ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'data_id', '1234567', 'replica_number', '123456789', 'DATA_COMMENTS', 'something'], 'STDERR'); + self.assertNotEqual(ec, 0) + class test_moduser_user(unittest.TestCase): """Test modifying a user.""" @classmethod