blob: 2bd6094dd95e00ac7e8b805f5c5c09837ec407e2 [file] [log] [blame]
Gavin McDonald0b75e1a2010-10-28 02:12:01 +00001#!/usr/bin/env python
2
3#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the
9# "License"); you may not use this file except in compliance
10# with the License. You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing,
15# software distributed under the License is distributed on an
16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21
22import time
23import subprocess
24import sys
25import os
26import signal
27
28def relfile(fname):
29 return os.path.join(os.path.dirname(__file__), fname)
30
31FRAMED = ["TNonblockingServer"]
32
33def runTest(server_class):
34 print "Testing ", server_class
35 serverproc = subprocess.Popen([sys.executable, relfile("TestServer.py"), server_class])
36 time.sleep(0.25)
37 try:
38 argv = [sys.executable, relfile("TestClient.py")]
39 if server_class in FRAMED:
40 argv.append('--framed')
41 if server_class == 'THttpServer':
42 argv.append('--http=/')
43 ret = subprocess.call(argv)
44 if ret != 0:
45 raise Exception("subprocess failed")
46 finally:
47 # fixme: should check that server didn't die
48 os.kill(serverproc.pid, signal.SIGKILL)
49
50 # wait for shutdown
51 time.sleep(1)
52
53map(runTest, [
54 "TSimpleServer",
55 "TThreadedServer",
56 "TThreadPoolServer",
57 "TForkingServer",
58 "TNonblockingServer",
59 "THttpServer",
60 ])