def test_timeout_error_on_too_long_service_stop(): unstoppable_service_path = os.path.join(os.path.dirname(__file__), 'unstoppable_service.py') service = HttpService([sys.executable, unstoppable_service_path, '{port}']) service.start() try: with pytest.raises(subprocess.TimeoutExpired): service.stop(0.001) finally: # cleanup by ending the service process service._service_proc.terminate()
def test_service_start_timeout_and_cleanup(): never_starting_service = os.path.join(os.path.dirname(__file__), 'never_starting_service.py') test_service = HttpService([sys.executable, never_starting_service, '{port}']) with pytest.raises(TimeoutError): # If this timeout is lower, then the test can sometimes fail. # It looks like Python can ignore SIGINT in the early process startup, # but this needs to be verified. # This wouldn't be a problem with SIGTERM. test_service.start(timeout=0.1) test_service._service_proc.wait(timeout=1.0)
def test_service_start_timeout_and_cleanup(): never_starting_service = os.path.join(os.path.dirname(__file__), 'never_starting_service.py') test_service = HttpService( [sys.executable, never_starting_service, '{port}']) with pytest.raises(TimeoutError): # If this timeout is lower, then the test can sometimes fail. # It looks like Python can ignore SIGINT in the early process startup, # but this needs to be verified. # This wouldn't be a problem with SIGTERM. test_service.start(timeout=0.1) test_service._service_proc.wait(timeout=1.0)
def das_session(vcap_services, uaa_imposter): waitress_path = os.path.join(os.path.dirname(sys.executable), 'waitress-serve') das_command = [ waitress_path, '--port', '{port}', '--call', 'data_acquisition.app:get_app'] project_root_path = os.path.join(waitress_path, '../../../..') das_service = HttpService( das_command, env={ 'VCAP_APPLICATION': TEST_VCAP_APPLICATION, 'VCAP_SERVICES': vcap_services, 'VCAP_APP_PORT': '{port}', 'PYTHONPATH': project_root_path}) das_service.start() yield das_service das_service.stop()
def das_session(vcap_services, uaa_imposter): waitress_path = os.path.join(os.path.dirname(sys.executable), 'waitress-serve') das_command = [ waitress_path, '--port', '{port}', '--call', 'data_acquisition.app:get_app' ] project_root_path = os.path.join(waitress_path, '../../../..') das_service = HttpService(das_command, env={ 'VCAP_APPLICATION': TEST_VCAP_APPLICATION, 'VCAP_SERVICES': vcap_services, 'VCAP_APP_PORT': '{port}', 'PYTHONPATH': project_root_path }) das_service.start() yield das_service das_service.stop()
def test_service_timeout_and_cleanup(): test_service = HttpService(TEST_SERVICE_COMMAND) with pytest.raises(TimeoutError): test_service.start(timeout=0.001) test_service._service_proc.wait(timeout=3.0)