当前位置: 首页>>代码示例>>Python>>正文


Python TestLib.TestLib类代码示例

本文整理汇总了Python中TestLib.TestLib的典型用法代码示例。如果您正苦于以下问题:Python TestLib类的具体用法?Python TestLib怎么用?Python TestLib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestLib类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if, m2_if, m3_if, m4_if, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces

    # Create a bridge
    sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4]
    sw_br = sw.create_bridge(slaves=sw_ports, options={"vlan_filtering": 1,
                                                       "multicast_querier": 1})

    m1_if.set_addresses(test_ip(1,1))
    m2_if.set_addresses(test_ip(1, 2))
    m3_if.set_addresses(test_ip(1, 3))
    m4_if.set_addresses(test_ip(1, 4))
    sleep(30)

    tl = TestLib(ctl, aliases)

    tl.check_cpu_traffic(sw_ports, test=False)
    for iface in [m1_if, m2_if, m3_if, m4_if]:
        iface.enable_multicast()

    test_standard_mutlicast(tl, m1_if, [m2_if, m4_if], [m3_if], mcgrp(3))
    test_standard_mutlicast(tl, m1_if, [m4_if], [m2_if, m3_if], mcgrp(4))
    test_standard_mutlicast(tl, m2_if, [m3_if, m4_if, m1_if], [], mcgrp(5))
    for iface in [m1_if, m2_if, m3_if, m4_if]:
        iface.disable_multicast()
    tl.check_cpu_traffic(sw_ports)
开发者ID:jpirko,项目名称:lnst,代码行数:27,代码来源:l2-020-bridge_mdb.py

示例2: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if1, m2_if1, sw_if1, sw_if2 = ifaces

    m1_if1.reset(ip=test_ip(1,1))
    m2_if1.reset(ip=test_ip(2,1))

    sw_if1.reset(ip=test_ip(1,2))
    sw_if2.reset(ip=test_ip(2,2))

    m1_if1.add_nhs_route(ipv4(test_ip(2,0)), [ipv4(test_ip(1,2,[]))]);
    m2_if1.add_nhs_route(ipv4(test_ip(1,0)), [ipv4(test_ip(2,2,[]))]);

    m1_if1.add_nhs_route(ipv6(test_ip(2,0)), [ipv6(test_ip(1,2,[]))], ipv6=True);
    m2_if1.add_nhs_route(ipv6(test_ip(1,0)), [ipv6(test_ip(2,2,[]))], ipv6=True);

    sleep(30)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_if1, m2_if1)

    # Remove route and check that traffic is not passing
    sw_if1.set_addresses(ips=[])
    sw_if2.set_addresses(ips=[])
    tl.ping_simple(m1_if1, m2_if1, fail_expected=True)
开发者ID:jpirko,项目名称:lnst,代码行数:25,代码来源:l3-000-minimal.py

示例3: do_task

def do_task(ctl, hosts, ifaces, aliases):
    tl = TestLib(ctl, aliases)
    m1, m2, sw = hosts
    m1_if1, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3 = ifaces
    m1.sync_resources(modules=["PacketAssert"])

    # configure interfaces
    m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"])
    m2_if1.reset(ip=["192.168.101.11/24", "2002::2/64"])
    sw_if3.set_link_up()
    m2_if2.set_link_up()
    sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1})
    mirred_port = MirredPort(sw_if2)

    sleep(15)

    mirror_status = {"ingress": False, "egress": False}
    for i in range(10):
        change = random.choice(mirror_status.keys())
        change_mirror_status(mirror_status, change, mirred_port, sw_if3)

        in_num = 10 if mirror_status["ingress"] else 0
        out_num = 10 if mirror_status["egress"] else 0

        in_assert_proc = run_packet_assert(in_num, m2_if2, m2_if1, m1_if1)
        out_assert_proc = run_packet_assert(out_num, m2_if2, m1_if1, m2_if1)
        tl.ping_simple(m1_if1, m2_if1, count=10)
        in_assert_proc.intr()
        out_assert_proc.intr()

    return 0
