Merge "Simulator: always use random messages for time-bound tests"
This commit is contained in:
commit
7c01d54f4f
@ -50,6 +50,7 @@ Usage example:
|
|||||||
--url rabbit://stackrabbit:secretrabbit@localhost/ rpc-client\
|
--url rabbit://stackrabbit:secretrabbit@localhost/ rpc-client\
|
||||||
--exit-wait 15000 -p 64 -m 64"""
|
--exit-wait 15000 -p 64 -m 64"""
|
||||||
|
|
||||||
|
MESSAGES_LIMIT = 1000
|
||||||
DISTRIBUTION_BUCKET_SIZE = 500
|
DISTRIBUTION_BUCKET_SIZE = 500
|
||||||
|
|
||||||
|
|
||||||
@ -217,19 +218,19 @@ class RPCClient(object):
|
|||||||
time.sleep(self.wait_after_msg)
|
time.sleep(self.wait_after_msg)
|
||||||
|
|
||||||
|
|
||||||
def init_msg(messages_count):
|
def generate_messages(messages_count):
|
||||||
# Limit the messages amount. Clients will reiterate the array again
|
# Limit the messages amount. Clients will reiterate the array again
|
||||||
# if an amount of messages to be sent is bigger than 1000
|
# if an amount of messages to be sent is bigger than MESSAGES_LIMIT
|
||||||
if messages_count > 1000:
|
if messages_count > MESSAGES_LIMIT:
|
||||||
messages_count = 1000
|
messages_count = MESSAGES_LIMIT
|
||||||
LOG.info("Preparing %d messages", messages_count)
|
LOG.info("Generating %d random messages", messages_count)
|
||||||
|
|
||||||
for i in range(messages_count):
|
for i in range(messages_count):
|
||||||
length = RANDOM_GENERATOR()
|
length = RANDOM_GENERATOR()
|
||||||
msg = ''.join(random.choice(string.lowercase) for x in range(length)) \
|
msg = ''.join(random.choice(string.lowercase) for x in range(length)) \
|
||||||
+ ' ' + str(i)
|
+ ' ' + str(i)
|
||||||
MESSAGES.append(msg)
|
MESSAGES.append(msg)
|
||||||
i += 1
|
|
||||||
LOG.info("Messages has been prepared")
|
LOG.info("Messages has been prepared")
|
||||||
|
|
||||||
|
|
||||||
@ -428,6 +429,10 @@ def main():
|
|||||||
transport = messaging.get_notification_transport(cfg.CONF,
|
transport = messaging.get_notification_transport(cfg.CONF,
|
||||||
url=args.url)
|
url=args.url)
|
||||||
|
|
||||||
|
if args.mode in ['rpc-client', 'notify-client']:
|
||||||
|
# always generate maximum number of messages for duration-limited tests
|
||||||
|
generate_messages(MESSAGES_LIMIT if args.duration else args.messages)
|
||||||
|
|
||||||
# oslo.config defaults
|
# oslo.config defaults
|
||||||
cfg.CONF.heartbeat_interval = 5
|
cfg.CONF.heartbeat_interval = 5
|
||||||
cfg.CONF.prog = os.path.basename(__file__)
|
cfg.CONF.prog = os.path.basename(__file__)
|
||||||
@ -449,7 +454,6 @@ def main():
|
|||||||
args.messages, args.wait_after_msg, args.timeout,
|
args.messages, args.wait_after_msg, args.timeout,
|
||||||
args.duration)
|
args.duration)
|
||||||
elif args.mode == 'rpc-client':
|
elif args.mode == 'rpc-client':
|
||||||
init_msg(args.messages)
|
|
||||||
targets = [target.partition('.')[::2] for target in args.targets]
|
targets = [target.partition('.')[::2] for target in args.targets]
|
||||||
start = datetime.datetime.now()
|
start = datetime.datetime.now()
|
||||||
targets = [messaging.Target(
|
targets = [messaging.Target(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user