Example #1
0
def restart_test_instance(_instance_id, _port, _profile, response_encoder, configurations):
    config_module = create_module_string(configurations,
                                         _port,
                                         get_base_url(_port),
                                         conf=CONF)
    config_file_path = get_config_file_path(_port, CONF.OPRP_DIR_PATH)
    try:
        write_config_file(config_file_path, config_module, _port, oprp_dir_path=CONF.OPRP_DIR_PATH)
        LOGGER.debug("Written configuration to file: %s" % config_file_path)
    except IOError as ioe:
        error_message = "write configurations file (%s) to disk." % config_file_path
        return handle_exception(ioe, response_encoder, failed_to_message=error_message)
    try:
        save_config_info_in_database(_port, configurations)
        LOGGER.debug(
            'Configurations for the test instance using instance ID '
            '"%s" which should be using port %s to has been saved in the database' % (
                _instance_id, _port))
    except Exception as ex:
        return handle_exception(ex, response_encoder,
                                failed_to_message="store configurations in database")
    try:
        kill_existing_process_on_port(_port, get_base_url(_port))
    except Exception as ex:
        return handle_exception(ex, response_encoder,
                                failed_to_message="restart existing test instance")
    config_file_name = os.path.basename(config_file_path)
    config_module = config_file_name.split(".")[0]
    start_rp_process(_port, [CONF.OPRP_PATH, "-p", _profile, "-t",
                             CONF.OPRP_TEST_FLOW, config_module], CONF.OPRP_DIR_PATH)
    return response_encoder.return_json(
        json.dumps({"oprp_url": str(get_base_url(_port))}))
Example #2
0
def restart_test_instance(_instance_id, _port, _profile, response_encoder, configurations):
    config_module = create_module_string(configurations,
                                         _port,
                                         get_base_url(_port),
                                         conf=CONF)
    config_file_path = get_config_file_path(_port, CONF.OPRP_DIR_PATH)
    try:
        write_config_file(config_file_path, config_module, _port, oprp_dir_path=CONF.OPRP_DIR_PATH)
        LOGGER.debug("Written configuration to file: %s" % config_file_path)
    except IOError as ioe:
        error_message = "write configurations file (%s) to disk." % config_file_path
        return handle_exception(ioe, response_encoder, failed_to_message=error_message)
    try:
        save_config_info_in_database(_port, configurations)
        LOGGER.debug(
            'Configurations for the test instance using instance ID '
            '"%s" which should be using port %s to has been saved in the database' % (
                _instance_id, _port))
    except Exception as ex:
        return handle_exception(ex, response_encoder,
                                failed_to_message="store configurations in database")
    try:
        kill_existing_process_on_port(_port, get_base_url(_port))
    except Exception as ex:
        return handle_exception(ex, response_encoder,
                                failed_to_message="restart existing test instance")
    config_file_name = os.path.basename(config_file_path)
    config_module = config_file_name.split(".")[0]
    start_rp_process(_port, [CONF.OPRP_PATH, "-p", _profile, "-t",
                             CONF.OPRP_TEST_FLOW, config_module], CONF.OPRP_DIR_PATH)
    return response_encoder.return_json(
        json.dumps({"oprp_url": str(get_base_url(_port))}))
 def test_if_exception_is_not_user_friendly_standard_message_should_be_used(self, uuid4_mock):
     event_id = "a1s2d3"
     uuid4_mock.return_value = event_id
     message = "message"
     ex = Exception("Exception message")
     response_encoder = MagicMock()
     handle_exception(ex, response_encoder, message=message)
     response_encoder.service_error.assert_called_once_with(message, event_id=event_id)
 def test_separate_between_user_friendly_exception_message_and_log_info(self, logger, uuid4_mock):
     event_id = "a1s2d3"
     message = "message"
     log_info = "log_info"
     ex = UserFriendlyException(message, log_info)
     uuid4_mock.return_value = event_id
     response_encoder = MagicMock()
     handle_exception(ex, response_encoder)
     response_encoder.service_error.assert_called_once_with(message, event_id=event_id)
     assert logger.error.called
Example #5
0
def application(environ, start_response):
    response_encoder = ResponseEncoder(environ=environ,
                                       start_response=start_response)
    try:
        return handle_path(environ, start_response, response_encoder)
    except Exception as ex:
        response = handle_exception(ex, response_encoder,
                                    message="An error occurred on the server side, "
                                            "please contact technical support.")
        LOGGER.debug("Error response: " + str(response))
        return response
Example #6
0
def application(environ, start_response):
    response_encoder = ResponseEncoder(environ=environ,
                                       start_response=start_response)
    try:
        return handle_path(environ, start_response, response_encoder)
    except Exception as ex:
        response = handle_exception(ex, response_encoder,
                                    message="An error occurred on the server side, "
                                            "please contact technical support.")
        LOGGER.debug("Error response: " + str(response))
        return response