开发者ID:jpirko,项目名称:lnst,代码行数:31,代码来源:l2-021-span.py

示例4: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if1, m2_if1, sw_if1, sw_if2 = ifaces

    vrf_None = None
    tl = TestLib(ctl, aliases)

    # Test that offloaded routes do have "offload" flag.
    with dummy(sw, vrf_None, ip=["1.2.3.4/32"]) as d:
        with gre(sw, None, vrf_None,
                 tos="inherit",
                 local_ip="1.2.3.4",
                 remote_ip="1.2.3.5") as g, \
             encap_route(sw, vrf_None, 2, g, ip=ipv4), \
             encap_route(sw, vrf_None, 2, g, ip=ipv6):
            sleep(15)

            ulip = test_ip(2, 0, [24, 64])
            (r4,), _ = sw.get_routes("table 0 %s" % ipv4(ulip))
            if "offload" not in r4["flags"]:
                tl.custom(sw, "ipip", "IPv4 encap route not offloaded")

            (r6,), _ = sw.get_routes("table 0 %s" % ipv6(ulip))
            if "offload" not in r6["flags"]:
                tl.custom(sw, "ipip", "IPv6 encap route not offloaded")

            (dcr4,), _ = sw.get_routes("table local 1.2.3.4")
            if "offload" not in dcr4["flags"]:
                tl.custom(sw, "ipip", "IPv4 decap route not offloaded")

        sleep(5)
        (dcr4,), _ = sw.get_routes("table local 1.2.3.4")
        if "offload" in dcr4["flags"]:
            tl.custom(sw, "ipip", "IPv4 decap still flagged offloaded")
开发者ID:jpirko,项目名称:lnst,代码行数:34,代码来源:ipip-005-offload-flag.py

示例5: do_task

def do_task(ctl, hosts, ifaces, aliases):
    """
    This test deffines MAX_ROUTES number of routes on the switch with different
    32bit prefixes in the range 192.168.[10..].[1..254] and redirects them to a
    nexthop on machine2. The test than checks that:
     - All routes has the offloaded flag
     - Traffic destined to each of the route prefixes did end up on machine2, as
       the route specifies
    """
    m1, sw, m2 = hosts
    m1_if1, sw_if1, sw_if2, m2_if1 = ifaces

    m1_if1.reset(ip=test_ip(1, 1))
    sw_if1.reset(ip=test_ip(1, 2))

    sw_if2.reset(ip=test_ip(2, 2))
    m2_if1.reset(ip=test_ip(2, 3))

    for route_index in range(ROUTES_COUNT):
        route_major = get_route_major(route_index)
        route_minor = get_route_minor(route_index)
        sw_if1.add_nhs_route(ipv4(test_ip(route_major, route_minor, [])),
                             [ipv4(test_ip(2, 3, []))])

    sleep(30)
    tl = TestLib(ctl, aliases)

    # check that there are ROUTES_COUNT offloaded routes
    dc_routes, nh_routes = sw.get_routes()
    offloaded_routes_num = 0
    for nh_route in nh_routes:
        if "offload" in nh_route["nexthops"][0]["flags"]:
            offloaded_routes_num += 1

    if offloaded_routes_num < ROUTES_COUNT:
        tl.custom(sw, "route", "Only %d out of %d routes offloaded" %
                  (offloaded_routes_num, ROUTES_COUNT))

    # run traffic, and validate that each route will be hit
    sleep(2)
    before_stats = m2_if1.link_stats()["rx_packets"]

    total_sent = 0
    for major in get_all_route_majors():
        total_sent += traffic_route_major(tl, major, m1_if1, m2_if1, sw_if1)

    sleep(2)
    after_stats = m2_if1.link_stats()["rx_packets"]
    recieved = after_stats - before_stats

    # validate that all traffic went according to the routes
    thresh = total_sent * 0.95
    if recieved < thresh:
        tl.custom(sw, "route", "Recieved %d out of %d packets" %
                  (recieved, thresh))
