コード例 #1
0
ファイル: set_link.py プロジェクト: isabella232/autotest
def run_set_link(test, params, env):
    """
    KVM guest link test:
    1) Boot up guest with one nic
    2) Ping guest from host
    3) Disable guest link and ping guest from host
    4) Re-enable guest link and ping guest from host
    5) Do file transfer test

    @param test: kvm test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment.
    """
    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
    timeout = float(params.get("login_timeout", 360))
    session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2)

    ip = vm.get_address(0)
    linkname = vm.netdev_id[0]

    logging.info("Pinging guest from host")
    s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
    if s != 0:
        raise error.TestFail("Ping failed, status: %s, output: %s" % (s, o))
    ratio = kvm_test_utils.get_loss_ratio(o)
    if ratio != 0:
        raise error.TestFail("Loss ratio is %s, output: %s" % (ratio, o))

    logging.info("Executing 'set link %s off'", linkname)
    vm.monitor.cmd("set_link %s off" % linkname)
    logging.info(vm.monitor.info("network"))
    logging.info("Pinging guest from host")
    s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
    if s == 0:
        raise error.TestFail("Ping unexpectedly succeeded, status: %s,"
                             "output: %s" % (s, o))
    ratio = kvm_test_utils.get_loss_ratio(o)
    if ratio != 100:
        raise error.TestFail("Loss ratio is not 100%%,"
                             "Loss ratio is %s" % ratio)

    logging.info("Executing 'set link %s on'", linkname)
    vm.monitor.cmd("set_link %s on" % linkname)
    logging.info(vm.monitor.info("network"))
    logging.info("Pinging guest from host")
    s, o = kvm_test_utils.ping(ip, count=10, timeout=20)
    if s != 0:
        raise error.TestFail("Ping failed, status: %s, output: %s" % (s, o))
    ratio = kvm_test_utils.get_loss_ratio(o)
    if ratio != 0:
        raise error.TestFail("Loss ratio is %s, output: %s" % (ratio, o))

    file_transfer.run_file_transfer(test, params, env)
    session.close()
コード例 #2
0
ファイル: jumbo.py プロジェクト: ceph/autotest
 def large_frame_ping(count=100):
     logging.info("Large frame ping")
     s, o = kvm_test_utils.ping(ip, count, interface=ifname,
                                packetsize=max_icmp_pkt_size,
                                timeout=float(count) * 2)
     ratio = kvm_test_utils.get_loss_ratio(o)
     if ratio != 0:
         raise error.TestFail("Loss ratio of large frame ping is %s" %
                              ratio)
コード例 #3
0
 def large_frame_ping(count=100):
     logging.info("Large frame ping")
     s, o = kvm_test_utils.ping(ip,
                                count,
                                interface=ifname,
                                packetsize=max_icmp_pkt_size,
                                timeout=float(count) * 2)
     ratio = kvm_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 = kvm_test_utils.ping(ip, count=10, timeout=20)
        if kvm_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 = kvm_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 kvm_test_utils.get_loss_ratio(o) == 100:
            raise error.TestFail("Packet loss during ping %s after up %s" %
                                 (ip, linkid))
コード例 #5
0
ファイル: jumbo.py プロジェクト: ceph/autotest
 def verify_mtu():
     logging.info("Verify the path MTU")
     s, o = kvm_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 kvm_test_utils.get_loss_ratio(o) != 0:
         logging.error(o)
         raise error.TestFail("Packet loss ratio during MTU "
                              "verification is not zero")
コード例 #6
0
 def verify_mtu():
     logging.info("Verify the path MTU")
     s, o = kvm_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 kvm_test_utils.get_loss_ratio(o) != 0:
         logging.error(o)
         raise error.TestFail("Packet loss ratio during MTU "
                              "verification is not zero")
コード例 #7
0
ファイル: jumbo.py プロジェクト: ceph/autotest
        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 = kvm_test_utils.ping(ip, 1, interface=ifname,
                                           packetsize=size,
                                           hint="do", timeout=1)
                if s != 0:
                    s, o = kvm_test_utils.ping(ip, 10, interface=ifname,
                                               packetsize=size,
                                               adaptive=True, hint="do",
                                               timeout=20)

                    if kvm_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 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 = kvm_test_utils.ping(ip,
                                           1,
                                           interface=ifname,
                                           packetsize=size,
                                           hint="do",
                                           timeout=1)
                if s != 0:
                    s, o = kvm_test_utils.ping(ip,
                                               10,
                                               interface=ifname,
                                               packetsize=size,
                                               adaptive=True,
                                               hint="do",
                                               timeout=20)

                    if kvm_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)
コード例 #9
0
ファイル: ping.py プロジェクト: ehabkost/my-autotest-hacks
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 = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
    session = kvm_test_utils.wait_for_login(vm)

    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", i)
                continue

            for size in packet_size:
                logging.info("Ping with packet size %s", size)
                status, output = kvm_test_utils.ping(ip, 10,
                                                     packetsize=size,
                                                     timeout=20)
                if strict_check:
                    ratio = kvm_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")
            kvm_test_utils.ping(ip, None, flood=True, output_func=None,
                                timeout=flood_minutes * 60)

            logging.info("Final ping test")
            status, output = kvm_test_utils.ping(ip, counts,
                                                 timeout=float(counts) * 1.5)
            if strict_check:
                ratio = kvm_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()
コード例 #10
0
ファイル: ping.py プロジェクト: renormalist/autotest
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 = kvm_test_utils.ping(ip, 10,
                                                     packetsize=size,
                                                     timeout=20)
                if strict_check:
                    ratio = kvm_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")
            kvm_test_utils.ping(ip, None, flood=True, output_func=None,
                                timeout=flood_minutes * 60)

            logging.info("Final ping test")
            status, output = kvm_test_utils.ping(ip, counts,
                                                 timeout=float(counts) * 1.5)
            if strict_check:
                ratio = kvm_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()