summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-04 12:24:30 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-04 12:24:30 +0000
commitf5e3d9ec8c0bfdf82d290ad242269ebf250dd5dc (patch)
tree3b62a4bf6367f0495f51aee1cb7221d7562ccdba
parent4ca1ddcaebbc4bd5aed97db583a04742b52a5e58 (diff)
downloadchromium_src-f5e3d9ec8c0bfdf82d290ad242269ebf250dd5dc.zip
chromium_src-f5e3d9ec8c0bfdf82d290ad242269ebf250dd5dc.tar.gz
chromium_src-f5e3d9ec8c0bfdf82d290ad242269ebf250dd5dc.tar.bz2
GTTF: Get rid of the test server's /kill switch
This also allows us to remove a quite complicated test. The lifetime of the test server is now fully controlled by its c++ launcher. BUG=49680 TEST=none Review URL: http://codereview.chromium.org/3479018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61358 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/tools/testserver/testserver.py33
-rw-r--r--net/url_request/url_request_unittest.cc79
2 files changed, 0 insertions, 112 deletions
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 9f99d71..c3fe86b 100644
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -9,7 +9,6 @@ It supports several test URLs, as specified by the handlers in TestPageHandler.
It defaults to living on localhost:8888.
It can use https if you specify the flag --https=CERT where CERT is the path
to a pem file containing the certificate and private key that should be used.
-To shut it down properly, visit localhost:8888/kill.
"""
import base64
@@ -108,7 +107,6 @@ class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.ServerAuthConnectHandler,
self.DefaultConnectResponseHandler]
self._get_handlers = [
- self.KillHandler,
self.NoCacheMaxAgeTimeHandler,
self.NoCacheTimeHandler,
self.CacheTimeHandler,
@@ -189,25 +187,6 @@ class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# extension starts with a dot, so we need to remove it
return self._mime_types.get(extension[1:], self._default_mime_type)
- def KillHandler(self):
- """This request handler kills the server, for use when we're done"
- with the a particular test."""
-
- if (self.path.find("kill") < 0):
- return False
-
- self.send_response(200)
- self.send_header('Content-type', 'text/html')
- self.send_header('Cache-Control', 'max-age=0')
- self.end_headers()
- if options.never_die:
- self.wfile.write('I cannot die!! BWAHAHA')
- else:
- self.wfile.write('Goodbye cruel world!')
- self.server.stop = True
-
- return True
-
def NoCacheMaxAgeTimeHandler(self):
"""This request handler yields a page with the title set to the current
system time, and no caching requested."""
@@ -1204,12 +1183,6 @@ def main(options, args):
else:
my_data_dir = MakeDataDir()
- def line_logger(msg):
- if (msg.find("kill") >= 0):
- server.stop = True
- print 'shutting down server'
- sys.exit(0)
-
# Instantiate a dummy authorizer for managing 'virtual' users
authorizer = pyftpdlib.ftpserver.DummyAuthorizer()
@@ -1222,7 +1195,6 @@ def main(options, args):
# Instantiate FTP handler class
ftp_handler = pyftpdlib.ftpserver.FTPHandler
ftp_handler.authorizer = authorizer
- pyftpdlib.ftpserver.logline = line_logger
# Define a customized banner (string returned when client connects)
ftp_handler.banner = ("pyftpdlib %s based ftpd ready." %
@@ -1272,11 +1244,6 @@ if __name__ == '__main__':
'in the specified certificate file')
option_parser.add_option('', '--file-root-url', default='/files/',
help='Specify a root URL for files served.')
- option_parser.add_option('', '--never-die', default=False,
- action="store_true",
- help='Prevent the server from dying when visiting '
- 'a /kill URL. Useful for manually running some '
- 'tests.')
option_parser.add_option('', '--startup-pipe', type='int',
dest='startup_pipe',
help='File handle of pipe to parent process')
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 9070ef1..82d8288 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -281,85 +281,6 @@ TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) {
EXPECT_EQ(std::string(), req.referrer());
}
-namespace {
-
-// Used by MakeGETRequest to implement sync load behavior.
-class SyncTestDelegate : public TestDelegate {
- public:
- SyncTestDelegate() : event_(false, false), success_(false) {
- }
- virtual void OnResponseCompleted(URLRequest* request) {
- MessageLoop::current()->DeleteSoon(FROM_HERE, request);
- success_ = request->status().is_success();
- event_.Signal();
- }
- bool Wait(int64 secs) {
- return event_.TimedWait(TimeDelta::FromSeconds(secs));
- }
- bool did_succeed() const { return success_; }
- private:
- base::WaitableEvent event_;
- bool success_;
- DISALLOW_COPY_AND_ASSIGN(SyncTestDelegate);
-};
-
-void StartGETRequest(const GURL& url, URLRequest::Delegate* delegate) {
- URLRequest* request = new URLRequest(url, delegate);
- request->set_context(new TestURLRequestContext());
- request->set_method("GET");
- request->Start();
- EXPECT_TRUE(request->is_pending());
-}
-
-bool MakeGETRequest(const GURL& url) {
- // Spin up a background thread for this request so that we have access to
- // an IO message loop, and in cases where this thread already has an IO
- // message loop, we also want to avoid spinning a nested message loop.
- SyncTestDelegate d;
- {
- base::Thread io_thread("MakeGETRequest");
- base::Thread::Options options;
- options.message_loop_type = MessageLoop::TYPE_IO;
- io_thread.StartWithOptions(options);
- io_thread.message_loop()->PostTask(FROM_HERE, NewRunnableFunction(
- &StartGETRequest, url, &d));
-
- const int kWaitSeconds = 30;
- if (!d.Wait(kWaitSeconds))
- return false;
- }
- return d.did_succeed();
-}
-
-} // namespace
-
-// Some tests use browser javascript to fetch a 'kill' url that causes
-// the server to exit by itself (rather than letting TestServerLauncher's
-// destructor kill it). We now unit test this mechanism.
-TEST_F(URLRequestTest, QuitTest) {
- net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
- ASSERT_TRUE(test_server.Start());
-
- // Append the time to avoid problems where the kill page
- // is being cached rather than being executed on the server
- std::string page_name = base::StringPrintf("kill?%u",
- static_cast<int>(base::Time::Now().ToInternalValue()));
- int retry_count = 5;
- while (retry_count > 0) {
- bool r = MakeGETRequest(test_server.GetURL(page_name));
- // BUG #1048625 causes the kill GET to fail. For now we just retry.
- // Once the bug is fixed, we should remove the while loop and put back
- // the following DCHECK.
- // DCHECK(r);
- if (r)
- break;
- retry_count--;
- }
- // Make sure we were successful in stopping the testserver.
- EXPECT_LT(0, retry_count);
- EXPECT_TRUE(test_server.WaitToFinish(20000));
-}
-
class HTTPSRequestTest : public testing::Test {
};