开发者ID:jpirko,项目名称:lnst,代码行数:55,代码来源:l3-008-routes_stress.py

示例6: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if1, m2_if1, sw_if1, sw_if2 = ifaces

    m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"])
    m2_if1.reset(ip=["192.168.101.11/24", "2002::2/64"])

    sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1})

    sleep(15)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_if1, m2_if1)
开发者ID:eladraz,项目名称:lnst,代码行数:13,代码来源:l2-000-minimal.py

示例7: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if1, m1_if2, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces

    team_config = '{"runner" : {"name" : "lacp"}}'
    m1_lag1 = m1.create_team(slaves=[m1_if1, m1_if2], config=team_config,
                             ip=test_ip(1,1))
    m2_lag1 = m2.create_team(slaves=[m2_if1, m2_if2], config=team_config,
                             ip=test_ip(2,1))

    m1_lag1.add_nhs_route(ipv4(test_ip(2,0)), [ipv4(test_ip(1,2,[]))]);
    m2_lag1.add_nhs_route(ipv4(test_ip(1,0)), [ipv4(test_ip(2,2,[]))]);

    m1_if1.add_nhs_route(ipv6(test_ip(2,0)), [ipv6(test_ip(1,2,[]))], ipv6=True);
    m2_if1.add_nhs_route(ipv6(test_ip(1,0)), [ipv6(test_ip(2,2,[]))], ipv6=True);

    sw_lag1 = sw.create_team(slaves=[sw_if1, sw_if2], config=team_config,
                             ip=test_ip(1,2))
    sw_lag2 = sw.create_team(slaves=[sw_if3, sw_if4], config=team_config,
                             ip=test_ip(2,2))

    sleep(30)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_lag1, m2_lag1)
    tl.netperf_tcp(m1_lag1, m2_lag1)
    tl.netperf_udp(m1_lag1, m2_lag1)
开发者ID:jpirko,项目名称:lnst,代码行数:27,代码来源:l3-004-team-interface.py

示例8: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if1, m1_if2, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces

    bond_options = {"mode": "802.3ad", "miimon": "100"}
    m1_lag1 = m1.create_bond(slaves=[m1_if1, m1_if2], options=bond_options,
                             ip=test_ip(1,1))
    m2_lag1 = m2.create_bond(slaves=[m2_if1, m2_if2], options=bond_options,
                             ip=test_ip(2,1))

    m1_lag1.add_nhs_route(ipv4(test_ip(2,0)), [ipv4(test_ip(1,2,[]))]);
    m2_lag1.add_nhs_route(ipv4(test_ip(1,0)), [ipv4(test_ip(2,2,[]))]);

    m1_if1.add_nhs_route(ipv6(test_ip(2,0)), [ipv6(test_ip(1,2,[]))], ipv6=True);
    m2_if1.add_nhs_route(ipv6(test_ip(1,0)), [ipv6(test_ip(2,2,[]))], ipv6=True);

    sw_lag1 = sw.create_bond(slaves=[sw_if1, sw_if2], options=bond_options,
                             ip=test_ip(1,2))
    sw_lag2 = sw.create_bond(slaves=[sw_if3, sw_if4], options=bond_options,
                             ip=test_ip(2,2))

    sleep(30)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_lag1, m2_lag1)
    tl.netperf_tcp(m1_lag1, m2_lag1)
    tl.netperf_udp(m1_lag1, m2_lag1)
开发者ID:jpirko,项目名称:lnst,代码行数:27,代码来源:l3-003-bond-interface.py

