예제 #1
0
def main():
    # create multiple OPEN stations
    station_names = LFUtils.port_name_series(start_id=0, end_id=1)

    test = StaConnect("localhost",
                      8080,
                      _debugOn=False,
                      _exit_on_error=True,
                      _cleanup_on_exit=False,
                      _runtime_sec=360,
                      _exit_on_fail=True)
    test.sta_mode = sta_connect.MODE_AUTO
    test.upstream_resource = 1
    test.upstream_port = "eth1"
    test.radio = "wiphy0"
    test.resource = 1
    test.dut_security = sta_connect.OPEN
    test.dut_ssid = "jedway-open"
    test.dut_passwd = "[BLANK]"
    test.station_names = station_names
    test.runtime_secs = 5
    test.cleanup_on_exit = True
    test.run()
    is_passing = test.passes()

    # recorded stations and endpoints can be retrieved this way:
    '''
    for sta_name in test.resulting_stations:
        print("** recorded: "+sta_name)
        pprint.pprint(test.resulting_stations[sta_name])

    for endp_name in test.resulting_endpoints:
        print("** endp: "+endp_name)
        pprint.pprint(test.resulting_endpoints[endp_name])
    '''
    if is_passing == False:
        # run_results = staConnect.get_failed_result_list()
        fail_message = test.get_fail_message()
        print("Some tests failed:\n" + fail_message)
        return
    else:
        print("Tests pass")

    # Stations use WPA2
    test.dut_security = sta_connect.WPA2
    test.dut_ssid = "jedway-wpa2-x2048-5-1"
    test.dut_passwd = "jedway-wpa2-x2048-5-1"
    test.run()
    is_passing = test.passes()
    if is_passing == False:
        # run_results = staConnect.get_failed_result_list()
        fail_message = test.get_fail_message()
        print("Some tests failed:\n" + fail_message)
        return
    else:
        print("Tests pass")

    if test.cleanup_on_exit == True:
        test.remove_stations()
예제 #2
0
    def __init__(self,
                 upstream,
                 host="localhost",
                 port=8080,
                 side_a_min_rate=0,
                 side_a_max_rate=56000,
                 side_b_min_rate=0,
                 side_b_max_rate=56000,
                 num_sta_=200,
                 test_duration="30s",
                 _debug_on=True,
                 _exit_on_error=False,
                 _exit_on_fail=False):
        super().__init__(host,
                         port,
                         _debug=_debug_on,
                         _local_realm=Realm(lfclient_host=host,
                                            lfclient_port=port),
                         _halt_on_error=_exit_on_error,
                         _exit_on_fail=_exit_on_fail)
        self.ssid_radio_map = {
            '1.1.wiphy0':
            ("wpa2", "jedway-wpa2-x2048-4-4", "jedway-wpa2-x2048-4-4"),
            '1.1.wiphy1':
            ("wpa2", "jedway-wpa2-x2048-5-1", "jedway-wpa2-x2048-5-1"),
            '1.1.wiphy2':
            ("wpa2", "jedway-wpa2-x2048-4-1", "jedway-wpa2-x2048-4-1"),
            '1.2.wiphy0':
            ("wpa2", "jedway-wpa2-x2048-5-3", "jedway-wpa2-x2048-5-3"),
            '1.2.wiphy1': ("wpa2", "jedway-wpa2-x2048-4-4",
                           "jedway-wpa2-x2048-4-4"),
            '1.2.wiphy2': ("wpa2", "jedway-wpa2-x2048-4-1",
                           "jedway-wpa2-x2048-4-1"),
        }
        if num_sta_ is None:
            raise ValueError("need a number of stations per radio")
        self.num_sta = int(num_sta_)
        self.station_radio_map = {
            # port_name_series(prefix=prefix_, start_id=start_id_, end_id=end_id_, padding_number=padding_number_, radio=radio)
            "1.1.wiphy0":
            LFUtils.port_name_series(start_id=0,
                                     end_id=self.num_sta - 1,
                                     padding_number=10000,
                                     radio="1.1.wiphy0"),
            "1.1.wiphy1":
            LFUtils.port_name_series(start_id=1000,
                                     end_id=1000 + self.num_sta - 1,
                                     padding_number=10000,
                                     radio="1.1.wiphy1"),
            "1.1.wiphy2":
            LFUtils.port_name_series(start_id=2000,
                                     end_id=2000 + self.num_sta - 1,
                                     padding_number=10000,
                                     radio="1.1.wiphy2"),
            "1.2.wiphy0":
            LFUtils.port_name_series(start_id=3000,
                                     end_id=3000 + self.num_sta - 1,
                                     padding_number=10000,
                                     radio="1.2.wiphy0"),
            "1.2.wiphy1":
            LFUtils.port_name_series(start_id=4000,
                                     end_id=4000 + self.num_sta - 1,
                                     padding_number=10000,
                                     radio="1.2.wiphy1"),
            "1.2.wiphy2":
            LFUtils.port_name_series(start_id=5000,
                                     end_id=5000 + self.num_sta - 1,
                                     padding_number=10000,
                                     radio="1.2.wiphy2")
        }
        self.test_duration = test_duration
        self.upstream = upstream
        self.name_prefix = "1k"
        self.cx_profile = self.local_realm.new_l3_cx_profile()
        self.cx_profile.name_prefix = self.name_prefix
        self.cx_profile.side_a_min_bps = side_a_min_rate
        self.cx_profile.side_a_max_bps = side_a_max_rate
        self.cx_profile.side_b_min_bps = side_b_min_rate
        self.cx_profile.side_b_max_bps = side_b_max_rate

        self.station_profile_map = {}
예제 #3
0
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():
    parser = LFCliBase.create_basic_argparse(
        prog='test_ipv4_connection.py',
        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:
./test_ipv4_connection.py 
    --upstream_port eth1 
    --radio wiphy0 
    --num_stations 3 
    --security open 
    --ssid netgear 
    --passwd BLANK 
    --debug
            ''')

    args = parser.parse_args()
    if (args.radio is None):
        raise ValueError("--radio required")

    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.port_name_series(prefix="sta",
                                            start_id=0,
                                            end_id=num_sta - 1,
                                            padding_number=10000,
                                            radio=args.radio)

    ip_test = IPv4Test(host=args.mgr,
                       port=args.mgr_port,
                       ssid=args.ssid,
                       password=args.passwd,
                       security=args.security,
                       sta_list=station_list,
                       radio=args.radio,
                       _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.add_event(name="test_ipv4_connection.py",
                          message=ip_test.get_fail_message())
        ip_test.exit_fail()
    ip_test.start(station_list, False, False)
    ip_test.stop()
    if not ip_test.passes():
        print(ip_test.get_fail_message())
        ip_test.add_event(name="test_ipv4_connection.py",
                          message=ip_test.get_fail_message())
        ip_test.exit_fail()
    time.sleep(30)
    ip_test.cleanup(station_list)
    if ip_test.passes():
        ip_test.add_event(
            name="test_ipv4_connection.py",
            message="Full test passed, all stations associated and got IP")
        ip_test.exit_success()