示例#1
0
    def test_message_processed_with_callback(self):

        callback = Mock()
        scaling_response = DynamiteScalingResponse.from_json_string(
            self.test_json, message_processed_callback=callback)
        scaling_response.message_processed()
        callback.assert_called_once_with()
 def test_from_json_string(self):
     scaling_response = DynamiteScalingResponse.from_json_string(self.test_json)
     assert scaling_response.command == DynamiteScalingCommand.SCALE_DOWN
     assert scaling_response.service_instance_name == "apache_service_instance_name"
     assert scaling_response.service_name == "apache_service_name"
     assert scaling_response.failure_counter == 4
     assert scaling_response.success is True
示例#3
0
 def test_from_json_string(self):
     scaling_response = DynamiteScalingResponse.from_json_string(
         self.test_json)
     assert scaling_response.command == DynamiteScalingCommand.SCALE_DOWN
     assert scaling_response.service_instance_name == "apache_service_instance_name"
     assert scaling_response.service_name == "apache_service_name"
     assert scaling_response.failure_counter == 4
     assert scaling_response.success is True
    def test_to_json_string(self):
        scaling_response = DynamiteScalingResponse()
        scaling_response.command = DynamiteScalingCommand.SCALE_DOWN
        scaling_response.failure_counter = 4
        scaling_response.service_instance_name = "apache_service_instance_name"
        scaling_response.service_name = "apache_service_name"
        scaling_response.success = False
        scaling_response.message_processed_callback = lambda: None

        result_json = scaling_response.to_json_string()
        result_response = DynamiteScalingResponse.from_json_string(result_json, scaling_response.message_processed_callback)
        assert result_response == scaling_response
示例#5
0
    def test_to_json_string(self):
        scaling_response = DynamiteScalingResponse()
        scaling_response.command = DynamiteScalingCommand.SCALE_DOWN
        scaling_response.failure_counter = 4
        scaling_response.service_instance_name = "apache_service_instance_name"
        scaling_response.service_name = "apache_service_name"
        scaling_response.success = False
        scaling_response.message_processed_callback = lambda: None

        result_json = scaling_response.to_json_string()
        result_response = DynamiteScalingResponse.from_json_string(
            result_json, scaling_response.message_processed_callback)
        assert result_response == scaling_response
    def receive(self):
        messages = ()

        if self._process_queue.empty():
            return messages

        received_scaling_response_string = self._process_queue.get()

        scaling_response = DynamiteScalingResponse.from_json_string(
            received_scaling_response_string,
            message_processed_callback=lambda: None
        )
        self._logger.info("Received scaling response %s", repr(scaling_response))
        messages = (scaling_response,)
        return messages + self.receive()
    def receive(self):
        messages = ()

        if self._process_queue.empty():
            return messages

        received_scaling_response_string = self._process_queue.get()

        scaling_response = DynamiteScalingResponse.from_json_string(
            received_scaling_response_string,
            message_processed_callback=lambda: None)
        self._logger.info("Received scaling response %s",
                          repr(scaling_response))
        messages = (scaling_response, )
        return messages + self.receive()
    def receive(self):
        messages = ()
        method_frame, header_frame, message_body = self._queue_channel.basic_get(queue=self._queue_name, no_ack=False)
        if self._no_message_delivered(method_frame, header_frame):
            self._logger.debug("Received no message from executor response queue")
            return messages

        received_scaling_response_string = message_body.decode("utf-8")
        message_processed_callback = lambda: self._on_message_processed(method_frame.delivery_tag)
        scaling_response = DynamiteScalingResponse.from_json_string(
            received_scaling_response_string,
            message_processed_callback=message_processed_callback
        )
        self._logger.info("Received scaling response %s", repr(scaling_response))
        messages = (scaling_response,)
        return messages + self.receive()
    def receive(self):
        messages = ()
        method_frame, header_frame, message_body = self._queue_channel.basic_get(
            queue=self._queue_name, no_ack=False)
        if self._no_message_delivered(method_frame, header_frame):
            self._logger.debug(
                "Received no message from executor response queue")
            return messages

        received_scaling_response_string = message_body.decode("utf-8")
        message_processed_callback = lambda: self._on_message_processed(
            method_frame.delivery_tag)
        scaling_response = DynamiteScalingResponse.from_json_string(
            received_scaling_response_string,
            message_processed_callback=message_processed_callback)
        self._logger.info("Received scaling response %s",
                          repr(scaling_response))
        messages = (scaling_response, )
        return messages + self.receive()
示例#10
0
    def test_message_processed_without_callback(self):

        scaling_response = DynamiteScalingResponse.from_json_string(
            self.test_json)
        scaling_response.message_processed()
    def test_message_processed_without_callback(self):

        scaling_response = DynamiteScalingResponse.from_json_string(self.test_json)
        scaling_response.message_processed()
    def test_message_processed_with_callback(self):

        callback = Mock()
        scaling_response = DynamiteScalingResponse.from_json_string(self.test_json, message_processed_callback=callback)
        scaling_response.message_processed()
        callback.assert_called_once_with()