예제 #1
0
def start_rp_process(port, command, working_directory=None):
    failed_to_start_message = "Failed to start test instance %s." % get_base_url(
        port)

    if is_port_used_by_another_process(port):
        log_info = "Port %s is used by another process" % port
        raise PortUsedByOtherProcess(failed_to_start_message,
                                     log_info=log_info)

    try:
        p = subprocess.Popen(command,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             cwd=working_directory)
    except Exception as ex:
        raise SubProcessFailed(
            failed_to_start_message,
            log_info="Failed to run oprp script: %s Error message: %s" %
            (command[0], ex.message))

    check_if_oprp_started(port, get_base_url(port))

    return_code = p.poll()
    if return_code is not None:
        raise NoResponseException(
            failed_to_start_message,
            log_info="Return code %s != None so the process did not "
            "start correctly. Command executed: %s" % (return_code, command))
예제 #2
0
def start_rp_process(port, command, working_directory=None):
    failed_to_start_message = "Failed to start test instance %s." % get_base_url(port)

    if is_port_used_by_another_process(port):
        log_info = "Port %s is used by another process" % port
        raise PortUsedByOtherProcess(failed_to_start_message,
                                     log_info=log_info)

    try:
        p = subprocess.Popen(command,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             cwd=working_directory)
    except Exception as ex:
        raise SubProcessFailed(failed_to_start_message,
                               log_info="Failed to run oprp script: %s Error message: %s"
                                        % (command[0], ex.message))

    check_if_oprp_started(port, get_base_url(port))

    return_code = p.poll()
    if return_code is not None:
        raise NoResponseException(failed_to_start_message,
                                  log_info="Return code %s != None so the process did not "
                                           "start correctly. Command executed: %s"
                                           % (return_code, command))
예제 #3
0
 def test_if_able_to_get_200_ok_from_running_server(self):
     responses.add(responses.GET,
                   self.get_external_host_url(9001),
                   body={},
                   status=200,
                   content_type='application/json')
     return_code = check_if_oprp_started(
         None, oprp_url=self.get_external_host_url(9001), timeout=1)
     assert return_code
예제 #4
0
 def test_if_able_to_get_200_ok_from_running_server(self):
     responses.add(responses.GET,
                   self.get_external_host_url(9001),
                   body={},
                   status=200,
                   content_type='application/json')
     return_code = check_if_oprp_started(None,
                                         oprp_url=self.get_external_host_url(9001),
                                         timeout=1)
     assert return_code
예제 #5
0
 def test_check_if_oprp_started_raises_NoResponseException(self):
     with pytest.raises(NoResponseException):
         check_if_oprp_started(None, oprp_url="http://1234.1234.1234.1234:8000", timeout=1)
예제 #6
0
 def test_check_if_oprp_started_raises_NoResponseException(self):
     with pytest.raises(NoResponseException):
         check_if_oprp_started(None,
                               oprp_url="http://1234.1234.1234.1234:8000",
                               timeout=1)