def start_static_http_server(root): port = starboard.find_local_free_tcp_port() config = Configurator() config.add_static_view('static', root, cache_max_age=3600) app = config.make_wsgi_app() server = make_server('0.0.0.0', port, app) server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = True server_thread.start() return Server(server, server_thread, root, port)
def default_installation_serves_default_page(): nginx_port = starboard.find_local_free_tcp_port() install_dir = "_test-install-dir" if os.path.exists(install_dir): shutil.rmtree(install_dir) shell.run( ["whack", "install", ".", install_dir], ) conf_path = os.path.join(install_dir, "conf/nginx.conf") shell.run([ "sed", "-ie", r"s/listen\s\+80\s*;/listen {0};/g".format(nginx_port), conf_path, ]) shell.run([os.path.join(install_dir, "sbin/nginx")]) response = requests.get("http://localhost:{0}".format(nginx_port)) assert "Welcome to nginx!" in response.text, "Response text was: \n{0}".format(response.text)
def can_communicate_with_localhost_using_found_local_hostname(): hostname = starboard.find_local_hostname() port = starboard.find_local_free_tcp_port() with _start_server(port=port): _assert_server_is_running(hostname=hostname, port=port)
def _create_remote_provider(): with qemu_provider() as underlying_provider: port = starboard.find_local_free_tcp_port() with peachtree.server.start_server(port=port, provider=underlying_provider): with peachtree.remote_provider(hostname="localhost", port=port) as provider: yield provider
def can_start_server_on_free_tcp_port(): port = starboard.find_local_free_tcp_port() with _start_server(port=port): _assert_server_is_running(hostname="localhost", port=port)