Пример #1
0
 def large_frame_ping(count=100):
     logging.info("Large frame ping")
     s, o = virt_test_utils.ping(
         ip, count, interface=ifname, packetsize=max_icmp_pkt_size, timeout=float(count) * 2
     )
     ratio = virt_test_utils.get_loss_ratio(o)
     if ratio != 0:
         raise error.TestFail("Loss ratio of large frame ping is %s" % ratio)
Пример #2
0
 def verify_mtu():
     logging.info("Verify the path MTU")
     s, o = virt_test_utils.ping(ip, 10, interface=ifname, packetsize=max_icmp_pkt_size, hint="do", timeout=15)
     if s != 0:
         logging.error(o)
         raise error.TestFail("Path MTU is not as expected")
     if virt_test_utils.get_loss_ratio(o) != 0:
         logging.error(o)
         raise error.TestFail("Packet loss ratio during MTU " "verification is not zero")
Пример #3
0
 def large_frame_ping(count=100):
     logging.info("Large frame ping")
     s, o = virt_test_utils.ping(ip, count, interface=ifname,
                                packetsize=max_icmp_pkt_size,
                                timeout=float(count) * 2)
     ratio = virt_test_utils.get_loss_ratio(o)
     if ratio != 0:
         raise error.TestFail("Loss ratio of large frame ping is %s" %
                              ratio)
Пример #4
0
    def set_link_test(linkid):
        """
        Issue set_link commands and test its function

        @param linkid: id of netdev or devices to be tested
        """
        ip = vm.get_address(0)

        vm.monitor.cmd("set_link %s down" % linkid)
        s, o = virt_test_utils.ping(ip, count=10, timeout=20)
        if virt_test_utils.get_loss_ratio(o) != 100:
            raise error.TestFail("Still can ping the %s after down %s" %
                                 (ip, linkid))

        vm.monitor.cmd("set_link %s up" % linkid)
        s, o = virt_test_utils.ping(ip, count=10, timeout=20)
        # we use 100% here as the notification of link status changed may be
        # delayed in guest driver
        if virt_test_utils.get_loss_ratio(o) == 100:
            raise error.TestFail("Packet loss during ping %s after up %s" %
                                 (ip, linkid))
Пример #5
0
        def size_increase_ping(step=random.randrange(90, 110)):
            logging.info("Size increase ping")
            for size in range(0, max_icmp_pkt_size + 1, step):
                logging.info("Ping %s with size %s", ip, size)
                s, o = virt_test_utils.ping(ip, 1, interface=ifname, packetsize=size, hint="do", timeout=1)
                if s != 0:
                    s, o = virt_test_utils.ping(
                        ip, 10, interface=ifname, packetsize=size, adaptive=True, hint="do", timeout=20
                    )

                    if virt_test_utils.get_loss_ratio(o) > int(params.get("fail_ratio", 50)):
                        raise error.TestFail("Ping loss ratio is greater " "than 50% for size %s" % size)
Пример #6
0
 def verify_mtu():
     logging.info("Verify the path MTU")
     s, o = virt_test_utils.ping(ip, 10, interface=ifname,
                                packetsize=max_icmp_pkt_size,
                                hint="do", timeout=15)
     if s != 0 :
         logging.error(o)
         raise error.TestFail("Path MTU is not as expected")
     if virt_test_utils.get_loss_ratio(o) != 0:
         logging.error(o)
         raise error.TestFail("Packet loss ratio during MTU "
                              "verification is not zero")
Пример #7
0
        def size_increase_ping(step=random.randrange(90, 110)):
            logging.info("Size increase ping")
            for size in range(0, max_icmp_pkt_size + 1, step):
                logging.info("Ping %s with size %s", ip, size)
                s, o = virt_test_utils.ping(ip, 1, interface=ifname,
                                           packetsize=size,
                                           hint="do", timeout=1)
                if s != 0:
                    s, o = virt_test_utils.ping(ip, 10, interface=ifname,
                                               packetsize=size,
                                               adaptive=True, hint="do",
                                               timeout=20)

                    if virt_test_utils.get_loss_ratio(o) > int(params.get(
                                                      "fail_ratio", 50)):
                        raise error.TestFail("Ping loss ratio is greater "
                                             "than 50% for size %s" % size)
