mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-03 20:27:54 +00:00 
			
		
		
		
	Create cv_to_grafana and make fixes
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
		@@ -363,7 +363,7 @@ class cv_test(Realm):
 | 
				
			|||||||
                print("Detected test is not running.")
 | 
					                print("Detected test is not running.")
 | 
				
			||||||
                not_running += 1
 | 
					                not_running += 1
 | 
				
			||||||
                if not_running > 5:
 | 
					                if not_running > 5:
 | 
				
			||||||
                    break;
 | 
					                    break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            time.sleep(1)
 | 
					            time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -142,7 +142,7 @@ class CreateChamberview(cv):
 | 
				
			|||||||
                                            VLAN
 | 
					                                            VLAN
 | 
				
			||||||
                                            );  # To manage scenario
 | 
					                                            );  # To manage scenario
 | 
				
			||||||
        if not line and not raw_line:
 | 
					        if not line and not raw_line:
 | 
				
			||||||
            raise Exception("scenario sceation failed")
 | 
					            raise Exception("scenario creation failed")
 | 
				
			||||||
            return False
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
@@ -210,7 +210,7 @@ def main():
 | 
				
			|||||||
    if args.delete_scenario:
 | 
					    if args.delete_scenario:
 | 
				
			||||||
        Create_Chamberview.clean_cv_scenario(type="Network-Connectivity", scenario_name=args.create_scenario)
 | 
					        Create_Chamberview.clean_cv_scenario(type="Network-Connectivity", scenario_name=args.create_scenario)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Create_Chamberview.setup( create_scenario=args.create_scenario,
 | 
					    Create_Chamberview.setup(create_scenario=args.create_scenario,
 | 
				
			||||||
                             line=args.line,
 | 
					                             line=args.line,
 | 
				
			||||||
                             raw_line=args.raw_line)
 | 
					                             raw_line=args.raw_line)
 | 
				
			||||||
    Create_Chamberview.build(args.create_scenario)
 | 
					    Create_Chamberview.build(args.create_scenario)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										255
									
								
								py-scripts/cv_to_grafana.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										255
									
								
								py-scripts/cv_to_grafana.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,255 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					'''
 | 
				
			||||||
 | 
					This script loads and builds a Chamber View Scenario, runs WiFi Capacity Test, runs Dataplane Test,
 | 
				
			||||||
 | 
					and posts the results to Influx.
 | 
				
			||||||
 | 
					There are optional arguments which will create a Grafana dashboard which will import the data posted to
 | 
				
			||||||
 | 
					Influx from this script.
 | 
				
			||||||
 | 
					./cv_to_grafana.py
 | 
				
			||||||
 | 
					--mgr 192.168.1.4
 | 
				
			||||||
 | 
					--influx_host 192.168.100.201
 | 
				
			||||||
 | 
					--influx_token TOKEN
 | 
				
			||||||
 | 
					--influx_tag testbed Stidmatt-01
 | 
				
			||||||
 | 
					--influx_bucket stidmatt
 | 
				
			||||||
 | 
					--influx_org Candela
 | 
				
			||||||
 | 
					--pull_report
 | 
				
			||||||
 | 
					--ssid_dut "ssid_idx=0 ssid=lanforge security=WPA2 password=password bssid=04:f0:21:2c:41:84"
 | 
				
			||||||
 | 
					--line "Resource=1.1 Profile=default Amount=4 Uses-1=wiphy1 DUT=DUT_TO_GRAFANA_DUT Traffic=wiphy1 Freq=-1"
 | 
				
			||||||
 | 
					--line "Resource=1.1 Profile=upstream Amount=1 Uses-1=eth1 DUT=DUT_TO_GRAFANA_DUT Traffic=eth1 Freq=-1"
 | 
				
			||||||
 | 
					--dut DUT_TO_GRAFANA
 | 
				
			||||||
 | 
					--test_rig Stidmatt-01
 | 
				
			||||||
 | 
					--create_scenario DUT_TO_GRAFANA_SCENARIO
 | 
				
			||||||
 | 
					--station 1.1.sta00002
 | 
				
			||||||
 | 
					--duration 15s
 | 
				
			||||||
 | 
					--upstream 1.1.eth1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OPTIONAL GRAFANA ARGUMENTS
 | 
				
			||||||
 | 
					--grafana_token TOKEN
 | 
				
			||||||
 | 
					--grafana_host 192.168.100.201
 | 
				
			||||||
 | 
					--title "Grafana Dashboard"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The Grafana arguments are only required once. After the Grafana dashboard is built it will automatically update
 | 
				
			||||||
 | 
					as more data is added to the Influx database. Running the Grafana arguments to create a dashboard will do nothing.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The pull_report flag is to be used when running this on a computer which is different from the LANforge Manager.
 | 
				
			||||||
 | 
					It downloads the reports to the device which is running the script.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Each line argument adds a line to the Chamber View Scenario which you create in the script.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DUT flag gives the name of the DUT which is created by this script. It can be found in the DUT tab in LANforge Manager.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The station flag tells Dataplane test which station to test with.
 | 
				
			||||||
 | 
					'''
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
 | 
					import argparse
 | 
				
			||||||
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if sys.version_info[0] != 3:
 | 
				
			||||||
 | 
					    print("This script requires Python 3")
 | 
				
			||||||
 | 
					    exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if 'py-json' not in sys.path:
 | 
				
			||||||
 | 
					    sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
 | 
				
			||||||
 | 
					    sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from lf_wifi_capacity_test import WiFiCapacityTest
 | 
				
			||||||
 | 
					from cv_test_manager import *
 | 
				
			||||||
 | 
					from create_chamberview_dut import DUT
 | 
				
			||||||
 | 
					from create_chamberview import CreateChamberview
 | 
				
			||||||
 | 
					from lf_dataplane_test import DataplaneTest
 | 
				
			||||||
 | 
					from grafana_profile import UseGrafana
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
 | 
					    parser = argparse.ArgumentParser(
 | 
				
			||||||
 | 
					        prog='cv_to_grafana.py',
 | 
				
			||||||
 | 
					        formatter_class=argparse.RawTextHelpFormatter,
 | 
				
			||||||
 | 
					        epilog='''Run Wifi Capacity and Dataplane Test and record results to Grafana''',
 | 
				
			||||||
 | 
					        description='''\
 | 
				
			||||||
 | 
					        cv_to_grafana.py
 | 
				
			||||||
 | 
					        ------------------
 | 
				
			||||||
 | 
					        ./cv_to_grafana.py
 | 
				
			||||||
 | 
					            --mgr 
 | 
				
			||||||
 | 
					            --influx_host
 | 
				
			||||||
 | 
					            --influx_token
 | 
				
			||||||
 | 
					            --influx_tag testbed
 | 
				
			||||||
 | 
					            --influx_bucket 
 | 
				
			||||||
 | 
					            --influx_org 
 | 
				
			||||||
 | 
					            --pull_report
 | 
				
			||||||
 | 
					            --ssid_dut 
 | 
				
			||||||
 | 
					            --line 
 | 
				
			||||||
 | 
					            --line
 | 
				
			||||||
 | 
					            --dut 
 | 
				
			||||||
 | 
					            --test_rig
 | 
				
			||||||
 | 
					            --create_scenario
 | 
				
			||||||
 | 
					            --station 
 | 
				
			||||||
 | 
					            --influx_tag 
 | 
				
			||||||
 | 
					            --duration 
 | 
				
			||||||
 | 
					            --upstream 
 | 
				
			||||||
 | 
					            '''
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cv_add_base_parser(parser)  # see cv_test_manager.py
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    parser.add_argument("-b", "--batch_size", type=str, default="",
 | 
				
			||||||
 | 
					                        help="station increment ex. 1,2,3")
 | 
				
			||||||
 | 
					    parser.add_argument("-l", "--loop_iter", type=str, default="",
 | 
				
			||||||
 | 
					                        help="Loop iteration ex. 1")
 | 
				
			||||||
 | 
					    parser.add_argument("-p", "--protocol", type=str, default="",
 | 
				
			||||||
 | 
					                        help="Protocol ex.TCP-IPv4")
 | 
				
			||||||
 | 
					    parser.add_argument("-d", "--duration", type=str, default="",
 | 
				
			||||||
 | 
					                        help="duration in ms. ex. 5000")
 | 
				
			||||||
 | 
					    parser.add_argument("--download_rate", type=str, default="1Gbps",
 | 
				
			||||||
 | 
					                        help="Select requested download rate.  Kbps, Mbps, Gbps units supported.  Default is 1Gbps")
 | 
				
			||||||
 | 
					    parser.add_argument("--upload_rate", type=str, default="10Mbps",
 | 
				
			||||||
 | 
					                        help="Select requested upload rate.  Kbps, Mbps, Gbps units supported.  Default is 10Mbps")
 | 
				
			||||||
 | 
					    parser.add_argument("--sort", type=str, default="interleave",
 | 
				
			||||||
 | 
					                        help="Select station sorting behaviour:  none | interleave | linear  Default is interleave.")
 | 
				
			||||||
 | 
					    parser.add_argument('--number_template', help='Start the station numbering with a particular number. Default is 0000',
 | 
				
			||||||
 | 
					                        default=0000)
 | 
				
			||||||
 | 
					    parser.add_argument('--mode', help='Used to force mode of stations')
 | 
				
			||||||
 | 
					    parser.add_argument('--ap', help='Used to force a connection to a particular AP')
 | 
				
			||||||
 | 
					    parser.add_argument("--num_stations", default=2)
 | 
				
			||||||
 | 
					    parser.add_argument("--mgr_port", default=8080)
 | 
				
			||||||
 | 
					    parser.add_argument("--upstream_port", default="1.1.eth1")
 | 
				
			||||||
 | 
					    parser.add_argument("--scenario", help="", default=None)
 | 
				
			||||||
 | 
					    parser.add_argument("--line", action='append', nargs='+',
 | 
				
			||||||
 | 
					                        help="line number", default=[])
 | 
				
			||||||
 | 
					    parser.add_argument("-ds", "--delete_scenario", default=False, action='store_true',
 | 
				
			||||||
 | 
					                        help="delete scenario (by default: False)")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    parser.add_argument("--create_scenario", "--create_lf_scenario", type=str,
 | 
				
			||||||
 | 
					                        help="name of scenario to be created")
 | 
				
			||||||
 | 
					    parser.add_argument("-u", "--upstream", type=str, default="",
 | 
				
			||||||
 | 
					                        help="Upstream port for wifi capacity test ex. 1.1.eth2")
 | 
				
			||||||
 | 
					    parser.add_argument("--station", type=str, default="",
 | 
				
			||||||
 | 
					                        help="Station to be used in this test, example: 1.1.sta01500")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    parser.add_argument("--dut", default="",
 | 
				
			||||||
 | 
					                        help="Specify DUT used by this test, example: linksys-8450")
 | 
				
			||||||
 | 
					    parser.add_argument("--download_speed", default="",
 | 
				
			||||||
 | 
					                        help="Specify requested download speed.  Percentage of theoretical is also supported.  Default: 85%")
 | 
				
			||||||
 | 
					    parser.add_argument("--upload_speed", default="",
 | 
				
			||||||
 | 
					                        help="Specify requested upload speed.  Percentage of theoretical is also supported.  Default: 0")
 | 
				
			||||||
 | 
					    parser.add_argument("--graph_groups", help="File to save graph_groups to", default=None)
 | 
				
			||||||
 | 
					    parser.add_argument("--ssid_dut", action='append', nargs=1, help="SSID", default=[])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    parser.add_argument("--sw_version", default="NA", help="DUT Software version.")
 | 
				
			||||||
 | 
					    parser.add_argument("--hw_version", default="NA", help="DUT Hardware version.")
 | 
				
			||||||
 | 
					    parser.add_argument("--serial_num", default="NA", help="DUT Serial number.")
 | 
				
			||||||
 | 
					    parser.add_argument("--model_num", default="NA", help="DUT Model Number.")
 | 
				
			||||||
 | 
					    parser.add_argument("--report_dir", default="")
 | 
				
			||||||
 | 
					    parser.add_argument('--grafana_token', help='token to access your Grafana database')
 | 
				
			||||||
 | 
					    parser.add_argument('--grafana_port', help='Grafana port if different from 3000', default=3000)
 | 
				
			||||||
 | 
					    parser.add_argument('--grafana_host', help='Grafana host', default='localhost')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    args = parser.parse_args()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cv_base_adjust_parser(args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Create/update new DUT
 | 
				
			||||||
 | 
					    print("Make new DUT")
 | 
				
			||||||
 | 
					    new_dut = DUT(lfmgr=args.mgr,
 | 
				
			||||||
 | 
					                  port=args.port,
 | 
				
			||||||
 | 
					                  dut_name=args.dut,
 | 
				
			||||||
 | 
					                  ssid=args.ssid_dut,
 | 
				
			||||||
 | 
					                  sw_version=args.sw_version,
 | 
				
			||||||
 | 
					                  hw_version=args.hw_version,
 | 
				
			||||||
 | 
					                  serial_num=args.serial_num,
 | 
				
			||||||
 | 
					                  model_num=args.model_num,
 | 
				
			||||||
 | 
					                  )
 | 
				
			||||||
 | 
					    new_dut.setup()
 | 
				
			||||||
 | 
					    new_dut.add_ssids()
 | 
				
			||||||
 | 
					    new_dut.cv_test.show_text_blob(None, None, True)  # Show changes on GUI
 | 
				
			||||||
 | 
					    new_dut.cv_test.sync_cv()
 | 
				
			||||||
 | 
					    time.sleep(2)
 | 
				
			||||||
 | 
					    new_dut.cv_test.sync_cv()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    print("Build Chamber View Scenario")
 | 
				
			||||||
 | 
					    Create_Chamberview = CreateChamberview(lfmgr=args.mgr,
 | 
				
			||||||
 | 
					                                           port=args.port,
 | 
				
			||||||
 | 
					                                           )
 | 
				
			||||||
 | 
					    if args.delete_scenario:
 | 
				
			||||||
 | 
					        Create_Chamberview.clean_cv_scenario(type="Network-Connectivity", scenario_name=args.create_scenario)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Create_Chamberview.setup(create_scenario=args.create_scenario,
 | 
				
			||||||
 | 
					                             line=args.line,
 | 
				
			||||||
 | 
					                             raw_line=args.raw_line)
 | 
				
			||||||
 | 
					    Create_Chamberview.build(args.create_scenario)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    print("Run WiFi Capacity Test")
 | 
				
			||||||
 | 
					    wifi_capacity = WiFiCapacityTest(lfclient_host=args.mgr,
 | 
				
			||||||
 | 
					                                     lf_port=args.mgr_port,
 | 
				
			||||||
 | 
					                                     lf_user=args.lf_user,
 | 
				
			||||||
 | 
					                                     lf_password=args.lf_password,
 | 
				
			||||||
 | 
					                                     instance_name='testing',
 | 
				
			||||||
 | 
					                                     config_name=args.config_name,
 | 
				
			||||||
 | 
					                                     upstream=args.upstream_port,
 | 
				
			||||||
 | 
					                                     batch_size=args.batch_size,
 | 
				
			||||||
 | 
					                                     loop_iter=args.loop_iter,
 | 
				
			||||||
 | 
					                                     protocol=args.protocol,
 | 
				
			||||||
 | 
					                                     duration=args.duration,
 | 
				
			||||||
 | 
					                                     pull_report=args.pull_report,
 | 
				
			||||||
 | 
					                                     load_old_cfg=args.load_old_cfg,
 | 
				
			||||||
 | 
					                                     download_rate=args.download_rate,
 | 
				
			||||||
 | 
					                                     upload_rate=args.upload_rate,
 | 
				
			||||||
 | 
					                                     sort=args.sort,
 | 
				
			||||||
 | 
					                                     enables=args.enable,
 | 
				
			||||||
 | 
					                                     disables=args.disable,
 | 
				
			||||||
 | 
					                                     raw_lines=args.raw_line,
 | 
				
			||||||
 | 
					                                     raw_lines_file=args.raw_lines_file,
 | 
				
			||||||
 | 
					                                     sets=args.set)
 | 
				
			||||||
 | 
					    wifi_capacity.apply_cv_scenario(args.scenario)
 | 
				
			||||||
 | 
					    wifi_capacity.build_cv_scenario()
 | 
				
			||||||
 | 
					    wifi_capacity.setup()
 | 
				
			||||||
 | 
					    wifi_capacity.run()
 | 
				
			||||||
 | 
					    wifi_capacity.check_influx_kpi(args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    print("Run Dataplane test")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CV_Test = DataplaneTest(lf_host=args.mgr,
 | 
				
			||||||
 | 
					                            lf_port=args.port,
 | 
				
			||||||
 | 
					                            lf_user=args.lf_user,
 | 
				
			||||||
 | 
					                            lf_password=args.lf_password,
 | 
				
			||||||
 | 
					                            instance_name='dataplane-instance',
 | 
				
			||||||
 | 
					                            config_name=args.config_name,
 | 
				
			||||||
 | 
					                            upstream=args.upstream,
 | 
				
			||||||
 | 
					                            pull_report=args.pull_report,
 | 
				
			||||||
 | 
					                            load_old_cfg=args.load_old_cfg,
 | 
				
			||||||
 | 
					                            download_speed=args.download_speed,
 | 
				
			||||||
 | 
					                            upload_speed=args.upload_speed,
 | 
				
			||||||
 | 
					                            duration=args.duration,
 | 
				
			||||||
 | 
					                            dut=args.dut,
 | 
				
			||||||
 | 
					                            station=args.station,
 | 
				
			||||||
 | 
					                            enables=args.enable,
 | 
				
			||||||
 | 
					                            disables=args.disable,
 | 
				
			||||||
 | 
					                            raw_lines=args.raw_line,
 | 
				
			||||||
 | 
					                            raw_lines_file=args.raw_lines_file,
 | 
				
			||||||
 | 
					                            sets=args.set,
 | 
				
			||||||
 | 
					                            graph_groups=args.graph_groups
 | 
				
			||||||
 | 
					                            )
 | 
				
			||||||
 | 
					    CV_Test.setup()
 | 
				
			||||||
 | 
					    CV_Test.run()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CV_Test.check_influx_kpi(args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if args.grafana_token:
 | 
				
			||||||
 | 
					        print("Create Grafana dashboard")
 | 
				
			||||||
 | 
					        Grafana = UseGrafana(args.grafana_token,
 | 
				
			||||||
 | 
					                             args.grafana_port,
 | 
				
			||||||
 | 
					                             args.grafana_host
 | 
				
			||||||
 | 
					                             )
 | 
				
			||||||
 | 
					        Grafana.create_custom_dashboard(scripts=args.scripts,
 | 
				
			||||||
 | 
					                                        title=args.title,
 | 
				
			||||||
 | 
					                                        bucket=args.influx_bucket,
 | 
				
			||||||
 | 
					                                        graph_groups=args.graph_groups,
 | 
				
			||||||
 | 
					                                        graph_groups_file=args.graph_groups_file,
 | 
				
			||||||
 | 
					                                        testbed=args.testbed,
 | 
				
			||||||
 | 
					                                        datasource=args.datasource,
 | 
				
			||||||
 | 
					                                        from_date=args.from_date,
 | 
				
			||||||
 | 
					                                        graph_height=args.graph_height,
 | 
				
			||||||
 | 
					                                        graph__width=args.graph_width)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
@@ -110,10 +110,11 @@ if sys.version_info[0] != 3:
 | 
				
			|||||||
if 'py-json' not in sys.path:
 | 
					if 'py-json' not in sys.path:
 | 
				
			||||||
    sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
 | 
					    sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cv_test_manager import cv_test as cvtest
 | 
					from cv_test_manager import cv_test
 | 
				
			||||||
from cv_test_manager import *
 | 
					from cv_test_manager import *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DataplaneTest(cvtest):
 | 
					
 | 
				
			||||||
 | 
					class DataplaneTest(cv_test):
 | 
				
			||||||
    def __init__(self,
 | 
					    def __init__(self,
 | 
				
			||||||
                 lf_host="localhost",
 | 
					                 lf_host="localhost",
 | 
				
			||||||
                 lf_port=8080,
 | 
					                 lf_port=8080,
 | 
				
			||||||
@@ -134,14 +135,15 @@ class DataplaneTest(cvtest):
 | 
				
			|||||||
                 raw_lines=[],
 | 
					                 raw_lines=[],
 | 
				
			||||||
                 raw_lines_file="",
 | 
					                 raw_lines_file="",
 | 
				
			||||||
                 sets=[],
 | 
					                 sets=[],
 | 
				
			||||||
                 graph_groups=None
 | 
					                 graph_groups=None,
 | 
				
			||||||
 | 
					                 report_dir=""
 | 
				
			||||||
                 ):
 | 
					                 ):
 | 
				
			||||||
        super().__init__(lfclient_host=lf_host, lfclient_port=lf_port)
 | 
					        super().__init__(lfclient_host=lf_host, lfclient_port=lf_port)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.lf_host = lf_host
 | 
					        self.lf_host = lf_host
 | 
				
			||||||
        self.lf_port = lf_port
 | 
					        self.lf_port = lf_port
 | 
				
			||||||
        self.lf_user = lf_user
 | 
					        self.lf_user = lf_user
 | 
				
			||||||
        self.lf_password =lf_password
 | 
					        self.lf_password = lf_password
 | 
				
			||||||
        self.instance_name = instance_name
 | 
					        self.instance_name = instance_name
 | 
				
			||||||
        self.config_name = config_name
 | 
					        self.config_name = config_name
 | 
				
			||||||
        self.dut = dut
 | 
					        self.dut = dut
 | 
				
			||||||
@@ -159,12 +161,12 @@ class DataplaneTest(cvtest):
 | 
				
			|||||||
        self.raw_lines_file = raw_lines_file
 | 
					        self.raw_lines_file = raw_lines_file
 | 
				
			||||||
        self.sets = sets
 | 
					        self.sets = sets
 | 
				
			||||||
        self.graph_groups = graph_groups
 | 
					        self.graph_groups = graph_groups
 | 
				
			||||||
 | 
					        self.report_dir = report_dir
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setup(self):
 | 
					    def setup(self):
 | 
				
			||||||
        # Nothing to do at this time.
 | 
					        # Nothing to do at this time.
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def run(self):
 | 
					    def run(self):
 | 
				
			||||||
        self.sync_cv()
 | 
					        self.sync_cv()
 | 
				
			||||||
        time.sleep(2)
 | 
					        time.sleep(2)
 | 
				
			||||||
@@ -208,7 +210,6 @@ class DataplaneTest(cvtest):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
 | 
					 | 
				
			||||||
    parser = argparse.ArgumentParser("""
 | 
					    parser = argparse.ArgumentParser("""
 | 
				
			||||||
    Open this file in an editor and read the top notes for more details.
 | 
					    Open this file in an editor and read the top notes for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -247,6 +248,7 @@ def main():
 | 
				
			|||||||
    parser.add_argument("--duration", default="",
 | 
					    parser.add_argument("--duration", default="",
 | 
				
			||||||
                        help="Specify duration of each traffic run")
 | 
					                        help="Specify duration of each traffic run")
 | 
				
			||||||
    parser.add_argument("--graph_groups", help="File to save graph_groups to", default=None)
 | 
					    parser.add_argument("--graph_groups", help="File to save graph_groups to", default=None)
 | 
				
			||||||
 | 
					    parser.add_argument("--report_dir", default="")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    args = parser.parse_args()
 | 
					    args = parser.parse_args()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -278,5 +280,6 @@ def main():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    CV_Test.check_influx_kpi(args)
 | 
					    CV_Test.check_influx_kpi(args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
    main()
 | 
					    main()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,8 @@ Note: This is a test file which will run a wifi capacity test.
 | 
				
			|||||||
             --test_rig Testbed-01 \
 | 
					             --test_rig Testbed-01 \
 | 
				
			||||||
             --influx_host c7-graphana --influx_port 8086 --influx_org Candela \
 | 
					             --influx_host c7-graphana --influx_port 8086 --influx_org Candela \
 | 
				
			||||||
             --influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
 | 
					             --influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
 | 
				
			||||||
             --influx_bucket ben --influx_tag testbed Ferndale-01
 | 
					             --influx_bucket ben \
 | 
				
			||||||
 | 
					             --influx_tag testbed Ferndale-01
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ex. on how to run this script (to create new stations):
 | 
					    ex. on how to run this script (to create new stations):
 | 
				
			||||||
    ./lf_wifi_capacity_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \
 | 
					    ./lf_wifi_capacity_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,99 +0,0 @@
 | 
				
			|||||||
#!/usr/bin/env python3
 | 
					 | 
				
			||||||
'''
 | 
					 | 
				
			||||||
This script loads and builds a Chamber View Scenario, runs WiFi Capacity Test, and posts the results to Grafana
 | 
					 | 
				
			||||||
'''
 | 
					 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
import os
 | 
					 | 
				
			||||||
import argparse
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if sys.version_info[0] != 3:
 | 
					 | 
				
			||||||
    print("This script requires Python 3")
 | 
					 | 
				
			||||||
    exit(1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if 'py-json' not in sys.path:
 | 
					 | 
				
			||||||
    sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
 | 
					 | 
				
			||||||
    sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard'))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from lf_wifi_capacity_test import WiFiCapacityTest
 | 
					 | 
				
			||||||
from cv_test_manager import *
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def main():
 | 
					 | 
				
			||||||
    parser = argparse.ArgumentParser(
 | 
					 | 
				
			||||||
        prog='wifi_cap_to_grafana.py',
 | 
					 | 
				
			||||||
        formatter_class=argparse.RawTextHelpFormatter,
 | 
					 | 
				
			||||||
        epilog='''Run Wifi Capacity and record results to Grafana''',
 | 
					 | 
				
			||||||
        description='''\
 | 
					 | 
				
			||||||
        wifi_cap_to_grafana.py
 | 
					 | 
				
			||||||
        ------------------
 | 
					 | 
				
			||||||
        ./wifi_cap_to_grafana.py
 | 
					 | 
				
			||||||
            --num_stations
 | 
					 | 
				
			||||||
            --grafana_token
 | 
					 | 
				
			||||||
            --influx_host
 | 
					 | 
				
			||||||
            --influx_org
 | 
					 | 
				
			||||||
            --influx_token
 | 
					 | 
				
			||||||
            --influx_bucket
 | 
					 | 
				
			||||||
            --target_csv
 | 
					 | 
				
			||||||
            --panel_name
 | 
					 | 
				
			||||||
            --dut_name'''
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cv_add_base_parser(parser)  # see cv_test_manager.py
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    parser.add_argument("-b", "--batch_size", type=str, default="",
 | 
					 | 
				
			||||||
                        help="station increment ex. 1,2,3")
 | 
					 | 
				
			||||||
    parser.add_argument("-l", "--loop_iter", type=str, default="",
 | 
					 | 
				
			||||||
                        help="Loop iteration ex. 1")
 | 
					 | 
				
			||||||
    parser.add_argument("-p", "--protocol", type=str, default="",
 | 
					 | 
				
			||||||
                        help="Protocol ex.TCP-IPv4")
 | 
					 | 
				
			||||||
    parser.add_argument("-d", "--duration", type=str, default="",
 | 
					 | 
				
			||||||
                        help="duration in ms. ex. 5000")
 | 
					 | 
				
			||||||
    parser.add_argument("--download_rate", type=str, default="1Gbps",
 | 
					 | 
				
			||||||
                        help="Select requested download rate.  Kbps, Mbps, Gbps units supported.  Default is 1Gbps")
 | 
					 | 
				
			||||||
    parser.add_argument("--upload_rate", type=str, default="10Mbps",
 | 
					 | 
				
			||||||
                        help="Select requested upload rate.  Kbps, Mbps, Gbps units supported.  Default is 10Mbps")
 | 
					 | 
				
			||||||
    parser.add_argument("--sort", type=str, default="interleave",
 | 
					 | 
				
			||||||
                        help="Select station sorting behaviour:  none | interleave | linear  Default is interleave.")
 | 
					 | 
				
			||||||
    parser.add_argument('--number_template', help='Start the station numbering with a particular number. Default is 0000',
 | 
					 | 
				
			||||||
                        default=0000)
 | 
					 | 
				
			||||||
    parser.add_argument('--mode', help='Used to force mode of stations')
 | 
					 | 
				
			||||||
    parser.add_argument('--ap', help='Used to force a connection to a particular AP')
 | 
					 | 
				
			||||||
    parser.add_argument("--num_stations", default=2)
 | 
					 | 
				
			||||||
    parser.add_argument("--mgr_port", default=8080)
 | 
					 | 
				
			||||||
    parser.add_argument("--upstream_port", default="1.1.eth1")
 | 
					 | 
				
			||||||
    parser.add_argument("--scenario", help="", default=None)
 | 
					 | 
				
			||||||
    args = parser.parse_args()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cv_base_adjust_parser(args)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Run WiFi Capacity Test
 | 
					 | 
				
			||||||
    wifi_capacity = WiFiCapacityTest(lfclient_host=args.mgr,
 | 
					 | 
				
			||||||
                                     lf_port=args.mgr_port,
 | 
					 | 
				
			||||||
                                     lf_user=args.lf_user,
 | 
					 | 
				
			||||||
                                     lf_password=args.lf_password,
 | 
					 | 
				
			||||||
                                     instance_name=args.instance_name,
 | 
					 | 
				
			||||||
                                     config_name=args.config_name,
 | 
					 | 
				
			||||||
                                     upstream=args.upstream_port,
 | 
					 | 
				
			||||||
                                     batch_size=args.batch_size,
 | 
					 | 
				
			||||||
                                     loop_iter=args.loop_iter,
 | 
					 | 
				
			||||||
                                     protocol=args.protocol,
 | 
					 | 
				
			||||||
                                     duration=args.duration,
 | 
					 | 
				
			||||||
                                     pull_report=args.pull_report,
 | 
					 | 
				
			||||||
                                     load_old_cfg=args.load_old_cfg,
 | 
					 | 
				
			||||||
                                     download_rate=args.download_rate,
 | 
					 | 
				
			||||||
                                     upload_rate=args.upload_rate,
 | 
					 | 
				
			||||||
                                     sort=args.sort,
 | 
					 | 
				
			||||||
                                     enables=args.enable,
 | 
					 | 
				
			||||||
                                     disables=args.disable,
 | 
					 | 
				
			||||||
                                     raw_lines=args.raw_line,
 | 
					 | 
				
			||||||
                                     raw_lines_file=args.raw_lines_file,
 | 
					 | 
				
			||||||
                                     sets=args.set)
 | 
					 | 
				
			||||||
    wifi_capacity.apply_cv_scenario(args.scenario)
 | 
					 | 
				
			||||||
    wifi_capacity.build_cv_scenario()
 | 
					 | 
				
			||||||
    wifi_capacity.setup()
 | 
					 | 
				
			||||||
    wifi_capacity.run()
 | 
					 | 
				
			||||||
    wifi_capacity.check_influx_kpi(args)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if __name__ == "__main__":
 | 
					 | 
				
			||||||
    main()
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user