1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
#!/usr/bin/env python
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import glob, os, subprocess
from subprocess import Popen
from optparse import OptionParser
interop_cases = ["InteropTestCase1DummyRun", "InteropTestCase2BasicP2P", "InteropTestCase3BasicPubSub", "InteropTestCase4P2PMessageSize", "InteropTestCase5PubSubMessageSize"]
interop_command = "java -cp %s org.apache.qpid.test.framework.distributedtesting.Coordinator --xml -e interop -o . -n interop org.apache.qpid.interop.testcases.%s"
# TODO: read this from the ant properties file
clientlibs = ["qpid-integrationtests-incubating-M4.jar",
"qpid-junit-toolkit-incubating-M4.jar",
"junit-3.8.1.jar",
"qpid-systests-incubating-M4.jar",
"qpid-junit-toolkit-incubating-M4.jar",
"geronimo-jms_1.1_spec-1.0.jar",
"log4j-1.2.12.jar"]
def main():
parser = OptionParser()
parser.add_option("-t", "--testlib", dest="testlib", action="store",
type="string",
help="The directory containing the test classes to run")
parser.add_option("-b", "--brokers", dest="brokers", action="store",
type="string",
help="The directory containing the unpacked brokers to test")
parser.add_option("-j", "--java", dest="java", action="store",
type="string",
help="The directory containing the java client to test")
parser.add_option("-d", "--dotnet", dest="dotnet", action="store",
type="string",
help="The directory containing the .Net client to test")
parser.add_option("-c", "--cpp", dest="cpp", action="store",
type="string",
help="The directory containing the C++ client to test")
(options, args) = parser.parse_args()
# check available brokers
if (options.brokers == None or
not os.path.exists(options.brokers) or
not os.path.isdir(options.brokers)):
parser.error("Broker directory must be specified and must exist")
# check available clients
if (options.java == None or
not os.path.exists(options.java) or
not os.path.isdir(options.java)):
parser.error("Java client directory must be specified and must exist")
# check available tests
if (options.testlib == None or
not os.path.exists(options.testlib) or
not os.path.isdir(options.testlib)):
parser.error("Test directory must be specified and must exist")
# check dotnet test client
if (options.dotnet == None or
not os.path.exists(options.dotnet) or
not os.path.exists(options.dotnet+"/TestClient.exe")):
parser.error(".Net test directory must be specified and must contain TestClient.exe")
# check cpp test client
if (options.cpp == None or
not os.path.exists(options.cpp) or
not os.path.exists(options.cpp+"/src/tests/interop_runner")):
parser.error("C++ test directory must be specified and must contain test client")
# Get list of available broker and client versions
brokers = glob.glob(options.brokers+"/qpid-[0-9].[0-9].[0-9].[0-9]")
java_clients = glob.glob(options.java+"/qpid-[0-9].[0-9].[0-9].[0-9]*")
if (not len(brokers) > 0):
parser.error("Broker directory did not contain any brokers!")
if (not len(java_clients) > 0):
parser.error("Broker directory did not contain any brokers!")
for broker in brokers:
for client in java_clients:
test(options.testlib, broker, client, options.dotnet,
options.cpp)
def start_dotnet(dotnetpath):
return Popen(["%s/TestClient.exe" % os.path.abspath(dotnetpath),
"-bamqp://guest:guest@clientid/?brokerlist=\'tcp://localhost:5672\'"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
def start_java(javapath):
# Setup classpath
classpath = ""
for lib in clientlibs:
classpath = classpath + testlibdir+"/"+lib+";"
classpath = classpath + javapath+"/lib/qpid-incubating.jar"
# Add qpid common since the tests need that, classpath hatefulness
classpath = classpath + ";"+testlibdir+"/qpid-common-incubating-M4.jar"
return Popen(["java", "-cp","\""+classpath+"\"",
"org.apache.qpid.test.framework.distributedtesting.TestClient"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
def start_cpp(cpppath):
return Popen([cpppath+"tests/interop_runner"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
def run_tests():
for testcase in interop_cases:
cmd = " ".join(["java", "-cp","\""+classpath+"\"", "org.apache.qpid.test.framework.distributedtesting.Coordinator",
"--xml", "-e", "interop", "-o", ".", "-n", "interop", ("org.apache.qpid.interop.testcases.%s" % testcase)])
fd = os.popen(cmd, "r")
output = fd.read()
fd.close()
def test(testlibdir, brokerpath, javapath, dotnetpath, cpppath):
print ("Testing broker in %s\nclient in %s" % (brokerpath, javapath))
print ("Logging too %s" % ("/tmp/qpid-interop-tests/%s-%s" %
(os.path.basename(brokerpath), os.path.basename(javapath))))
os.environ["QPID_HOME"] = brokerpath
os.environ["QPID_WORK"] = ("/tmp/qpid-interop-tests/%s-%s" %
(os.path.basename(brokerpath), os.path.basename(javapath)))
brokerp, javacp, dotnetp, cppp, coordinatorp = (None, None, None, None, None)
try:
# Start broker
brokerp = Popen(brokerpath+"/bin/qpid-server",
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
print ("Started broker, pid %s" % brokerp.pid)
cppp = start_cpp(cpppath)
print ("Started C++ client, pid %s" % cppp.pid)
dotnetp = start_dotnet(dotnetpath)
print ("Started .Net client, pid %s" % dotnetp.pid)
javacp = start_java(javapath)
print ("Started client, pid %s" % javacp.pid)
run_tests()
finally:
# Shutdown broker and clients
if javacp != None:
os.kill(javacp.pid, 9)
if dotnetp != None:
os.kill(dotnetp.pid, 9)
if coordinatorp != None:
os.kill(coordinatorp.pid, 9)
if brokerp != None:
os.kill(brokerp.pid, 9)
# Start coordinator
if __name__ == "__main__":
main()
|