def json_get(self, _req_url="/"): cli_base = LFCliBase( _lfjson_host=self.lanforge_ip, _lfjson_port=self.lanforge_port, ) json_response = cli_base.json_get(_req_url=_req_url) return json_response
def set_radio_antenna(self, req_url, shelf, resources, radio, antenna): data = { "shelf": shelf, "resource": resources, "radio": radio, "antenna": antenna } cli_base = LFCliBase( _lfjson_host=self.lanforge_ip, _lfjson_port=self.lanforge_port, ) return cli_base.json_post(req_url, data)
def json_post(self, req_url, shelf, resources, port, current, intrest): data = { "shelf": shelf, "resource": resources, "port": port, "current_flags": current, "interest": intrest } cli_base = LFCliBase( _lfjson_host=self.lanforge_ip, _lfjson_port=self.lanforge_port, ) return cli_base.json_post(req_url, data)
def main(): lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_ipv6_connection.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create stations that attempt to authenticate, associate, and receive IPV6 addresses on the chosen SSID ''', description='''\ test_ipv6_connection.py: -------------------- Generic command example: python3 ./test_ipv6_connection.py --upstream_port eth1 \\ --radio wiphy0 \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear \\ --passwd admin123 \\ --dest 10.40.0.1 \\ --test_duration 2m \\ --interval 1s \\ -- timeout 120 \\ --debug ''') parser.add_argument('--timeout', help='--timeout sets the length of time to wait until a connection is successful', default=120) args = parser.parse_args() num_sta=2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ipv6_test = IPv6Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, security=args.security, sta_list=station_list) ipv6_test.cleanup(station_list) ipv6_test.build() if not ipv6_test.passes(): print(ipv6_test.get_fail_message()) exit(1) ipv6_test.start(station_list, False, False) ipv6_test.stop() if not ipv6_test.passes(): print(ipv6_test.get_fail_message()) exit(1) time.sleep(10) ipv6_test.cleanup(station_list) if ipv6_test.passes(): print("Full test passed, all stations associated and got IP")
def main(): lfjson_host = "localhost" lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='example_wpa_connection.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Example code that creates a specified amount of stations on a specified SSID using WPA security. ''', description='''\ example_wpa_connection.py -------------------- Generic command example: python3 ./example_wpa_connection.py \\ --host localhost (optional) \\ --port 8080 (optional) \\ --num_stations 3 \\ --ssid netgear-wpa \\ --passwd admin123-wpa \\ --radio wiphy1 --debug ''') parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") parser.add_argument( '--url', help='--url specifies upload/download, address, and dest', default="dl http://10.40.0.1 /dev/null") args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000, radio=args.radio) ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd, radio=args.radio, security="wpa", sta_list=station_list) ip_test.cleanup(station_list) ip_test.timeout = 60 ip_test.build()
def main(): lfjson_host = "localhost" lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='example_wpa3_connection.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Example code that creates a specified amount of stations on a specified SSID using WPA3 security. ''', description='''\ example_wpa_connection.py -------------------- Generic command example: python3 ./example_wpa_connection.py \\ --host localhost (optional) \\ --port 8080 (optional) \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear-wpa3 \\ --passwd admin123-wpa3 \\ --debug Note: multiple --radio switches may be entered up to the number of radios available: --radio wiphy0 <stations> <ssid> <ssid password> --radio <radio 01> <number of last station> <ssid> <ssid password> ''') args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000, radio=args.radio) ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd, radio=args.radio, security=args.security, sta_list=station_list) ip_test.cleanup(station_list) ip_test.timeout = 60 ip_test.build()
def main(): # This has --mgr, --mgr_port and --debug parser = LFCliBase.create_bare_argparse( prog="layer3_test.py", formatter_class=argparse.RawTextHelpFormatter, epilog="About This Script") # Adding More Arguments for custom use parser.add_argument('--ssid', help='--ssid of DUT', default="lexusdut") parser.add_argument('--passwd', help='--passwd of dut', default="[BLANK]") parser.add_argument('--radio', help='--radio to use on LANforge', default="wiphy1") parser.add_argument('--security', help='--security of dut', default="open") parser.add_argument('--session_id', help='--session_id is for websocket', default="local") parser.add_argument('--test_name', help='--test_name is for webconsole reports', default="Client Connectivity Test") parser.add_argument( '--num_clients', type=int, help='--num_sta is number of stations you want to create', default=2) parser.add_argument( '--pass_criteria', type=int, help='--pass_criteria is pass criteria for connection Time', default=50) args = parser.parse_args() # args.session_id = "local"; print(args) # Start Test obj = ConnectionTest(lfclient_host="192.168.200.15", lfclient_port=args.mgr_port, session_id=args.session_id, test_name=args.test_name, dut_ssid=args.ssid, dut_passwd=args.passwd, dut_security=args.security, num_sta=args.num_clients, radio=args.radio, pass_criteria=args.pass_criteria) obj.precleanup() obj.build() obj.start() obj.stop() obj.postcleanup()
def main(): lfjson_host = "localhost" lfjson_port = 8080 argparser = LFCliBase.create_basic_argparse( prog=__file__, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ creates lots of stations across multiple radios. ''', description='''\ test_1k_clients_jedtest.py: -------------------- Generic command layout: python3 ./test_1k_clients_jedtest.py --sta_per_radio 300 --test_duration 3m --a_min 1000 --b_min 1000 --debug ''') argparser.add_argument("--sta_per_radio", type=int, help="number of stations per radio") argparser.add_argument("--test_duration", type=int, help="length of test duration") args = argparser.parse_args() kilo_test = Test1KClients(lfjson_host, lfjson_port, upstream=args.upstream_port, num_sta_=args.sta_per_radio, _debug_on=args.debug) kilo_test.pre_cleanup() kilo_test.build() if not kilo_test.passes(): kilo_test.exit_failed() kilo_test.start() if not kilo_test.passes(): kilo_test.exit_failed() kilo_test.stop() if not kilo_test.passes(): kilo_test.exit_failed() time.sleep(60) kilo_test.post_cleanup() kilo_test.exit_success()
def main(): lfjson_host = "localhost" lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='example_security_connection.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Example flags and command line input to run the script. ''', description='''\ example_security_connection.py -------------------- This python script creates an inputted number of stations using user-inputted security. This verifies that the most basic form of security works with the LANforge device. -------------------- Generic command example: python3 ./example_security_connection.py \\ --host localhost (optional) \\ --port 8080 (optional) \\ --num_stations 6 \\ --radio wiphy2 --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear-wpa3 \\ --passwd admin123-wpa3 \\ --debug ''') args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd, radio=args.radio, security=args.security, sta_list=station_list) ip_test.cleanup(station_list) ip_test.timeout = 60 ip_test.build()
def main(): lfjson_host = "localhost" lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='example_wpa3_connection.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Example code that creates a specified amount of stations on a specified SSID using WPA3 security. ''', description='''\ example_wpa3_connection.py -------------------- Generic command example: python3 ./example_wpa3_connection.py --host localhost (optional) --port 8080 (optional) --num_stations 3 --ssid netgear-wpa3 --passwd admin123-wpa3 --radio wiphy1 --debug ''') args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000, radio=args.radio) ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd, radio=args.radio, security="wpa3", sta_list=station_list) ip_test.cleanup(station_list) ip_test.timeout = 60 ip_test.build()
def main(): parser = LFCliBase.create_bare_argparse(prog=__name__, description='''\ Example: ./port_probe.py --port 1.1.eth0 ''') parser.add_argument('--mode', help='Used to force mode of stations') parser.add_argument('--port_eid', help='EID of station to be used', default="1.1.eth0") args = parser.parse_args() probe = ProbePort2(lfhost=args.mgr, lfport=args.mgr_port, debug=args.debug, eid_str=args.port_eid) probe.run()
def main(): parser = LFCliBase.create_basic_argparse( prog='example_open_connection.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Example code that creates a specified amount of stations on a specified SSID using Open security. ''', description='''\ example_open_connection.py -------------------- Generic command example: python3 ./example_open_connection.py --mgr localhost --mgr_port 8080 --num_stations 3 --radio wiphy1 --ssid netgear-open --passwd [BLANK] --debug ''') args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_sta = int(args.num_stations) station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000) ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, security="open", radio=args.radio, sta_list=station_list) ip_test.cleanup(station_list) ip_test.timeout = 60 ip_test.build()
def main(): lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_ipv4_l4_urls_per_ten', formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create layer-4 endpoints to connect to an ftp server and test that urls/s are meeting or exceeding the target rate ''', description='''\ test_ipv4_l4_ftp_urls_per_ten.py -------------------- Generic command example: python3 ./test_ipv4_l4_ftp_urls_per_ten.py --upstream_port eth1 \\ --radio wiphy0 \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear \\ --passwd admin123 \\ --test_duration 2m \\ {2m | 30s | 3h | 1d ...etc} --interval 1s \\ --mode 1 {"auto" : "0", "a" : "1", "b" : "2", "g" : "3", "abg" : "4", "abgn" : "5", "bgn" : "6", "bg" : "7", "abgnAC" : "8", "anAC" : "9", "an" : "10", "bgnAC" : "11", "abgnAX" : "12", "bgnAX" : "13", --ap "00:0e:8e:78:e1:76" --requests_per_ten 600 \\ --num_tests 1 \\ --url "ul ftp://lanforge:[email protected]/example.txt /home/lanforge/example.txt" --debug ''') optional = parser.add_argument_group('optional arguments') required = parser.add_argument_group('required arguments') required.add_argument( '--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True) parser.add_argument( '--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) parser.add_argument('--test_duration', help='--test duration of a single test', default=600) parser.add_argument( '--num_tests', help='--num_tests number of tests to run. Each test runs 10 minutes', default=1) parser.add_argument( '--url', help='--url specifies upload/download, address, and dest', default="dl http://10.40.0.1 /dev/null") optional.add_argument('--mode', help='Used to force mode of stations') optional.add_argument('--ap', help='Used to force a connection to a particular AP') #parser.add_argument('--target_per_ten', help='--target_per_ten target number of request per ten minutes. test will check for 90 percent of this value', #default=600) args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000, radio=args.radio) ip_test = IPV4L4(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, upstream_port=args.upstream_port, radio=args.radio, security=args.security, station_list=station_list, url=args.url, mode=args.mode, ap=args.ap, num_tests=args.num_tests, requests_per_ten=args.requests_per_ten, test_duration=args.test_duration, _debug_on=args.debug) ip_test.cleanup(station_list) ip_test.build() ip_test.start() ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) exit(1) time.sleep(30) ip_test.cleanup(station_list) if ip_test.passes(): print( "Full test passed, all endpoints met or exceeded 90 percent of the target rate" )
def main(): parser = LFCliBase.create_basic_argparse( prog='test_ipv6_variable_time.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create stations to test IPV6 connection and traffic on VAPs of varying security types (WEP, WPA, WPA2, WPA3, Open) ''', description='''\ test_ipv6_variable_time.py: -------------------- Generic command example: ./test_ipv6_connection.py --upstream_port eth1 \\ --radio wiphy0 \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear \\ --passwd admin123 \\ --upstream 10.40.0.1 \\ --test_duration 2m \\ --interval 1s \\ --a_min 256000 \\ --b_min 256000 \\ --debug ''') required_args=None for group in parser._action_groups: if group.title == "required arguments": required_args=group break; if required_args is not None: required_args.add_argument('--a_min', help='minimum bps rate for side_a', default=256000) required_args.add_argument('--b_min', help='minimum bps rate for side_b', default=256000) required_args.add_argument('--cx_type', help='tcp6 or udp6') required_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") optional_args=None for group in parser._action_groups: if group.title == "optional arguments": optional_args=group break; if optional_args is not None: optional_args.add_argument('--mode', help='Used to force mode of stations') optional_args.add_argument('--ap', help='Used to force a connection to a particular AP') optional_args.add_argument("--a_max", help="Maximum side_a bps speed", default=0) optional_args.add_argument("--b_max", help="Maximum side_b bps speed", default=0) args = parser.parse_args() CX_TYPES=("tcp6", "udp6", "lf_tcp6", "lf_udp6") if (args.cx_type is None) or (args.cx_type not in CX_TYPES): print("cx_type needs to be lf_tcp6 or lf_udp6, bye") exit(1) if args.cx_type == "tcp6": args.cx_type = "lf_tcp6" if args.cx_type == "udp6": args.cx_type = "lf_udp6" num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_var_test = IPV6VariableTime(_host=args.mgr, _port=args.mgr_port, _number_template="00", _sta_list=station_list, _name_prefix="VT", _upstream=args.upstream_port, _ssid=args.ssid, _password=args.passwd, _radio=args.radio, _security=args.security, _test_duration=args.test_duration, _use_ht160=False, _side_a_min_rate=args.a_min, _side_b_min_rate=args.b_min, _side_a_max_rate=args.a_max, _side_b_max_rate=args.b_max, _cx_type=args.cx_type, _debug_on=args.debug) ip_var_test.pre_cleanup() ip_var_test.build() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) exit(1) ip_var_test.start(False, False) ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) exit(1) time.sleep(30) ip_var_test.cleanup() if ip_var_test.passes(): print("Full test passed, all connections increased rx bytes")
def main(): lfjson_port = 8080 parser = LFCliBase.create_bare_argparse( prog=__file__, # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, description=""" Test the status message passing functions of /status-msg: - create a session: PUT /status-msg/<new-session-id> - post message: POST /status-msg/<new-session-id> - list sessions: GET /status-msg/ - list messages for session: GET /status-msg/<new-session-id> - delete message: DELETE /status-msg/<new-session-id>/message-id - delete session: DELETE /status-msg/<new-session-id>/this - delete all messages in session: DELETE /status-msg/<new-session-id>/all """) parser.add_argument('--action', default="run_test", help=""" Actions can be: run_test : run a messaging test new : create new session update : add message to session, requires --session, --key, --message read : read message(s) from session, requires --session list : list messages from session delete : delete message, all messages using session/all or session using session/this """) parser.add_argument('--session', type=str, help='explicit session or session/message-id') parser.add_argument('--deep_clean', type=bool, help='remove all messages and all sessions') parser.add_argument('--key', type=str, help='how to key the message') parser.add_argument('--message', type=str, help='message to include') args = parser.parse_args() status_messages = TestStatusMessage(args.mgr, lfjson_port, _debug_on=False, _exit_on_error=False, _exit_on_fail=False) if args.action == "new": if args.session is not None: status_messages.json_put("/status-msg/"+args.session, {}) else: u = uuid1() status_messages.json_put("/status-msg/"+u, {}) print("created session /status-msg/"+u) return if args.action == "update": if args.session is None: print("requires --session") return if args.key is None: print("requires --key") return if args.message is None: print("requires --message") return status_messages.json_post("/status-msg/"+args.session, { "key": args.key, "content-type": "text/plain", "message": args.message }) return if args.action == "list": if args.session is None: response_o = status_messages.json_get("/status-msg/") pprint(response_o["sessions"]) else: response_o = status_messages.json_get("/status-msg/"+args.session) pprint(response_o["messages"]) return if args.action == "read": if args.session is None: print("requires --session") return response_o = status_messages.json_get("/status-msg/"+args.session) pprint(response_o) return if args.action == "delete": if args.session is None: print("requires --session") return response_o = status_messages.json_delete("/status-msg/"+args.session) pprint(response_o) return if args.action == "run_test": if args.deep_clean: status_messages.deep_clean = True status_messages.build() if not status_messages.passes(): print(status_messages.get_fail_message()) exit(1) status_messages.start(False, False) status_messages.stop() if not status_messages.passes(): print(status_messages.get_fail_message()) exit(1) status_messages.cleanup() if status_messages.passes(): print("Full test passed, all messages read and cleaned up") exit(0)
def main(): parser = LFCliBase.create_bare_argparse( prog='testgroup.py', formatter_class=argparse.RawTextHelpFormatter, epilog='''Control and query test groups\n''', description='''testgroup.py -------------------- Generic command example: ./testgroup.py --group_name group1 --add_group --add_cx l3_test1,l3_test2 --remove_cx l3_test3 --list_groups ./testgroup.py --group_name group1 --add_group --list_groups ''') parser.add_argument('--group_name', help='specify the name of the test group to use', default=None) parser.add_argument('--list_groups', help='list all existing test groups', action='store_true', default=False) tg_group = parser.add_mutually_exclusive_group() tg_group.add_argument('--add_group', help='add new test group', action='store_true', default=False) tg_group.add_argument('--del_group', help='delete test group', action='store_true', default=False) parser.add_argument('--show_group', help='show connections in current test group', action='store_true', default=False) cx_group = parser.add_mutually_exclusive_group() cx_group.add_argument('--start_group', help='start all cxs in chosen test group', default=None) cx_group.add_argument('--stop_group', help='stop all cxs in chosen test group', default=None) cx_group.add_argument('--quiesce_group', help='quiesce all cxs in chosen test groups', default=None) parser.add_argument('--add_cx', help='add cx to chosen test group', nargs='*', default=[]) parser.add_argument('--remove_cx', help='remove cx from chosen test group', nargs='*', default=[]) args = parser.parse_args() tg_action = None cx_action = None if args.add_group: tg_action = 'add' elif args.del_group: tg_action = 'del' if args.start_group: cx_action = 'start' elif args.stop_group: cx_action = 'stop' elif args.quiesce_group: cx_action = 'quiesce' tg = TestGroup(host=args.mgr, port=args.mgr_port, group_name=args.group_name, add_cx_list=args.add_cx, rm_cx_list=args.remove_cx, cx_action=cx_action, tg_action=tg_action, list_groups=args.list_groups, show_group=args.show_group) tg.do_tg_action() tg.update_cxs() tg.do_cx_action() tg.show_info()
def main(): parser = LFCliBase.create_bare_argparse( prog='test_fileio.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog= '''Creates FileIO endpoints which can be NFS, CIFS or iSCSI endpoints.''', description='''\ test_fileio.py: -------------------- Generic command layout: ./test_fileio.py --macvlan_parent <port> --num_ports <num ports> --use_macvlans --first_mvlan_ip <first ip in series> --netmask <netmask to use> --gateway <gateway ip addr> ./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 ''') parser.add_argument('--num_stations', help='Number of stations to create', default=0) parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2') parser.add_argument('--ssid', help='SSID for stations to associate to') parser.add_argument('--passwd', '--password', '--key', help='WiFi passphrase/password/key') parser.add_argument( '--security', help='security type to use for ssid { wep | wpa | wpa2 | wpa3 | open }' ) parser.add_argument( '-u', '--upstream_port', help= 'non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1', default='1.eth1') parser.add_argument('--test_duration', help='sets the duration of the test', default="5m") parser.add_argument('--fs_type', help='endpoint type', default="fe_nfs4") parser.add_argument('--min_rw_size', help='minimum read/write size', default=64 * 1024) parser.add_argument('--max_rw_size', help='maximum read/write size', default=64 * 1024) parser.add_argument('--min_file_size', help='minimum file size', default=50 * 1024 * 1024) parser.add_argument('--max_file_size', help='maximum file size', default=50 * 1024 * 1024) parser.add_argument('--min_read_rate_bps', help='minimum bps read rate', default=10e9) parser.add_argument('--max_read_rate_bps', help='maximum bps read rate', default=10e9) parser.add_argument('--min_write_rate_bps', help='minimum bps write rate', default=10e9) parser.add_argument('--max_write_rate_bps', help='maximum bps write rate', default="1G") parser.add_argument( '--directory', help='--directory directory to read/write in. Absolute path suggested', default="AUTO") parser.add_argument( '--server_mount', help= '--server_mount The server to mount, ex: 192.168.100.5/exports/test1', default="10.40.0.1:/var/tmp/test") parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', default=None) parser.add_argument('--first_port', help='specifies name of first port to be used', default=None) parser.add_argument('--num_ports', help='number of ports to create', default=1) parser.add_argument('--use_macvlans', help='will create macvlans', action='store_true', default=False) parser.add_argument( '--first_mvlan_ip', help='specifies first static ip address to be used or dhcp', default=None) parser.add_argument( '--netmask', help='specifies netmask to be used with static ip addresses', default=None) parser.add_argument( '--gateway', help='specifies default gateway to be used with static addressing', default=None) parser.add_argument( '--use_test_groups', help='will use test groups to start/stop instead of single endps/cxs', action='store_true', default=False) parser.add_argument('--read_only_test_group', help='specifies name to use for read only test group', default=None) parser.add_argument('--write_only_test_group', help='specifies name to use for write only test group', default=None) parser.add_argument('--mode', help='write,read,both', default='both', type=str) parser.add_argument( '--use_ports', help= 'list of comma separated ports to use with ips, \'=\' separates name and ip' '{ port_name1=ip_addr1,port_name1=ip_addr2 }', default=None) tg_group = parser.add_mutually_exclusive_group() tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None) tg_group.add_argument('--del_from_group', help='name of test group to delete cxs from', default=None) parser.add_argument( '--cxs', help= 'list of cxs to add/remove depending on use of --add_to_group or --del_from_group', default=None) args = parser.parse_args() update_group_args = {"name": None, "action": None, "cxs": None} if args.add_to_group is not None and args.cxs is not None: update_group_args['name'] = args.add_to_group update_group_args['action'] = "add" update_group_args['cxs'] = args.cxs elif args.del_from_group is not None and args.cxs is not None: update_group_args['name'] = args.del_from_group update_group_args['action'] = "del" update_group_args['cxs'] = args.cxs port_list = [] ip_list = [] if args.first_port is not None and args.use_ports is not None: if args.first_port.startswith("sta"): if (args.num_ports is not None) and (int(args.num_ports) > 0): start_num = int(args.first_port[3:]) num_ports = int(args.num_ports) port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num + num_ports - 1, padding_number=10000, radio=args.radio) else: if (args.num_ports is not None) and args.macvlan_parent is not None and (int(args.num_ports) > 0) \ and args.macvlan_parent in args.first_port: start_num = int(args.first_port[args.first_port.index('#') + 1:]) num_ports = int(args.num_ports) port_list = LFUtils.port_name_series( prefix=args.macvlan_parent + "#", start_id=start_num, end_id=start_num + num_ports - 1, padding_number=100000, radio=args.radio) else: raise ValueError( "Invalid values for num_ports [%s], macvlan_parent [%s], and/or first_port [%s].\n" "first_port must contain parent port and num_ports must be greater than 0" % (args.num_ports, args.macvlan_parent, args.first_port)) else: if args.use_ports is None: num_ports = int(args.num_ports) if not args.use_macvlans: port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1, padding_number=10000, radio=args.radio) else: port_list = LFUtils.port_name_series( prefix=args.macvlan_parent + "#", start_id=0, end_id=num_ports - 1, padding_number=100000, radio=args.radio) else: temp_list = args.use_ports.split(',') for port in temp_list: port_list.append(port.split('=')[0]) ip_list.append(port.split('=')[1]) if len(port_list) != len(ip_list): raise ValueError(temp_list, " ports must have matching ip addresses!") if args.first_mvlan_ip is not None: if args.first_mvlan_ip.lower() == "dhcp": dhcp = True else: dhcp = False else: dhcp = True # print(port_list) # exit(1) ip_test = FileIOTest(args.mgr, args.mgr_port, ssid=args.ssid, password=args.passwd, security=args.security, port_list=port_list, ip_list=ip_list, test_duration=args.test_duration, upstream_port=args.upstream_port, _debug_on=args.debug, macvlan_parent=args.macvlan_parent, use_macvlans=args.use_macvlans, first_mvlan_ip=args.first_mvlan_ip, netmask=args.netmask, gateway=args.gateway, dhcp=dhcp, fs_type=args.fs_type, min_rw_size=args.min_rw_size, max_rw_size=args.max_rw_size, min_file_size=args.min_file_size, max_file_size=args.max_file_size, min_read_rate_bps=args.min_read_rate_bps, max_read_rate_bps=args.max_read_rate_bps, min_write_rate_bps=args.min_write_rate_bps, max_write_rate_bps=args.max_write_rate_bps, directory=args.directory, server_mount=args.server_mount, num_ports=args.num_ports, use_test_groups=args.use_test_groups, write_only_test_group=args.write_only_test_group, read_only_test_group=args.read_only_test_group, update_group_args=update_group_args, mode=args.mode # want a mount options param ) ip_test.cleanup(port_list) ip_test.build() # exit(1) if not ip_test.passes(): print(ip_test.get_fail_message()) # ip_test.start(False, False) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) # exit(1) time.sleep(30) ip_test.cleanup(port_list) if ip_test.passes(): print( "Full test passed, all endpoints had increased bytes-rd throughout test duration" )
def main(): lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_ipv4_variable_time.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Useful Information: 1. TBD ''', description='''\ test_ipv4_variable_time.py: -------------------- TBD Generic command layout: python ./test_ipv4_variable_time.py --upstream_port <port> --radio <radio 0> <stations> <ssid> <ssid password> <security type: wpa2, open, wpa3> --debug Note: multiple --radio switches may be entered up to the number of radios available: --radio <radio 0> <stations> <ssid> <ssid password> --radio <radio 01> <number of last station> <ssid> <ssid password> python3 ./test_ipv4_variable_time.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 ''') parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) parser.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_var_test = IPV4VariableTime(args.mgr, lfjson_port, number_template="00", sta_list=station_list, name_prefix="VT", upstream=args.upstream_port, ssid=args.ssid, password=args.passwd, radio=args.radio, security=args.security, test_duration=args.test_duration, use_ht160=False, side_a_min_rate=args.a_min, side_b_min_rate=args.b_min, _debug_on=args.debug) ip_var_test.pre_cleanup() ip_var_test.build() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) exit(1) ip_var_test.start(False, False) ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) exit(1) time.sleep(30) ip_var_test.cleanup() if ip_var_test.passes(): print("Full test passed, all connections increased rx bytes")
def main(): lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_ipv6_variable_time.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create stations to test IPV6 connection and traffic on VAPs of varying security types (WEP, WPA, WPA2, WPA3, Open) ''', description='''\ test_ipv6_variable_time.py: -------------------- Generic command example: python3 ./test_ipv6_connection.py --upstream_port eth1 \\ --radio wiphy0 \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear \\ --passwd admin123 \\ --dest 10.40.0.1 \\ --test_duration 2m \\ --interval 1s \\ --a_min 256000 \\ --b_min 256000 \\ --debug ''') parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) parser.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_var_test = IPV6VariableTime(host=args.mgr, port=args.mgr_port, number_template="00", sta_list=station_list, name_prefix="VT", upstream=args.upstream_port, ssid=args.ssid, password=args.passwd, radio=args.radio, security=args.security, test_duration=args.test_duration, use_ht160=False, side_a_min_rate=args.a_min, side_b_min_rate=args.b_min, _debug_on=args.debug) ip_var_test.pre_cleanup() ip_var_test.build() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) exit(1) ip_var_test.start(False, False) ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) exit(1) time.sleep(30) ip_var_test.cleanup() if ip_var_test.passes(): print("Full test passed, all connections increased rx bytes")
def main(): parser = LFCliBase.create_basic_argparse( prog='test_generic.py', formatter_class=argparse.RawTextHelpFormatter, epilog= '''Create generic endpoints and test for their ability to execute chosen commands\n''', description='''test_generic.py -------------------- Generic command example: python3 ./test_generic.py --mgr localhost (optional) --mgr_port 4122 (optional) --upstream_port eth1 (optional) --radio wiphy0 (required) --num_stations 3 (optional) --security {open|wep|wpa|wpa2|wpa3} (required) --ssid netgear (required) --passwd admin123 (required) --type lfping {generic|lfping|iperf3-client | speedtest | lf_curl} (required) --dest 10.40.0.1 (required - also target for iperf3) --test_duration 2m --interval 1s --debug Example commands: LFPING: ./test_generic.py --mgr localhost --mgr_port 4122 --radio wiphy0 --num_stations 7 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --type lfping --dest 10.40.0.1 --security wpa2 LFCURL (under construction): ./test_generic.py --mgr localhost --mgr_port 4122 --radio wiphy1 --num_stations 26 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --type lfcurl --dest 10.40.0.1 GENERIC: ./test_generic.py --mgr localhost--mgr_port 4122 --radio wiphy1 --num_stations 2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --type generic SPEEDTEST: ./test_generic.py --mgr localhost --mgr_port 4122 --radio wiphy2 --num_stations 13 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security wpa2 IPERF3 (under construction): ./test_generic.py --mgr localhost --mgr_port 4122 --radio wiphy1 --num_stations 3 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --type iperf3 ''') required = parser.add_argument_group('required arguments') required.add_argument( '--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True) parser.add_argument( '--type', help= 'type of command to run: generic, lfping, iperf3-client, iperf3-server, lfcurl', default="lfping") parser.add_argument( '--cmd', help='specifies command to be run by generic type endp', default='') parser.add_argument('--dest', help='destination IP for command', default="10.40.0.1") parser.add_argument('--test_duration', help='duration of the test eg: 30s, 2m, 4h', default="2m") parser.add_argument('--interval', help='interval to use when running lfping (1s, 1m)', default=1) parser.add_argument( '--speedtest_min_up', help='sets the minimum upload threshold for the speedtest type', default=None) parser.add_argument( '--speedtest_min_dl', help='sets the minimum download threshold for the speedtest type', default=None) parser.add_argument( '--speedtest_max_ping', help='sets the minimum ping threshold for the speedtest type', default=None) parser.add_argument('--client', help='client to the iperf3 server', default=None) args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(radio=args.radio, prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=100) generic_test = GenTest(host=args.mgr, port=args.mgr_port, number_template="00", radio=args.radio, sta_list=station_list, name_prefix="GT", type=args.type, dest=args.dest, cmd=args.cmd, interval=1, ssid=args.ssid, upstream=args.upstream_port, passwd=args.passwd, security=args.security, test_duration=args.test_duration, speedtest_min_up=args.speedtest_min_up, speedtest_min_dl=args.speedtest_min_dl, speedtest_max_ping=args.speedtest_max_ping, client=args.client, _debug_on=args.debug) generic_test.cleanup(station_list) generic_test.build() if not generic_test.passes(): print(generic_test.get_fail_message()) generic_test.exit_fail() generic_test.start() if not generic_test.passes(): print(generic_test.get_fail_message()) generic_test.exit_fail() generic_test.stop() time.sleep(30) generic_test.cleanup(station_list) if generic_test.passes(): generic_test.exit_success()
def main(): lfjson_host = "localhost" lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_generic.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create layer-4 endpoints and test that the bytes-rd from the chosen URL are increasing over the duration of the test ''', description='''\ test_ipv4_l4.py -------------------- Generic command layout: python ./test_ipv4_l4.py --upstream_port <port> --radio <radio 0> <stations> <ssid> <ssid password> <security type: wpa2, open, wpa3> --debug Command Line Example: python3 ./test_ipv4_l4.py --upstream_port eth1 (optional) --radio wiphy0 (required) --num_stations 3 (optional) --security {open|wep|wpa|wpa2|wpa3} (required) --ssid netgear (required) --url "dl http://10.40.0.1 /dev/null" (required) --password admin123 (required) --test_duration 2m (optional) --debug (optional) ''') parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") parser.add_argument( '--url', help='--url specifies upload/download, address, and dest', default="dl http://10.40.0.1 /dev/null") args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000, radio=args.radio) ip_test = IPV4L4(host=args.mgr, port=args.mgr_port, ssid=args.ssid, radio=args.radio, password=args.passwd, security=args.security, station_list=station_list, url=args.url, test_duration=args.test_duration, upstream_port=args.upstream_port, _debug_on=args.debug) ip_test.cleanup(station_list) ip_test.build() if not ip_test.passes(): print(ip_test.get_fail_message()) ip_test.exit_fail() ip_test.start(False, False) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) ip_test.exit_fail() time.sleep(30) ip_test.cleanup(station_list) if ip_test.passes(): print( "Full test passed, all endpoints had increased bytes-rd throughout test duration" ) ip_test.exit_success()
def main(): lfjson_host = "localhost" lfjson_port = 8080 param_string = " " for param in add_dut.dut_params: param_string += "%s, " % param.name flags_string = " " for flag in add_dut.dut_flags: flags_string += "%s, " % flag.name parser = LFCliBase.create_bare_argparse( prog='update_dut.py', formatter_class=argparse.RawTextHelpFormatter, description='''{file} -------------------- Generic command layout: python {file} --dut [DUT name] # update existing DUT record --entry [key,value] # update/add entry by specifying key and value --flag [flag,0|1] # toggle a flag on 1 or off 0 --notes "all lines of text" --notes "are replaced if any" --notes "line of text is submitted with --notes" --append "this appends a line of text" DUT Parameters: {params} DUT Flags: {flags} Command Line Example: python3 {file} --mgr 192.168.100.24 --update Pathfinder \ --entry MAC1,"00:00:ae:f0:b1:b9" \ --notes "build 2901" \ --flag STA_MODE,0 --flag AP_MODE,1 '''.format(file=__file__, params=param_string, flags=flags_string), epilog="See", ) parser.add_argument("--dut", type=str, help="name of DUT record") parser.add_argument("-p", "--param", type=str, action="append", help="name,value pair to set parameter") parser.add_argument( "-f", "--flag", type=str, action="append", help="name,1/0/True/False pair to turn parameter on or off") parser.add_argument("-n", "--notes", type=str, action="append", help="replace lines of notes in the record") parser.add_argument("-a", "--append", type=str, action="append", help="append lines of text to the record") args = parser.parse_args() if args.dut is None: raise ValueError("need a name for the dut: --dut something") update_dut = UpdateDUT(args.mgr, lfjson_port, _debug_on=args.debug) update_dut.name = args.dut if (args.param is not None): for param in args.param: if "," not in param: raise ValueError( "Invalid format for param: %s, please use key,value" % param) (name, value) = param.split(",") if (args.debug): print("name %s = %s" % (name, value)) if add_dut.dut_params.has(name): update_dut.params[name] = value else: raise ValueError("parameter %s not in dut_params" % name) flags_sum = 0 flags_mask_sum = 0 if (args.flag is not None): for flag in args.flag: if "," not in flag: raise ValueError( "Invalid format for flag: %s, please use flag,(0/1)" % param) (name, val_str) = flag.split(",") if (args.debug): print("name %s = %s" % (name, val_str)) if not add_dut.dut_flags.has(name): raise ValueError("flag %s not in add_dut.dut_flags" % name) on_off = (0, 1)[val_str == "1"] if (args.debug): print("name %s = %s" % (name, on_off)) flags_sum |= (0, add_dut.dut_flags.to_flag(name).value)[on_off] flags_mask_sum |= add_dut.dut_flags.to_flag(name).value if args.debug: print( "params %s; flags %s; mask %s" % (",".join(update_dut.params), hex(flags_sum), hex(flags_mask_sum))) if (args.notes is not None) and (len(args.notes) > 0): update_dut.notes = args.notes.copy() if (args.append is not None) and (len(args.append) > 0): update_dut.append = args.append.copy() update_dut.flags = flags_sum update_dut.flags_mask = flags_mask_sum update_dut.build() update_dut.start()
def main(): parser = LFCliBase.create_basic_argparse( prog='test_ipv4_l4_urls_per_ten', formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create layer-4 endpoints to connect to a url and test that urls/s are meeting or exceeding the target rate ''', description='''\ test_ipv4_l4_urls_per_ten.py: -------------------- Generic command example: python3 ./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 \\ --radio wiphy0 \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear \\ --passwd admin123 \\ --requests_per_ten 600 \\ --mode 1 {"auto" : "0", "a" : "1", "b" : "2", "g" : "3", "abg" : "4", "abgn" : "5", "bgn" : "6", "bg" : "7", "abgnAC" : "8", "anAC" : "9", "an" : "10", "bgnAC" : "11", "abgnAX" : "12", "bgnAX" : "13"} \\ --num_tests 1 \\ --url "dl http://10.40.0.1 /dev/null" \\ --ap "00:0e:8e:78:e1:76" --target_per_ten 600 \\ --output_format csv \\ --report_file ~/Documents/results.csv \\ --test_duration 2m \\ --debug ''') required = None for agroup in parser._action_groups: if agroup.title == "required arguments": required = agroup #if required is not None: optional = None for agroup in parser._action_groups: if agroup.title == "optional arguments": optional = agroup if optional is not None: optional.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) optional.add_argument('--num_tests', help='--num_tests number of tests to run. Each test runs 10 minutes', default=1) optional.add_argument('--url', help='--url specifies upload/download, address, and dest',default="dl http://10.40.0.1 /dev/null") optional.add_argument('--test_duration', help='duration of test',default="2m") optional.add_argument('--target_per_ten', help='--target_per_ten target number of request per ten minutes. test will check for 90 percent this value',default=600) optional.add_argument('--mode',help='Used to force mode of stations') optional.add_argument('--ap',help='Used to force a connection to a particular AP') optional.add_argument('--report_file',help='where you want to store results') optional.add_argument('--output_format', help='choose csv or xlsx') #update once other forms are completed args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','png','df','xlsx']: output_form=args.output_format.lower() print("Defaulting file output placement to /home/lanforge.") rpt_file='/home/data.' + output_form else: print("Defaulting data file output type to Excel") rpt_file='/home/lanforge/data.xlsx' output_form='xlsx' else: rpt_file=args.report_file if args.output_format is None: output_form=str(args.report_file).split('.')[-1] else: output_form=args.output_format #Create directory if args.report_file is None: try: homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_l4_urls_per_ten' path = os.path.join('/home/lanforge/report-data/',homedir) os.mkdir(path) except: path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) print('Saving file to local directory') else: pass if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: rpt_file=path+'/data.' + args.output_format output=args.output_format else: print('Defaulting data file output type to Excel') rpt_file=path+'/data.xlsx' output='xlsx' else: rpt_file=args.report_file if args.output_format is None: output=str(args.report_file).split('.')[-1] else: output=args.output_format station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_test = IPV4L4(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, upstream_port=args.upstream_port, security=args.security, station_list=station_list, url=args.url, mode=args.mode, ap=args.ap, _debug_on=args.debug, test_duration=args.test_duration, num_tests=args.num_tests, target_requests_per_ten=args.target_per_ten, requests_per_ten=args.requests_per_ten) ip_test.cleanup(station_list) ip_test.build() ip_test.start() try: layer4traffic=','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']]) except: pass ip_test.l4cxprofile.monitor(col_names=['bytes-rd', 'urls/s'], report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx=layer4traffic, output_format=output_form, script_name='test_ipv4_l4_urls_per_ten', arguments=args, debug=args.debug) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) exit(1) time.sleep(30) ip_test.cleanup(station_list) if ip_test.passes(): print("Full test passed, all endpoints met or exceeded 90 percent of the target rate")
def main(): #Params for different tests: # # # # # lfjson_host = "localhost" lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_ipv4_connection.py', #formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create stations that attempt to authenticate, associate, and receive IP addresses on the chosen SSID ''', description='''\ test_ipv4_connection.py -------------------- Generic command example: python3 ./test_ipv4_connection.py --upstream_port eth1 \\ --radio wiphy0 \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear \\ --passwd admin123 \\ --dest 10.40.0.1 \\ --test_duration 2m \\ --interval 1s \\ --debug ''') args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000) ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd, security=args.security, sta_list=station_list, radio=args.radio) ip_test.cleanup(station_list) #ip_test.timeout = 60 ip_test.build() if not ip_test.passes(): print(ip_test.get_fail_message()) exit(1) ip_test.start(station_list, False, False) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) exit(1) time.sleep(30) ip_test.cleanup(station_list) if ip_test.passes(): print("Full test passed, all stations associated and got IP")
def main(): lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_generic.py', formatter_class=argparse.RawTextHelpFormatter, epilog= '''Create generic endpoints and test for their ability to execute chosen commands\n''', description='''test_generic.py -------------------- Generic command example: python3 ./test_generic.py --upstream_port eth1 --radio wiphy0 (required) --num_stations 3 --security {open|wep|wpa|wpa2|wpa3} (required) --ssid netgear (required) --passwd admin123 (required) --type lfping {generic|lfping|iperf3-client | speedtest | iperf3-server |lf_curl} (required) --dest 10.40.0.1 (required - also target for iperf3) --test_duration 2m --interval 1s --debug ''') parser.add_argument( '--type', help= 'type of command to run: generic, lfping, iperf3-client, iperf3-server, lfcurl', default="lfping") parser.add_argument( '--cmd', help='specifies command to be run by generic type endp', default='') parser.add_argument('--dest', help='destination IP for command', default="10.40.0.1") parser.add_argument('--test_duration', help='duration of the test eg: 30s, 2m, 4h', default="2m") parser.add_argument('--interval', help='interval to use when running lfping (1s, 1m)', default=1) parser.add_argument( '--speedtest_min_up', help='sets the minimum upload threshold for the speedtest type', default=None) parser.add_argument( '--speedtest_min_dl', help='sets the minimum download threshold for the speedtest type', default=None) parser.add_argument( '--speedtest_max_ping', help='sets the minimum ping threshold for the speedtest type', default=None) args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(radio=args.radio, prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=100) generic_test = GenTest(args.mgr, lfjson_port, number_template="00", radio=args.radio, sta_list=station_list, name_prefix="GT", type=args.type, dest=args.dest, cmd=args.cmd, interval=1, ssid=args.ssid, upstream=args.upstream_port, password=args.passwd, security=args.security, test_duration=args.test_duration, speedtest_min_up=args.speedtest_min_up, speedtest_min_dl=args.speedtest_min_dl, speedtest_max_ping=args.speedtest_max_ping, _debug_on=args.debug) generic_test.cleanup(station_list) generic_test.build() if not generic_test.passes(): print(generic_test.get_fail_message()) exit(1) generic_test.start() if not generic_test.passes(): print(generic_test.get_fail_message()) exit(1) generic_test.stop() time.sleep(30) generic_test.cleanup(station_list) if generic_test.passes(): print("Full test passed")
if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) import argparse from LANforge.lfcli_base import LFCliBase from LANforge import LFUtils import realm parser = LFCliBase.create_bare_argparse( prog='scenario.py', formatter_class=argparse.RawTextHelpFormatter, epilog='''Load a database file and control test groups\n''', description='''scenario.py -------------------- Generic command example: python3 scenario.py --load db1 --action overwrite --clean_dut --clean_chambers python3 scenario.py --start test_group1 python3 scenario.py --quiesce test_group1 python3 scenario.py --stop test_group1 ''') group = parser.add_mutually_exclusive_group() parser.add_argument('--load', help='name of database to load', default=None) parser.add_argument('--action', help='action to take with database {overwrite | append}', default="overwrite")
def main(): lfjson_host = "localhost" lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_ipv4_ttls.py', #formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''Demonstration showing wpa2-ent ttls authentication''', description='''\ test_ipv4_ttls.py: -------------------- Generic command layout: python ./test_ipv4_ttls.py --upstream_port <port> --radio <radio 0> --num_stations 3 --ssid ssid-wpa-1 --keyphrase ssid-wpa-1 --security <security type: wpa2, open, wpa3> --debug ''') parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) parser.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") parser.add_argument('--key-mgmt', help="--key-mgt: { %s }" % ", ".join(realm.wpa_ent_list()), default="WPA-EAP") parser.add_argument('--wpa_psk', help='wpa-ent pre shared key', default="[BLANK]") parser.add_argument('--eap', help='--eap eap method to use', default="TTLS") parser.add_argument('--identity', help='--identity eap identity string', default="testuser") parser.add_argument('--ttls_passwd', help='--ttls_passwd eap password string', default="testpasswd") parser.add_argument('--ttls_realm', help='--ttls_realm 802.11u home realm to use', default="localhost.localdomain") parser.add_argument('--domain', help='--domain 802.11 domain to use', default="localhost.localdomain") parser.add_argument( '--hessid', help='--hessid 802.11u HESSID (MAC addr format/peer for WDS)', default="00:00:00:00:00:01") parser.add_argument( '--ieee80211w', help='--ieee80211w <disabled(0),optional(1),required(2)', default='1') parser.add_argument('--use_hs20', help='use HotSpot 2.0', default=False) parser.add_argument('--enable_pkc', help='enable opportunistic PMKSA WPA2 key caching', default=False) args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000) ttls_test = TTLSTest( host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, security=args.security, sta_list=station_list, radio=args.radio, key_mgmt=args.key_mgmt, wpa_psk=args.wpa_psk, eap=args.eap, identity=args.identity, ttls_passwd=args.ttls_passwd, ttls_realm=args.ttls_realm, domain=args.domain, hessid=args.hessid, ieee80211w=args.ieee80211w, hs20_enable=args.use_hs20, enable_pkc=args.enable_pkc, ) ttls_test.cleanup(station_list) ttls_test.build() if not ttls_test.passes(): print(ttls_test.get_fail_message()) exit(1) ttls_test.start(station_list, False, False) ttls_test.stop() if not ttls_test.passes(): print(ttls_test.get_fail_message()) exit(1) time.sleep(30) ttls_test.cleanup(station_list) if ttls_test.passes(): print("Full test passed, all stations associated and got IP")
def main(): parser = LFCliBase.create_basic_argparse( prog='test_ipv6_connection.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create stations that attempt to authenticate, associate, and receive IPV6 addresses on the chosen SSID ''', description='''\ test_ipv6_connection.py: -------------------------------------------------- Generic command example: python3 ./test_ipv6_connection.py --upstream_port eth1 --radio wiphy0 --num_stations 3 --proxy --security {open|wep|wpa|wpa2|wpa3} --ssid netgear --passwd admin123 --mode 1 --ap "00:0e:8e:78:e1:76" --test_id --timeout 120 --debug ''') required = None for agroup in parser._action_groups: if agroup.title == "required arguments": required = agroup #if required is not None: optional = None for agroup in parser._action_groups: if agroup.title == "optional arguments": optional = agroup if optional is not None: optional.add_argument("--ap", help="Add BSSID of access point to connect to") optional.add_argument('--mode', help=LFCliBase.Help_Mode) optional.add_argument( '--timeout', help= '--timeout sets the length of time to wait until a connection is successful', default=30) args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000, radio=args.radio) ipv6_test = IPv6Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, security=args.security, ap=args.ap, mode=args.mode, sta_list=station_list, _debug_on=args.debug) ipv6_test.cleanup(station_list) ipv6_test.build() print('Sleeping for 30 seconds...', flush=True) time.sleep(30) if not ipv6_test.passes(): print(ipv6_test.get_fail_message()) exit(1) ipv6_test.start(station_list, False, False) ipv6_test.stop() if not ipv6_test.passes(): print(ipv6_test.get_fail_message()) exit(1) time.sleep(20) ipv6_test.cleanup(station_list) if ipv6_test.passes(): print("Full test passed, all stations associated and got IP")
def main(): lfjson_host = "localhost" lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_ipv4_l4_wifi.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create layer-4 endpoints and test that the bytes-rd from the chosen URL are increasing over the duration of the test ''', description='''\ test_ipv4_l4_wifi.py: -------------------- Generic command example: python3 ./test_ipv4_l4_wifi.py --upstream_port eth1 \\ --radio wiphy0 \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear \\ --passwd admin123 \\ --test_duration 2m \\ --requests_per_ten 600 \\ --direction {ul | dl} \\ --dest /dev/null (or 10.40.0.1)\\ --debug ''') parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") parser.add_argument( '--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) parser.add_argument( '--direction', help='--direction <ul | dl> specifies upload or download', default="dl") parser.add_argument( '--dest', help= '--dest specifies the destination (dl) or source (ul) for the file', default="/dev/null") args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000, radio=args.radio) ip_test = IPV4L4(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, security=args.security, station_list=station_list, direction=args.direction, dest=args.dest, test_duration=args.test_duration, upstream_port=args.upstream_port, requests_per_ten=args.requests_per_ten, _debug_on=args.debug) ip_test.cleanup(station_list) ip_test.build() if not ip_test.passes(): print(ip_test.get_fail_message()) ip_test.exit_fail() ip_test.start(False, False) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) ip_test.exit_fail() time.sleep(30) ip_test.cleanup(station_list) if ip_test.passes(): ("Full test passed, all endpoints had increased bytes-rd throughout test duration" ) ip_test.exit_success()
def main(): lfjson_port = 8080 parser = LFCliBase.create_basic_argparse( prog='test_ipv4_l4_urls_per_ten', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ Create layer-4 endpoints to connect to an ftp server and test that urls/s are meeting or exceeding the target rate ''', description='''\ test_ipv4_l4_ftp_urls_per_ten.py -------------------- Generic command example: python3 ./test_ipv4_l4_ftp_urls_per_ten.py --upstream_port eth1 \\ --radio wiphy0 \\ --num_stations 3 \\ --security {open|wep|wpa|wpa2|wpa3} \\ --ssid netgear \\ --passwd admin123 \\ --dest 10.40.0.1 \\ --test_duration 2m \\ --interval 1s \\ --requests_per_ten 600 \\ --num_tests 1 \\ --url "dl http://10.40.0.1 /dev/null" \\ --target_per_ten 600 \\ --debug ''') parser.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes', default=600) parser.add_argument('--num_tests', help='--num_tests number of tests to run. Each test runs 10 minutes', default=1) parser.add_argument('--url', help='--url specifies upload/download, address, and dest', default="dl http://10.40.0.1 /dev/null") parser.add_argument('--target_per_ten', help='--target_per_ten target number of request per ten minutes. test will check for 90% of this value', default=600) args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, upstream_port=args.upstream_port,radio= args.radio, security=args.security, station_list=station_list, url=args.url, num_tests=args.num_tests, target_requests_per_ten=args.target_per_ten, requests_per_ten=args.requests_per_ten) ip_test.cleanup(station_list) ip_test.build() ip_test.start() ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) exit(1) time.sleep(30) ip_test.cleanup(station_list) if ip_test.passes(): print("Full test passed, all endpoints met or exceeded 90% of the target rate")