traffic_replay: Avoid Exception if no packet rate is specified
authorTim Beale <timbeale@catalyst.net.nz>
Wed, 10 Apr 2019 01:12:30 +0000 (13:12 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 30 Apr 2019 23:18:28 +0000 (23:18 +0000)
traffic_replay would throw an exception if you didn't specify some sort
of packet rate. We can avoid this by using --scale-traffic=1.0 as the
default if nothing else was specified.

 script/traffic_replay model.txt $SERVER.$REALM --duration=10
   --fixed-password=blahblah12# -U$USERNAME%$PASSWORD
INFO 2019-04-10 01:03:01,809 pid:47755 script/traffic_replay #280: Using
the specified model file to generate conversations
Traceback (most recent call last):
  File "script/traffic_replay", line 438, in <module>
    main()
  File "script/traffic_replay", line 293, in main
    opts.conversation_persistence)
  File "bin/python/samba/emulate/traffic.py", line 1295, in
generate_conversation_sequences
    target_packets = int(packet_rate * duration)
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
script/traffic_replay

index 0d06d1c861dc5ea76ad49c798d57e96da43439c8..77eef7c0322bda95060985665c7d06dd1ce667c4 100755 (executable)
@@ -235,6 +235,10 @@ def main():
                      "are incompatible. Use one or the other.")
         sys.exit(1)
 
+    if not opts.scale_traffic and not opts.packets_per_second:
+        logger.info("No packet rate specified. Using --scale-traffic=1.0")
+        opts.scale_traffic = 1.0
+
     if opts.timing_data not in ('-', None):
         try:
             open(opts.timing_data, 'w').close()