示例9: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, sw, m2 = hosts
    m1_if1, sw_if1, sw_if2, sw_if3, m2_if1, m2_if2, m2_if3, m3_if1 = ifaces

    ecmp_sw_ifaces = [sw_if2, sw_if3]
    ecmp_m_ifaces = [m2_if1, m2_if2]

    m2.config("/proc/sys/net/ipv4/ip_forward", "1")
    m2.config("/proc/sys/net/ipv6/conf/all/forwarding", "1")

    ecmp_common.create_topology(m1_if1, sw_if1, ecmp_sw_ifaces, ecmp_m_ifaces,
                                m2_if3, m3_if1)
    sleep(30)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_if1, m3_if1)
    tl.netperf_udp(m1_if1, m3_if1)
    ecmp_common.test_traffic(tl, m1_if1, m3_if1, sw_if1, ecmp_sw_ifaces)
开发者ID:jpirko,项目名称:lnst,代码行数:18,代码来源:l3-005-ecmp-basic.py

示例10: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if1, m2_if1, sw_if1, sw_if2 = ifaces

    m1_if1.add_nhs_route(ipv4(test_ip(2, 0)), [ipv4(test_ip(1, 1, []))])
    m2_if1.add_nhs_route("1.2.3.4/32", [ipv4(test_ip(99, 1, []))])

    vrf_None = None
    tl = TestLib(ctl, aliases)

    # Test that non-IPIP traffic gets to slow path.
    with dummy(sw, vrf_None, ip=["1.2.3.4/32"]) as d, \
         gre(sw, None, vrf_None,
             tos="inherit",
             local_ip="1.2.3.4",
             remote_ip="1.2.3.5") as g, \
         encap_route(sw, vrf_None, 2, g, ip=ipv4):
        sleep(15)
        ping_test(tl, m2, sw, "1.2.3.4", m2_if1, g, count=20)

    # Configure the wrong interface on M2 to test that the traffic gets trapped
    # to CPU.
    with encap_route(m2, vrf_None, 1, "gre3"):

        add_forward_route(sw, vrf_None, "1.2.3.5")

        with dummy(sw, vrf_None, ip=["1.2.3.4/32"]) as d, \
             gre(sw, None, vrf_None,
                 local_ip="1.2.3.4",
                 remote_ip="1.2.3.5") as g:
            sleep(15)

            before_stats = sw_if2.link_stats()["rx_packets"]
            ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1, g,
                      count=20, fail_expected=True)
            after_stats = sw_if2.link_stats()["rx_packets"]
            delta = after_stats - before_stats
            if delta < 15:
                tl.custom(sw, "ipip",
                        "Too few packets (%d) observed in slow path" % delta)
开发者ID:jpirko,项目名称:lnst,代码行数:40,代码来源:ipip-004-gre-traps.py

示例11: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if1, m2_if1, sw_if1, sw_if2 = ifaces

    m1_if1_85 = m1.create_vlan(m1_if1, 85, ip=["192.168.101.10/24", "2002::1/64"])
    m2_if1_65 = m2.create_vlan(m2_if1, 65, ip=["192.168.101.11/24", "2002::2/64"])

    sw_br1 = sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1,
                                                                "multicast_snooping": 0})
    sw_if1.add_br_vlan(85)
    sw_if2.add_br_vlan(65)

    q1 = Qdisc(sw_if1, 0xffff, "ingress")
    q1.filter_add("protocol all flower skip_sw action vlan modify id 65")

    q2 = Qdisc(sw_if2, 0xffff, "ingress")
    q2.filter_add("protocol all flower skip_sw action vlan modify id 85")

    sleep(10)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_if1_85, m2_if1_65)
开发者ID:jpirko,项目名称:lnst,代码行数:22,代码来源:tc-001-action-vlan-modify.py

