Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 ashish 1
#!/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
 
22
import time
23
import subprocess
24
import sys
25
import os
26
import signal
27
 
28
def relfile(fname):
29
    return os.path.join(os.path.dirname(__file__), fname)
30
 
31
FRAMED = ["TNonblockingServer"]
32
 
33
def 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
 
53
map(runTest, [
54
  "TSimpleServer",
55
  "TThreadedServer",
56
  "TThreadPoolServer",
57
  "TForkingServer",
58
  "TNonblockingServer",
59
  "THttpServer",
60
  ])