Exemplo n.º 1
0
 def test_code_other(self):
     assert_report_item_equal(
         lib.response_to_report_item(self.fixture_response_connected(500)),
         (severity.ERROR, report_codes.NODE_COMMUNICATION_ERROR, {
             "node": self.host,
             "command": self.request,
             "reason": "HTTP error: 500"
         }, None))
Exemplo n.º 2
0
 def test_code_404(self):
     assert_report_item_equal(
         lib.response_to_report_item(self.fixture_response_connected(404)),
         (severity.ERROR,
          report_codes.NODE_COMMUNICATION_ERROR_UNSUPPORTED_COMMAND, {
              "node": self.host,
              "command": self.request,
              "reason": "HTTP error: 404"
          }, None))
Exemplo n.º 3
0
 def test_code_400(self):
     assert_report_item_equal(
         lib.response_to_report_item(self.fixture_response_connected(400)),
         (severity.ERROR,
          report_codes.NODE_COMMUNICATION_COMMAND_UNSUCCESSFUL, {
              "node": self.host,
              "command": self.request,
              "reason": self.data.decode("utf-8")
          }, None))
Exemplo n.º 4
0
 def test_code_403(self):
     assert_report_item_equal(
         lib.response_to_report_item(self.fixture_response_connected(403)),
         (severity.ERROR,
          report_codes.NODE_COMMUNICATION_ERROR_PERMISSION_DENIED, {
              "node": self.host,
              "command": self.request,
              "reason": "HTTP error: 403"
          }, None))
Exemplo n.º 5
0
 def assert_running_info_transform(self, run_info, report):
     self.get_primitives_for_state_check.return_value = ["elem1", "elem2"]
     self.get_primitive_roles_with_nodes.return_value = run_info
     assert_report_item_equal(
         state.info_resource_state(self.cluster_state, self.resource_id),
         report)
     self.get_primitives_for_state_check.assert_called_once_with(
         self.cluster_state, self.resource_id, expected_running=True)
     self.get_primitive_roles_with_nodes.assert_called_once_with(
         ["elem1", "elem2"])
Exemplo n.º 6
0
 def test_timedouted(self):
     response = self.fixture_response_not_connected(
         pycurl.E_OPERATION_TIMEOUTED, "err")
     assert_report_item_equal(
         lib.response_to_report_item(response),
         (severity.ERROR, report_codes.NODE_COMMUNICATION_ERROR_TIMED_OUT, {
             "node": self.host,
             "command": self.request,
             "reason": "err"
         }, None))
Exemplo n.º 7
0
 def test_unable_to_connect(self):
     response = self.fixture_response_not_connected(pycurl.E_SEND_ERROR,
                                                    "err")
     assert_report_item_equal(
         lib.response_to_report_item(response),
         (severity.ERROR,
          report_codes.NODE_COMMUNICATION_ERROR_UNABLE_TO_CONNECT, {
              "node": self.host,
              "command": self.request,
              "reason": "err"
          }, None))
Exemplo n.º 8
0
 def test_acl_role_not_found(self):
     assert_report_item_equal(
         lib.acl_error_to_report_item(lib.AclRoleNotFound("id")),
         (
             severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "id": "id",
                 "id_description": "role",
             }
         )
     )
Exemplo n.º 9
0
    def test_transform_error_other(self):
        node = "test_node"
        command = "test_command"
        reason = "test_reason"

        assert_report_item_equal(
            lib.node_communicator_exception_to_report_item(
                lib.NodeCommunicationException(node, command, reason)
            ),
            (
                severity.ERROR,
                report_codes.NODE_COMMUNICATION_ERROR,
                {
                    "node": node,
                    "command": command,
                    "reason": reason,
                }
            )
        )
Exemplo n.º 10
0
    def test_transform_error_404(self):
        node = "test_node"
        command = "test_command"
        reason = "test_reason"

        assert_report_item_equal(
            lib.node_communicator_exception_to_report_item(
                lib.NodeUnsupportedCommandException(node, command, reason)
            ),
            (
                severity.ERROR,
                report_codes.NODE_COMMUNICATION_ERROR_UNSUPPORTED_COMMAND,
                {
                    "node": node,
                    "command": command,
                    "reason": reason,
                }
            )
        )
Exemplo n.º 11
0
    def test_transform_error_403(self):
        node = "test_node"
        command = "test_command"
        reason = "test_reason"

        assert_report_item_equal(
            lib.node_communicator_exception_to_report_item(
                lib.NodePermissionDeniedException(node, command, reason)
            ),
            (
                severity.ERROR,
                report_codes.NODE_COMMUNICATION_ERROR_PERMISSION_DENIED,
                {
                    "node": node,
                    "command": command,
                    "reason": reason,
                }
            )
        )
Exemplo n.º 12
0
    def test_transform_error_400(self):
        node = "test_node"
        command = "test_command"
        reason = "test_reason"

        assert_report_item_equal(
            lib.node_communicator_exception_to_report_item(
                lib.NodeCommandUnsuccessfulException(node, command, reason)
            ),
            (
                severity.ERROR,
                report_codes.NODE_COMMUNICATION_COMMAND_UNSUCCESSFUL,
                {
                    "node": node,
                    "command": command,
                    "reason": reason,
                }
            )
        )