Skip to content

Commit a90b8ac

Browse files
lf_interop_throughput.py: check cx states are running before testing
Added get_cx_states to retrieve current state of cross connects and wait to begin test duration until 'Run' status is returned. Verified with: ./lf_interop_throughput.py --mgr 192.168.91.50 --mgr_port 8080 --ssid Quincefruit --passwd lanforge --security wpa2 --upstream_port 1.050.01 --traffic_type lf_udp --download 100000000 --test_duration 1m --packet_size 1500 --incremental_capacity 1 --precleanup --postcleanup devices: 1.50,1.70 Signed-off-by: Cameron LaPlante <[email protected]>
1 parent 9ca2472 commit a90b8ac

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

py-scripts/lf_interop_throughput.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,19 @@ def cleanup(self):
604604
logger.info("cleanup done")
605605
self.cx_profile.cleanup()
606606

607+
def get_cx_states(self, device_names):
608+
'''
609+
Get the cx states of the devices (ie Run, Stopped, WAITING)
610+
'''
611+
cx_state_list = []
612+
for device in device_names:
613+
try:
614+
device_data = self.json_get('/cx/all')[device]
615+
cx_state_list.append(device_data['state'])
616+
except KeyError:
617+
logger.error("Error: %s key not found in cx data", device)
618+
return cx_state_list
619+
607620
def monitor(self, iteration, individual_df, device_names, incremental_capacity_list, overall_start_time, overall_end_time):
608621

609622
throughput, upload, download, upload_throughput, download_throughput, connections_upload, connections_download = {}, [], [], [], [], {}, {}
@@ -623,9 +636,19 @@ def monitor(self, iteration, individual_df, device_names, incremental_capacity_l
623636
connections_upload_realtime = dict.fromkeys(list(self.cx_profile.created_cx.keys()), float(0))
624637
connections_download_realtime = dict.fromkeys(list(self.cx_profile.created_cx.keys()), float(0))
625638

626-
# provide time for connections to start and then initiaize the start and end time.
627-
print("Waiting for connections to start...")
628-
time.sleep(10)
639+
# loop to get_cx_states until one return 'Running'
640+
cx_states_down = True
641+
logger.info("Waiting for cx to start")
642+
643+
while cx_states_down:
644+
states = self.get_cx_states(list(self.cx_profile.created_cx.keys()))
645+
logger.info("states: {}".format(states))
646+
647+
for cx_state in states:
648+
if cx_state == 'Run':
649+
cx_states_down = False
650+
time.sleep(2)
651+
629652
start_time = datetime.now()
630653
end_time = start_time + timedelta(seconds=int(self.test_duration))
631654
logger.info("Monitoring cx and endpoints")
@@ -1718,11 +1741,11 @@ def parse_args():
17181741
parser = argparse.ArgumentParser(
17191742
prog="lf_interop_throughputput.py",
17201743
formatter_class=argparse.RawTextHelpFormatter,
1721-
epilog='''\
1744+
epilog=r'''\
17221745
Provides the available devices and allows user to run the wifi capacity test
17231746
on particular devices by specifying direction as upload, download and bidirectional including different types of loads and incremental capacity.
17241747
''',
1725-
description='''\
1748+
description=r'''\
17261749
17271750
NAME: lf_interop_throughputput.py
17281751

0 commit comments

Comments
 (0)