示例12: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, m2, sw = hosts
    m1_if1, m2_if1, sw_if1, sw_if2 = ifaces

    m1_if1.reset(ip=test_ip(1, 1))

    m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=test_ip(2, 1))
    m1_if1_20 = m1.create_vlan(m1_if1, 20, ip=test_ip(3, 1))
    m1_if1_30 = m1.create_vlan(m1_if1, 30, ip=test_ip(4, 1))

    m2_if1.reset(ip=test_ip(1, 2))
    m2_if1_10 = m2.create_vlan(m2_if1, 10, ip=test_ip(2, 2))
    m2_if1_21 = m2.create_vlan(m2_if1, 21, ip=test_ip(3, 2))
    m2_if1_30 = m2.create_vlan(m2_if1, 30, ip=test_ip(4, 2))

    br_options = {"vlan_filtering": 1, "multicast_querier": 1}
    sw.create_bridge(slaves=[sw_if1, sw_if2], options=br_options)

    sw_if1_10 = sw.create_vlan(sw_if1, 10)
    sw_if2_10 = sw.create_vlan(sw_if2, 10)
    sw_br = sw.create_bridge(slaves=[sw_if1_10, sw_if2_10],
                             options={"multicast_querier": 1})

    sw_if1_20 = sw.create_vlan(sw_if1, 20)
    sw_if2_21 = sw.create_vlan(sw_if2, 21)
    sw.create_bridge(slaves=[sw_if1_20, sw_if2_21],
                     options={"multicast_querier": 1})

    sleep(30)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_if1, m2_if1)
    tl.ping_simple(m1_if1_10, m2_if1_10)
    tl.ping_simple(m1_if1_20, m2_if1_21)
    tl.ping_simple(m1_if1_30, m2_if1_30, fail_expected=True)

    sw_br.slave_del(sw_if1_10.get_id())
    sw_if1_10.reset(ip=test_ip(2, 3))

    sleep(30)

    tl.ping_simple(sw_if1_10, m1_if1_10)
开发者ID:jpirko,项目名称:lnst,代码行数:42,代码来源:l2-010-bridge_vlan1d_sanity.py

示例13: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, sw = hosts
    m1_if1, sw_if1 = ifaces

    m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"])
    sw_if1.reset(ip=["192.168.101.11/24", "2002::2/64"])

    sleep(15)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_if1, sw_if1)
    tl.netperf_tcp(m1_if1, sw_if1)
    tl.netperf_udp(m1_if1, sw_if1)
开发者ID:eladraz,项目名称:lnst,代码行数:13,代码来源:basic-004-slowpath.py

示例14: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, sw = hosts
    m1_if1, sw_if1 = ifaces

    m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=["192.168.101.10/24",
                                               "2002::1/64"])
    sw_if1_10 = sw.create_vlan(sw_if1, 10, ip=["192.168.101.11/24",
                                               "2002::2/64"])

    sleep(15)

    tl = TestLib(ctl, aliases)
    tl.ping_simple(m1_if1_10, sw_if1_10)
    tl.netperf_tcp(m1_if1_10, sw_if1_10)
    tl.netperf_udp(m1_if1_10, sw_if1_10)
开发者ID:eladraz,项目名称:lnst,代码行数:15,代码来源:basic-006-slowpath-vlan.py

示例15: do_task

def do_task(ctl, hosts, ifaces, aliases):
    m1, sw = hosts
    m1_if1, sw_if1 = ifaces

    m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"])
    sw_if1.reset(ip=["192.168.101.11/24", "2002::2/64"])

    sleep(15)

    tl = TestLib(ctl, aliases)
    for x in range(64, 1500):
        tl.pktgen(sw_if1, m1_if1, x)
    for x in range(64, 1500):
        tl.pktgen(m1_if1, sw_if1, x)
    # Make sure switch is not stuck by performing ping test
    tl.ping_simple(m1_if1, sw_if1)
开发者ID:jpirko,项目名称:lnst,代码行数:16,代码来源:basic-005-slowpath-exhaustive.py


注:本文中的TestLib.TestLib类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。