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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************
import os, sys, time, threading, re
for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
toplevel = os.path.normpath(toplevel)
if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")):
break
else:
raise "can't find toplevel directory!"
sys.path.append(os.path.join(toplevel, "config"))
import TestUtil
TestUtil.processCmdLine()
name = os.path.join("IceStorm", "stress")
testdir = os.path.dirname(os.path.abspath(__file__))
exedir = testdir
iceBox = TestUtil.getIceBox(exedir)
iceBoxAdmin = os.path.join(TestUtil.getBinDir(__file__), "iceboxadmin")
iceStormAdmin = os.path.join(TestUtil.getBinDir(__file__), "icestormadmin")
iceBoxEndpoints = ' --IceBox.ServiceManager.Endpoints="default -p 12010" --Ice.Default.Locator='
iceStormService = " --IceBox.Service.IceStorm=IceStormService," + TestUtil.getIceSoVersion() + ":createIceStorm" + \
' --IceStorm.TopicManager.Endpoints="default -p 12011"' + \
' --IceStorm.Publish.Endpoints="default -p 12012"' + \
' --IceStorm.InstanceName=TestIceStorm1 ' + \
' --IceStorm.Discard.Interval=2' + \
' --IceBox.PrintServicesReady=IceStorm' + \
" --IceBox.InheritProperties=1"
iceStormReference = ' --IceStorm.TopicManager.Proxy="TestIceStorm1/TopicManager: default -p 12011"'
iceBoxEndpoints2 = ' --IceBox.ServiceManager.Endpoints="default -p 12020" --Ice.Default.Locator='
iceStormService2 = " --IceBox.Service.IceStorm=IceStormService," + TestUtil.getIceSoVersion() + ":createIceStorm" + \
' --IceStorm.TopicManager.Endpoints="default -p 12021"' + \
' --IceStorm.Publish.Endpoints="default -p 12022"' + \
' --IceStorm.InstanceName=TestIceStorm2 ' + \
' --IceStorm.Discard.Interval=2' + \
' --IceBox.PrintServicesReady=IceStorm' + \
" --IceBox.InheritProperties=1"
iceStormReference2 = ' --IceStorm.TopicManager.Proxy="TestIceStorm2/TopicManager: default -p 12021"'
adminIceStormReference = ' --IceStormAdmin.TopicManager.Proxy="TestIceStorm1/TopicManager: default -p 12011" ' + \
'--IceStormAdmin.TopicManager.Proxy2="TestIceStorm2/TopicManager: default -p 12021"'
def doTest(subOpts, pubOpts):
global testdir
global iceStormReference
global iceStormReference2
publisher = os.path.join(testdir, "publisher")
subscriber = os.path.join(testdir, "subscriber")
subscriberPipes = []
if type(subOpts) != type([]):
subOpts = [ subOpts ]
for opts in subOpts:
# We don't want the subscribers to time out.
pipe = TestUtil.startServer(subscriber, r' --Ice.ServerIdleTime=0 ' + opts + " 2>&1")
TestUtil.getServerPid(pipe)
TestUtil.getAdapterReady(pipe)
subscriberPipes.append(pipe)
publisherPipe = TestUtil.startClient(publisher, iceStormReference + ' ' + pubOpts + " 2>&1")
TestUtil.printOutputFromPipe(publisherPipe)
publisherStatus = TestUtil.closePipe(publisherPipe)
if publisherStatus:
print "(publisher failed)",
return publisherStatus
for p in subscriberPipes:
try:
sys.stdout.flush()
subscriberStatus = TestUtil.specificServerStatus(p)
except:
print "(subscriber failed)",
return 1
if subscriberStatus:
print "(subscriber failed)",
return subscriberStatus
return 0
def startServers(additionalArgs=""):
global iceBox
global iceBoxEndpoints
global iceBoxEndpoints2
global iceStormService
global iceStormService2
global iceStormDBEnv
global iceStormDBEnv2
print "starting icestorm services...",
sys.stdout.flush()
# Clear the idle timeout otherwise the IceBox ThreadPool will timeout.wA
command = iceBoxEndpoints + iceStormService + iceStormDBEnv + ' --Ice.ServerIdleTime=0' + additionalArgs
iceBoxPipe = TestUtil.startServer(iceBox, command + " 2>&1")
TestUtil.getServerPid(iceBoxPipe)
TestUtil.waitServiceReady(iceBoxPipe, "IceStorm")
command = iceBoxEndpoints2 + iceStormService2 + iceStormDBEnv2 + ' --Ice.ServerIdleTime=0' + additionalArgs
iceBoxPipe2 = TestUtil.startServer(iceBox, command + " 2>&1")
TestUtil.getServerPid(iceBoxPipe2)
TestUtil.waitServiceReady(iceBoxPipe2, "IceStorm")
print "ok"
return iceBoxPipe, iceBoxPipe2
def stopServers(p1, p2 = None):
global iceBox
global iceBoxAdmin
global iceBoxEndpoints
global iceBoxEndpoints2
print "shutting down icestorm services...",
sys.stdout.flush()
command = iceBoxEndpoints + r' shutdown'
pipe = TestUtil.startClient(iceBoxAdmin, command + " 2>&1")
status = TestUtil.closePipe(pipe)
if status or TestUtil.specificServerStatus(p1):
TestUtil.killServers()
sys.exit(1)
if p2:
command = iceBoxEndpoints2 + r' shutdown'
pipe = TestUtil.startClient(iceBoxAdmin, command + " 2>&1")
status = TestUtil.closePipe(pipe)
if status or TestUtil.specificServerStatus(p2):
TestUtil.killServers()
sys.exit(1)
print "ok"
def runAdmin(cmd, desc = None):
global iceStormAdmin
global iceStormAdminReference
if desc:
print desc,
sys.stdout.flush()
command = adminIceStormReference + r' -e "' + cmd + '"'
pipe = TestUtil.startClient(iceStormAdmin, command + " 2>&1")
status = TestUtil.closePipe(pipe)
if status:
TestUtil.killServers()
sys.exit(1)
if desc:
print "ok"
dbHome = os.path.join(testdir, "db")
TestUtil.cleanDbDir(dbHome)
iceStormDBEnv=" --Freeze.DbEnv.IceStorm.DbHome=" + dbHome
dbHome2 = os.path.join(testdir, "db2")
TestUtil.cleanDbDir(dbHome2)
iceStormDBEnv2=" --Freeze.DbEnv.IceStorm.DbHome=" + dbHome2
server1, server2 = startServers()
runAdmin("create TestIceStorm1/fed1 TestIceStorm2/fed1", "setting up the topics...")
print "Sending 5000 ordered events... ",
sys.stdout.flush()
status = doTest('--events 5000 --qos "reliability,ordered" ' + iceStormReference, '--events 5000')
if status:
print "failed!"
TestUtil.killServers()
sys.exit(1)
print "ok"
runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 5000 ordered events across a link... ",
sys.stdout.flush()
status = doTest('--events 5000 --qos "reliability,ordered" ' + iceStormReference2, '--events 5000')
if status:
TestUtil.killServers()
sys.exit(1)
print "ok"
runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 20000 unordered events... ",
sys.stdout.flush()
status = doTest('--events 20000 ' + iceStormReference, '--events 20000 --oneway')
if status:
print "failed!"
TestUtil.killServers()
sys.exit(1)
print "ok"
runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 20000 unordered events across a link... ",
sys.stdout.flush()
status = doTest('--events 20000 ' + iceStormReference2, '--events 20000 --oneway')
if status:
TestUtil.killServers()
sys.exit(1)
print "ok"
runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 20000 unordered batch events... ",
sys.stdout.flush()
status = doTest('--events 20000 --qos "reliability,batch" ' + iceStormReference, '--events 20000 --oneway')
if status:
print "failed!"
TestUtil.killServers()
sys.exit(1)
print "ok"
runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 20000 unordered batch events across a link... ",
sys.stdout.flush()
status = doTest('--events 20000 --qos "reliability,batch" ' + iceStormReference2, '--events 20000 --oneway')
if status:
TestUtil.killServers()
sys.exit(1)
print "ok"
runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 20000 unordered events with slow subscriber... ",
status = doTest(['--events 2 --slow ' + iceStormReference, '--events 20000 ' + iceStormReference], '--events 20000 --oneway')
if status:
print "failed!"
TestUtil.killServers()
sys.exit(1)
print "ok"
runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 20000 unordered events with slow subscriber & link... ",
status = doTest(['--events 2 --slow' + iceStormReference, '--events 20000' + iceStormReference, '--events 2 --slow' + iceStormReference2, '--events 20000' + iceStormReference2], '--events 20000 --oneway')
if status:
print "failed!"
TestUtil.killServers()
sys.exit(1)
print "ok"
#
# The erratic tests emit lots of connection warnings so they are
# disabled here. The IceStorm servers are stopped and restarted so the
# settings will take effect.
#
stopServers(server1, server2)
server1, server2 = startServers(" --Ice.Warn.Connections=0")
runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 20000 unordered events with erratic subscriber... ",
sys.stdout.flush()
status = doTest(\
[ '--erratic 5 --qos "reliability,ordered" --events 20000' + iceStormReference, \
'--erratic 5 --events 20000' + iceStormReference, \
'--events 20000' + iceStormReference], \
'--events 20000 --oneway')
if status:
print "failed!"
TestUtil.killServers()
sys.exit(1)
print "ok"
runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1")
print "Sending 20000 unordered events with erratic subscriber across a link... ",
sys.stdout.flush()
status = doTest( \
[ '--events 20000' + iceStormReference, \
'--erratic 5 --qos "reliability,ordered" --events 20000 ' + iceStormReference, \
'--erratic 5 --events 20000 ' + iceStormReference, \
'--events 20000' + iceStormReference2, \
'--erratic 5 --qos "reliability,ordered" --events 20000 ' + iceStormReference2, \
'--erratic 5 --events 20000 ' + iceStormReference2], \
'--events 20000 --oneway ')
if status:
print "failed!"
TestUtil.killServers()
sys.exit(1)
print "ok"
#
# Shutdown icestorm.
#
stopServers(server1, server2)
if TestUtil.serverStatus():
TestUtil.killServers()
sys.exit(1)
sys.exit(0)
|