Пример #8
0
def run_ping(test, params, env):
    """
    Ping the guest with different size of packets.

    Packet Loss Test:
    1) Ping the guest with different size/interval of packets.

    Stress Test:
    1) Flood ping the guest.
    2) Check if the network is still usable.

    @param test: KVM test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))

    counts = params.get("ping_counts", 100)
    flood_minutes = float(params.get("flood_minutes", 10))
    nics = params.get("nics").split()
    strict_check = params.get("strict_check", "no") == "yes"

    packet_size = [0, 1, 4, 48, 512, 1440, 1500, 1505, 4054, 4055, 4096, 4192,
                   8878, 9000, 32767, 65507]

    try:
        for i, nic in enumerate(nics):
            ip = vm.get_address(i)
            if not ip:
                logging.error("Could not get the ip of nic index %d: %s",
                              i, nic)
                continue

            for size in packet_size:
                logging.info("Ping with packet size %s", size)
                status, output = virt_test_utils.ping(ip, 10,
                                                     packetsize=size,
                                                     timeout=20)
                if strict_check:
                    ratio = virt_test_utils.get_loss_ratio(output)
                    if ratio != 0:
                        raise error.TestFail("Loss ratio is %s for packet size"
                                             " %s" % (ratio, size))
                else:
                    if status != 0:
                        raise error.TestFail("Ping failed, status: %s,"
                                             " output: %s" % (status, output))

            logging.info("Flood ping test")
            virt_test_utils.ping(ip, None, flood=True, output_func=None,
                                timeout=flood_minutes * 60)

            logging.info("Final ping test")
            status, output = virt_test_utils.ping(ip, counts,
                                                 timeout=float(counts) * 1.5)
            if strict_check:
                ratio = virt_test_utils.get_loss_ratio(output)
                if ratio != 0:
                    raise error.TestFail("Ping failed, status: %s,"
                                         " output: %s" % (status, output))
            else:
                if status != 0:
                    raise error.TestFail("Ping returns non-zero value %s" %
                                         output)
    finally:
        session.close()
Пример #9
0
def run_ping(test, params, env):
    """
    Ping the guest with different size of packets.

    Packet Loss Test:
    1) Ping the guest with different size/interval of packets.

    Stress Test:
    1) Flood ping the guest.
    2) Check if the network is still usable.

    @param test: KVM test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))

    counts = params.get("ping_counts", 100)
    flood_minutes = float(params.get("flood_minutes", 10))
    nics = params.get("nics").split()
    strict_check = params.get("strict_check", "no") == "yes"

    packet_size = [
        0, 1, 4, 48, 512, 1440, 1500, 1505, 4054, 4055, 4096, 4192, 8878, 9000,
        32767, 65507
    ]

    try:
        for i, nic in enumerate(nics):
            ip = vm.get_address(i)
            if not ip:
                logging.error("Could not get the ip of nic index %d: %s", i,
                              nic)
                continue

            for size in packet_size:
                logging.info("Ping with packet size %s", size)
                status, output = virt_test_utils.ping(ip,
                                                      10,
                                                      packetsize=size,
                                                      timeout=20)
                if strict_check:
                    ratio = virt_test_utils.get_loss_ratio(output)
                    if ratio != 0:
                        raise error.TestFail("Loss ratio is %s for packet size"
                                             " %s" % (ratio, size))
                else:
                    if status != 0:
                        raise error.TestFail("Ping failed, status: %s,"
                                             " output: %s" % (status, output))

            logging.info("Flood ping test")
            virt_test_utils.ping(ip,
                                 None,
                                 flood=True,
                                 output_func=None,
                                 timeout=flood_minutes * 60)

            logging.info("Final ping test")
            status, output = virt_test_utils.ping(ip,
                                                  counts,
                                                  timeout=float(counts) * 1.5)
            if strict_check:
                ratio = virt_test_utils.get_loss_ratio(output)
                if ratio != 0:
                    raise error.TestFail("Ping failed, status: %s,"
                                         " output: %s" % (status, output))
            else:
                if status != 0:
                    raise error.TestFail("Ping returns non-zero value %s" %
                                         output)
    finally:
        session.close()