That module-handled commands have appropriate behavior on disabled/failed/recently-enabled modules.
(self)
| 146 | self.assertEqual(original_standbys, self.mgr_cluster.get_standby_ids()) |
| 147 | |
| 148 | def test_module_commands(self): |
| 149 | """ |
| 150 | That module-handled commands have appropriate behavior on |
| 151 | disabled/failed/recently-enabled modules. |
| 152 | """ |
| 153 | |
| 154 | # Calling a command on a disabled module should return the proper |
| 155 | # error code. |
| 156 | self._load_module("selftest") |
| 157 | self.mgr_cluster.mon_manager.raw_cluster_cmd( |
| 158 | "mgr", "module", "disable", "selftest") |
| 159 | with self.assertRaises(CommandFailedError) as exc_raised: |
| 160 | self.mgr_cluster.mon_manager.raw_cluster_cmd( |
| 161 | "mgr", "self-test", "run") |
| 162 | |
| 163 | self.assertEqual(exc_raised.exception.exitstatus, errno.EOPNOTSUPP) |
| 164 | |
| 165 | # Calling a command that really doesn't exist should give me EINVAL. |
| 166 | with self.assertRaises(CommandFailedError) as exc_raised: |
| 167 | self.mgr_cluster.mon_manager.raw_cluster_cmd( |
| 168 | "osd", "albatross") |
| 169 | |
| 170 | self.assertEqual(exc_raised.exception.exitstatus, errno.EINVAL) |
| 171 | |
| 172 | # Enabling a module and then immediately using ones of its commands |
| 173 | # should work (#21683) |
| 174 | self._load_module("selftest") |
| 175 | self.mgr_cluster.mon_manager.raw_cluster_cmd( |
| 176 | "mgr", "self-test", "config", "get", "testkey") |
| 177 | |
| 178 | # Calling a command for a failed module should return the proper |
| 179 | # error code. |
| 180 | self.mgr_cluster.mon_manager.raw_cluster_cmd( |
| 181 | "mgr", "self-test", "background", "start", "throw_exception") |
| 182 | with self.assertRaises(CommandFailedError) as exc_raised: |
| 183 | self.mgr_cluster.mon_manager.raw_cluster_cmd( |
| 184 | "mgr", "self-test", "run" |
| 185 | ) |
| 186 | self.assertEqual(exc_raised.exception.exitstatus, errno.EIO) |
| 187 | |
| 188 | # A health alert should be raised for a module that has thrown |
| 189 | # an exception from its serve() method |
| 190 | self.wait_for_health( |
| 191 | "Module 'selftest' has failed: Synthetic exception in serve", |
| 192 | timeout=30) |
| 193 | # prune the crash reports, so that the health report is back to |
| 194 | # clean |
| 195 | self.mgr_cluster.mon_manager.raw_cluster_cmd( |
| 196 | "crash", "prune", "0") |
| 197 | self.mgr_cluster.mon_manager.raw_cluster_cmd( |
| 198 | "mgr", "module", "disable", "selftest") |
| 199 | |
| 200 | self.wait_for_health_clear(timeout=30) |
| 201 | |
| 202 | def test_module_remote(self): |
| 203 | """ |
nothing calls this directly
no test coverage detected