root/trunk/nuxleus/Scripts/queueloadtest.py

Revision 4039, 1.3 kB (checked in by sylvain.hellegouarch, 1 year ago)

Simple queue server load script

Line 
1 import time
2 import threading
3
4 from bucker.api.client import QueueClient
5 from bucker.api.message import Message
6
7 s = """<qs xmlns="http://purl.oclc.org/DEFUZE/qs" resp="1e582a22b3f82a7c9acc227b0ccb6fdec0d84e6b74dccbcb542e8d11e1b379dd" type="response"><op><push-message /></op><qid>test</qid><mid>3664f5666c2564f7fb6c16d45b1e5f7f951ebff6d7d34792fe4badb63b566ed2</mid><payload>PGxsdXA6bm90aWZpY2F0aW9uIHhtbG5zOmxsdXA9Imh0dHA6Ly93d3cueDJ4Mngub3JnL2xsdXAiIGFjdGlvbj0iIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwNS9BdG9tIj48bGx1cDpyZWNpcGllbnQgaHJlZj0iIiAvPjxsaW5rIGhyZWY9Imh0dHA6Ly9hdG9tcHViLmRlZnV6ZS5vcmcvc3RhcnRlci9zYWxhZC9OYXBvbGl0YW4uYXRvbSIgcmVsPSJzZWxmIiB0eXBlPSJhcHBsaWNhdGlvbi9hdG9tK3htbDt0eXBlPWVudHJ5IiAvPjxjYXRlZ29yeSB0ZXJtPSJpbmRpZSIgLz48Y2F0ZWdvcnkgdGVybT0icm9jayIgLz48Y2F0ZWdvcnkgdGVybT0iamF6eiIgLz48Y2F0ZWdvcnkgdGVybT0iYmx1ZXMiIC8+PC9sbHVwOm5vdGlmaWNhdGlvbj4=</payload></qs>"""
8
9 m = Message.parse(s)
10
11 def go():
12     c = QueueClient('127.0.0.1', 9876)
13     c.connect()
14     for i in range(0, 500):
15         c.send(m)
16         c.recv()
17         time.sleep(0.1)
18     c.disconnect()
19
20 def run_load():
21     threads = []
22     for i in range(0, 5):
23         t = threading.Thread(target=go)
24         threads.append(t)
25         t.start()
26
27     for t in threads:
28         t.join()
29
30 if __name__ == '__main__':
31     run_load()
Note: See TracBrowser for help on using the browser.