blob: 2bd6094dd95e00ac7e8b805f5c5c09837ec407e2 [file] [log] [blame]
Mark Slee5299a952007-10-05 00:13:24 +00001#!/usr/bin/env python
2
David Reissea2cba82009-03-30 21:35:00 +00003#
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
David Reissbcaa2ad2008-06-10 22:55:26 +000022import time
Mark Slee5299a952007-10-05 00:13:24 +000023import subprocess
24import sys
25import os
26import signal
27
David Reiss2a4bfd62008-04-07 23:45:00 +000028def relfile(fname):
29 return os.path.join(os.path.dirname(__file__), fname)
30
David Reiss74421272008-11-07 23:09:31 +000031FRAMED = ["TNonblockingServer"]
32
David Reissbcaa2ad2008-06-10 22:55:26 +000033def runTest(server_class):
34 print "Testing ", server_class
35 serverproc = subprocess.Popen([sys.executable, relfile("TestServer.py"), server_class])
David Reiss31661412009-01-31 21:39:08 +000036 time.sleep(0.25)
David Reissbcaa2ad2008-06-10 22:55:26 +000037 try:
David Reiss74421272008-11-07 23:09:31 +000038 argv = [sys.executable, relfile("TestClient.py")]
39 if server_class in FRAMED:
40 argv.append('--framed')
David Reissf78ec2b2009-01-31 21:59:32 +000041 if server_class == 'THttpServer':
42 argv.append('--http=/')
David Reiss74421272008-11-07 23:09:31 +000043 ret = subprocess.call(argv)
David Reissbcaa2ad2008-06-10 22:55:26 +000044 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
David Reiss31661412009-01-31 21:39:08 +000051 time.sleep(1)
David Reissbcaa2ad2008-06-10 22:55:26 +000052
David Reissf78ec2b2009-01-31 21:59:32 +000053map(runTest, [
54 "TSimpleServer",
55 "TThreadedServer",
56 "TThreadPoolServer",
57 "TForkingServer",
58 "TNonblockingServer",
59 "THttpServer",
60 ])