Debian Codegraph @

scripts/soak-check

raw
1 #!/usr/bin/env python
2 #
3 # Licensed to the Apache Software Foundation (ASF) under one
4 # or more contributor license agreements. See the NOTICE file
5 # distributed with this work for additional information
6 # regarding copyright ownership. The ASF licenses this file
7 # to you under the Apache License, Version 2.0 (the
8 # "License"); you may not use this file except in compliance
9 # with the License. You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing,
14 # software distributed under the License is distributed on an
15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 # KIND, either express or implied. See the License for the
17 # specific language governing permissions and limitations
18 # under the License.
19 #
20 from __future__ import print_function
21 import sys, optparse
22 from subprocess import Popen,PIPE
23
24 def run_test(cmd):
25 try:
26 process = Popen(cmd)
27 except OSError:
28 assert False, "Unable to execute command '%s', is it in your PATH?" % cmd[0]
29 return process.wait()
30
31
32 def main(argv=None):
33 """
34 Run a subset of the Proton tests for an extended period of time.
35 """
36
37 # tests is a list of test configurations. Each configuration is
38 # represented as a two-element tuple. Tuple[0] is the pattern passed to
39 # proton-test that identifies the test case. Tuple[1] is a list of maps.
40 # Each map contains the parameters for one test. A test (of 'pattern') is
41 # executed for each map in Tuple[1]
42
43 parser = optparse.OptionParser()
44 parser.add_option("-i", "--iterations", action="store", type="int", default=1,
45 help="# of times to repeat each test.")
46 parser.add_option("-v", "--verbose", action="store_true",
47 help="print extra detail to stdout")
48 opts, extra = parser.parse_args(args=argv)
49
50 iterations = opts.iterations
51 verbose = opts.verbose
52
53 tests = [
54
55 ("proton_tests.soak.MessengerTests.test_oneway_*",
56 # 104,297 * 7 = 730,079 msgs transferred per iteration
57 [{ "iterations": iterations,
58 "send_count": 104297,
59 "target_count": 7 }]),
60
61 ("proton_tests.soak.MessengerTests.test_echo_*",
62 # 102,811 * 5 * 2 (send+reply) = 1,028,110 msgs transferred per iteration
63 [{"iterations": iterations,
64 "send_count": 102811,
65 "target_count": 5,
66 "send_batch": 3187}]),
67
68 ("proton_tests.soak.MessengerTests.test_relay_*",
69 # 102,197 * 4 * 3 (send+reply+forward)= 1,226,364 msgs transferred per iteration
70 [{"iterations": iterations,
71 "send_count": 102197,
72 "target_count": 4,
73 "send_batch": 829,
74 "forward_count": 7}]),
75
76 ("proton_tests.soak.MessengerTests.test_star_topology_*",
77 # 2 ports * 3 senders = 6 connections per iteration
78 # 6 connections * 7 targets = 42 links per iteration
79 # 42 links * 35419 msg * 2 (send/reply) = 2,975,196 msgs per iteration
80 [{"iterations": iterations,
81 "port_count": 2,
82 "sender_count": 3,
83 "target_count": 7,
84 "send_count": 35419,
85 "send_batch": 311}]),
86
87 #
88 # Scale up the number of connections and links
89 #
90
91 ("proton_tests.soak.MessengerTests.test_star_topology_C",
92 # 10 ports * 10 senders = 100 connections per iteration
93 # 100 connections * 11 targets = 1100 links per iteration
94 # 1100 links * 311 msg * 2 (send/reply) = 684,200 msgs per iteration
95 [{"iterations": iterations,
96 "port_count": 10,
97 "sender_count": 10,
98 "target_count": 11,
99 "send_count": 311,
100 "send_batch": 3}]),
101
102 ("proton_tests.soak.MessengerTests.test_star_topology_C_SSL",
103 # 10 ports * 10 senders = 100 connections per iteration
104 # 100 connections * 11 targets = 1100 links per iteration
105 # 1100 links * 30 msg * 2 (send/reply) = 66000 msgs per iteration
106 [{"iterations": iterations,
107 "port_count": 10,
108 "sender_count": 10,
109 "target_count": 11,
110 "send_count": 30,
111 "send_batch": 3}])
112 ]
113
114 for test in tests:
115 pattern = test[0]
116 param_list = test[1]
117 for test_params in param_list:
118 command = ["proton-test"]
119 for (k, v) in test_params.iteritems():
120 command.append( "-D%s=%s" % (k,v) )
121 if verbose:
122 command.append( "-Dverbose" )
123 command.append( pattern )
124 if verbose:
125 print("command='%s'" % str(command))
126 run_test(command)
127 return 0
128
129
130 if __name__ == "__main__":
131 sys.exit(main())