def setUpClass(cls): super(GRRHTTPServerTest, cls).setUpClass() # Frontend must be initialized to register all the stats counters. front_end.FrontendInit().RunOnce() # Bring up a local server for testing. cls.httpd = http_server.GRRHTTPServer( ("127.0.0.1", portpicker.PickUnusedPort()), http_server.GRRHTTPServerHandler) cls.httpd_thread = threading.Thread(target=cls.httpd.serve_forever) cls.httpd_thread.daemon = True cls.httpd_thread.start() cls.base_url = "http://%s:%s/" % cls.httpd.server_address
def setUpClass(cls): super(GRRHTTPServerTest, cls).setUpClass() # Frontend must be initialized to register all the stats counters. front_end.FrontendInit().RunOnce() # Bring up a local server for testing. port = portpicker.PickUnusedPort() ip = utils.ResolveHostnameToIP("localhost", port) cls.httpd = http_server.GRRHTTPServer((ip, port), http_server.GRRHTTPServerHandler) if ipaddr.IPAddress(ip).version == 6: cls.address_family = socket.AF_INET6 cls.base_url = "http://[%s]:%d/" % (ip, port) else: cls.address_family = socket.AF_INET4 cls.base_url = "http://%s:%d/" % (ip, port) cls.httpd_thread = threading.Thread(target=cls.httpd.serve_forever) cls.httpd_thread.daemon = True cls.httpd_thread.start()