Esempio n. 1
0
                    def worker(mig_data):
                        vm = env.get_vm("vm1")
                        session = vm.wait_for_login(timeout=self.login_timeout)

                        install_cpuflags_test_on_vm(vm, install_path)

                        Flags = check_cpuflags_work(
                            vm, install_path, flags.all_possible_guest_flags)
                        logging.info("Woking CPU flags: %s", str(Flags[0]))
                        logging.info("Not working CPU flags: %s",
                                     str(Flags[1]))
                        logging.warning(
                            "Flags works even if not deffined on"
                            " guest cpu flags: %s",
                            str(Flags[0] - flags.guest_flags))
                        logging.warning("Not tested CPU flags: %s",
                                        str(Flags[2]))
                        session.sendline("nohup dd if=/dev/[svh]da of=/tmp/"
                                         "stressblock bs=10MB count=100 &")

                        cmd = (
                            "nohup %s/cpuflags-test --stress  %s%s &" %
                            (os.path.join(install_path, "test_cpu_flags"), smp,
                             virt_utils.kvm_flags_to_stresstests(
                                 Flags[0] & flags.guest_flags)))
                        logging.debug("Guest_flags: %s",
                                      str(flags.guest_flags))
                        logging.debug("Working_flags: %s", str(Flags[0]))
                        logging.debug("Start stress on guest: %s", cmd)
                        session.sendline(cmd)
Esempio n. 2
0
                    def worker(mig_data):
                        vm = env.get_vm("vm1")
                        session = vm.wait_for_login(timeout=self.login_timeout)

                        install_cpuflags_test_on_vm(vm, install_path)

                        Flags = check_cpuflags_work(vm, install_path,
                                            flags.all_possible_guest_flags)
                        logging.info("Woking CPU flags: %s", str(Flags[0]))
                        logging.info("Not working CPU flags: %s",
                                     str(Flags[1]))
                        logging.warning("Flags works even if not deffined on"
                                        " guest cpu flags: %s",
                                        str(Flags[0] - flags.guest_flags))
                        logging.warning("Not tested CPU flags: %s",
                                        str(Flags[2]))
                        session.sendline("nohup dd if=/dev/[svh]da of=/tmp/"
                                         "stressblock bs=10MB count=100 &")

                        cmd = ("nohup %s/cpuflags-test --stress  %s%s &" %
                               (os.path.join(install_path, "test_cpu_flags"),
                                smp,
                                virt_utils.kvm_flags_to_stresstests(Flags[0] &
                                                        flags.guest_flags)))
                        logging.debug("Guest_flags: %s",
                                      str(flags.guest_flags))
                        logging.debug("Working_flags: %s", str(Flags[0]))
                        logging.debug("Start stress on guest: %s", cmd)
                        session.sendline(cmd)
Esempio n. 3
0
 def run_stress(timeout, flags, smp):
     """
     Run stress on vm for timeout time.
     """
     ret = False
     flags = check_cpuflags_work(flags)
     try:
         utils.run("./cpuflags-test --stress %s%s" %
                   (smp, virt_utils.kvm_flags_to_stresstests(flags[0])),
                   timeout)
     except error.CmdError:
         ret = True
     return ret
Esempio n. 4
0
 def run_stress(timeout, flags, smp):
     """
     Run stress on vm for timeout time.
     """
     ret = False
     flags = check_cpuflags_work(flags)
     try:
         utils.run(
             "./cpuflags-test --stress %s%s" %
             (smp, virt_utils.kvm_flags_to_stresstests(flags[0])),
             timeout)
     except error.CmdError:
         ret = True
     return ret
Esempio n. 5
0
        def test(self):
            cpu_model, extra_flags = parse_cpu_model()

            flags = HgFlags(cpu_model, extra_flags)

            logging.debug("Cpu mode flags %s.",
                          str(flags.quest_cpu_model_flags))
            logging.debug("Added flags %s.",
                          str(flags.cpumodel_unsupport_flags))
            cpuf_model = cpu_model

            # Add unsupported flags.
            for fadd in flags.cpumodel_unsupport_flags:
                cpuf_model += ",+" + str(fadd)

            for fdel in flags.host_unsupported_flags:
                cpuf_model += ",-" + str(fdel)

            (self.vm, _) = start_guest_with_cpuflags(cpuf_model, smp)

            install_path = "/tmp"
            install_cpuflags_test_on_vm(self.vm, install_path)
            flags = check_cpuflags_work(self.vm, install_path,
                                        flags.guest_flags)
            dd_session = self.vm.wait_for_login()
            stress_session = self.vm.wait_for_login()

            dd_session.sendline("nohup dd if=/dev/[svh]da of=/tmp/"
                                "stressblock bs=10MB count=100 &")
            cmd = ("nohup %s/cpuflags-test --stress  %s%s &" %
                   (os.path.join(install_path, "test_cpu_flags"), smp,
                    virt_utils.kvm_flags_to_stresstests(flags[0])))
            stress_session.sendline(cmd)

            time.sleep(5)

            self.vm.monitor.migrate_set_speed(mig_speed)
            self.vm.migrate(mig_timeout, mig_protocol, offline=False)

            time.sleep(5)

            #If cpuflags-test hang up during migration test raise exception
            try:
                stress_session.cmd('killall cpuflags-test')
            except aexpect.ShellCmdError:
                raise error.TestFail("Cpuflags-test should work after"
                                     " migration.")
Esempio n. 6
0
        def test(self):
            cpu_model, extra_flags = parse_cpu_model()

            flags = HgFlags(cpu_model, extra_flags)

            logging.debug("Cpu mode flags %s.",
                          str(flags.quest_cpu_model_flags))
            logging.debug("Added flags %s.",
                          str(flags.cpumodel_unsupport_flags))
            cpuf_model = cpu_model

            # Add unsupported flags.
            for fadd in flags.cpumodel_unsupport_flags:
                cpuf_model += ",+" + fadd

            for fdel in flags.host_unsupported_flags:
                cpuf_model += ",-" + fdel

            (self.vm, _) = start_guest_with_cpuflags(cpuf_model, smp)

            install_path = "/tmp"
            install_cpuflags_test_on_vm(self.vm, install_path)
            flags = check_cpuflags_work(self.vm, install_path,
                                        flags.guest_flags)
            dd_session = self.vm.wait_for_login()
            stress_session = self.vm.wait_for_login()

            dd_session.sendline("nohup dd if=/dev/[svh]da of=/tmp/"
                                "stressblock bs=10MB count=100 &")
            cmd = ("nohup %s/cpuflags-test --stress  %s%s &" %
                   (os.path.join(install_path, "test_cpu_flags"), smp,
                   virt_utils.kvm_flags_to_stresstests(flags[0])))
            stress_session.sendline(cmd)

            time.sleep(5)

            self.vm.monitor.migrate_set_speed(mig_speed)
            self.vm.migrate(mig_timeout, mig_protocol, offline=False)

            time.sleep(5)

            #If cpuflags-test hang up during migration test raise exception
            try:
                stress_session.cmd('killall cpuflags-test')
            except aexpect.ShellCmdError:
                raise error.TestFail("Cpuflags-test should work after"
                                     " migration.")
Esempio n. 7
0
 def run_stress(vm, timeout, guest_flags):
     """
     Run stress on vm for timeout time.
     """
     ret = False
     install_path = "/tmp"
     install_cpuflags_test_on_vm(vm, install_path)
     flags = check_cpuflags_work(vm, install_path, guest_flags)
     dd_session = vm.wait_for_login()
     stress_session = vm.wait_for_login()
     dd_session.sendline("dd if=/dev/[svh]da of=/tmp/stressblock"
                         " bs=10MB count=100 &")
     try:
         stress_session.cmd("%s/cpuflags-test --stress %s%s" %
                     (os.path.join(install_path, "test_cpu_flags"), smp,
                      virt_utils.kvm_flags_to_stresstests(flags[0])),
                     timeout=timeout)
     except aexpect.ShellTimeoutError:
         ret = True
     stress_session.close()
     dd_session.close()
     return ret
Esempio n. 8
0
 def run_stress(vm, timeout, guest_flags):
     """
     Run stress on vm for timeout time.
     """
     ret = False
     install_path = "/tmp"
     install_cpuflags_test_on_vm(vm, install_path)
     flags = check_cpuflags_work(vm, install_path, guest_flags)
     dd_session = vm.wait_for_login()
     stress_session = vm.wait_for_login()
     dd_session.sendline("dd if=/dev/[svh]da of=/tmp/stressblock"
                         " bs=10MB count=100 &")
     try:
         stress_session.cmd(
             "%s/cpuflags-test --stress %s%s" %
             (os.path.join(install_path, "test_cpu_flags"), smp,
              virt_utils.kvm_flags_to_stresstests(flags[0])),
             timeout=timeout)
     except aexpect.ShellTimeoutError:
         ret = True
     stress_session.close()
     dd_session.close()
     return ret
Esempio n. 9
0
        def test(self):
            """
            Test migration between multiple hosts.
            """
            def guest_active(vm):
                o = vm.monitor.info("status")
                if isinstance(o, str):
                    return "status: running" in o
                else:
                    return o.get("status") == "running"

            cpu_model, extra_flags = parse_cpu_model()

            flags = HgFlags(cpu_model, extra_flags)

            logging.debug("Cpu mode flags %s.",
                          str(flags.quest_cpu_model_flags))
            logging.debug("Added flags %s.",
                          str(flags.cpumodel_unsupport_flags))
            cpuf_model = cpu_model

            for fadd in extra_flags:
                cpuf_model += ",+" + fadd

            for fdel in flags.host_unsupported_flags:
                cpuf_model += ",-" + fdel

            install_path = "/tmp"
            login_timeout = int(params.get("login_timeout", 360))
            role = params.get("role")
            srchost = params.get("srchost")
            dsthost = params.get("dsthost")
            # Port used to communicate info between source and destination
            comm_port = int(params.get("comm_port", 12324))
            comm_timeout = float(params.get("comm_timeout", "10"))
            regain_ip_cmd = params.get("regain_ip_cmd", "dhclient")

            if role == 'source':
                (self.vm, session) = start_guest_with_cpuflags(cpuf_model,
                                                               smp)

                install_cpuflags_test_on_vm(self.vm, install_path)

                Flags = check_cpuflags_work(self.vm, install_path,
                                            flags.all_possible_guest_flags)
                logging.info("Woking CPU flags: %s", str(Flags[0]))
                logging.info("Not working CPU flags: %s", str(Flags[1]))
                logging.warning("Flags works even if not deffined on"
                                " guest cpu flags: %s",
                                str(Flags[0] - flags.guest_flags))
                logging.warning("Not tested CPU flags: %s", str(Flags[2]))

                session.sendline("nohup dd if=/dev/[svh]da of=/tmp/"
                                "stressblock bs=10MB count=100 &")

                cmd = ("nohup %s/cpuflags-test --stress  %s%s &" %
                      (os.path.join(install_path, "test_cpu_flags"), smp,
                      virt_utils.kvm_flags_to_stresstests(Flags[0] &
                                                    flags.guest_flags)))
                logging.debug("Guest_flags: %s", str(flags.guest_flags))
                logging.debug("Working_flags: %s", str(Flags[0]))
                logging.debug("Start stress on guest: %s", cmd)
                session.sendline(cmd)

                # Listen on a port to get the migration port received from
                # dest machine
                s_socket = socket.socket(socket.AF_INET,
                                         socket.SOCK_STREAM)
                s_socket.bind(('', comm_port))
                s_socket.listen(1)
                s_socket.settimeout(comm_timeout)

                # Wait 30 seconds for source and dest to reach this point
                test.job.barrier(srchost,
                                 'socket_started', 120).rendezvous(srchost,
                                                                  dsthost)

                c_socket = s_socket.accept()[0]

                mig_port = int(c_socket.recv(6))
                logging.info("Received from destination the"
                             " migration port %s" % mig_port)
                c_socket.close()

                #Wait for start cpuflags-test stress.
                time.sleep(10)
                logging.info("Start migrating now...")
                self.vm.monitor.migrate_set_speed(mig_speed)
                self.vm.migrate(dest_host=dsthost, remote_port=mig_port)

                # Wait up to 30 seconds for dest to reach this point
                test.job.barrier(srchost,
                                 'mig_finished', 30).rendezvous(srchost,
                                                                dsthost)

            elif role == 'destination':
                # Wait up to login_timeout + 30 seconds for the source to
                # reach this point
                (self.vm, _) = start_guest_with_cpuflags(cpuf_model,
                                                         smp,
                                                         True,
                                                         False)

                test.job.barrier(dsthost, 'socket_started',
                                 login_timeout + 120).rendezvous(srchost,
                                                                dsthost)

                c_socket = socket.socket(socket.AF_INET,
                                         socket.SOCK_STREAM)
                c_socket.settimeout(comm_timeout)
                c_socket.connect((srchost, comm_port))

                logging.info("Communicating to source migration"
                             " port %s" % self.vm.migration_port)
                c_socket.send("%d" % self.vm.migration_port)
                c_socket.close()

                # Wait up to mig_timeout + 30 seconds for the source to
                # reach this point: migration finished
                test.job.barrier(dsthost, 'mig_finished',
                                 mig_timeout + 30).rendezvous(srchost,
                                                              dsthost)

                if not guest_active(self.vm):
                    raise error.TestFail("Guest not active after"
                                         " migration")

                logging.info("Migrated guest appears to be running")

                # Log into the guest again
                logging.info("Logging into migrated guest after"
                             " migration...")
                session_serial = self.vm.wait_for_serial_login(
                                                    timeout=login_timeout)
                session_serial.cmd(regain_ip_cmd)

                self.vm.verify_illegal_instructonn()

                session = self.vm.wait_for_login(timeout=login_timeout)

                try:
                    session.cmd('killall cpuflags-test')
                except aexpect.ShellCmdError:
                    raise error.TestFail("The cpuflags-test program should"
                                         " be active after migration and"
                                         " it's not.")

                Flags = check_cpuflags_work(self.vm, install_path,
                                            flags.all_possible_guest_flags)
                logging.info("Woking CPU flags: %s", str(Flags[0]))
                logging.info("Not working CPU flags: %s", str(Flags[1]))
                logging.warning("Flags works even if not deffined on"
                                " guest cpu flags: %s",
                                str(Flags[0] - flags.guest_flags))
                logging.warning("Not tested CPU flags: %s", str(Flags[2]))

            else:
                raise error.TestError('Invalid role specified')
Esempio n. 10
0
        def test(self):
            """
            Test migration between multiple hosts.
            """
            def guest_active(vm):
                o = vm.monitor.info("status")
                if isinstance(o, str):
                    return "status: running" in o
                else:
                    return o.get("status") == "running"

            cpu_model, extra_flags = parse_cpu_model()

            flags = HgFlags(cpu_model, extra_flags)

            logging.debug("Cpu mode flags %s.",
                          str(flags.quest_cpu_model_flags))
            logging.debug("Added flags %s.",
                          str(flags.cpumodel_unsupport_flags))
            cpuf_model = cpu_model

            for fadd in extra_flags:
                cpuf_model += ",+" + fadd

            for fdel in flags.host_unsupported_flags:
                cpuf_model += ",-" + fdel

            install_path = "/tmp"
            login_timeout = int(params.get("login_timeout", 360))
            role = params.get("role")
            srchost = params.get("srchost")
            dsthost = params.get("dsthost")
            # Port used to communicate info between source and destination
            comm_port = int(params.get("comm_port", 12324))
            comm_timeout = float(params.get("comm_timeout", "10"))
            regain_ip_cmd = params.get("regain_ip_cmd", "dhclient")

            if role == 'source':
                (self.vm, session) = start_guest_with_cpuflags(cpuf_model, smp)

                install_cpuflags_test_on_vm(self.vm, install_path)

                Flags = check_cpuflags_work(self.vm, install_path,
                                            flags.all_possible_guest_flags)
                logging.info("Woking CPU flags: %s", str(Flags[0]))
                logging.info("Not working CPU flags: %s", str(Flags[1]))
                logging.warning(
                    "Flags works even if not deffined on"
                    " guest cpu flags: %s", str(Flags[0] - flags.guest_flags))
                logging.warning("Not tested CPU flags: %s", str(Flags[2]))

                session.sendline("nohup dd if=/dev/[svh]da of=/tmp/"
                                 "stressblock bs=10MB count=100 &")

                cmd = (
                    "nohup %s/cpuflags-test --stress  %s%s &" %
                    (os.path.join(install_path, "test_cpu_flags"), smp,
                     virt_utils.kvm_flags_to_stresstests(Flags[0]
                                                         & flags.guest_flags)))
                logging.debug("Guest_flags: %s", str(flags.guest_flags))
                logging.debug("Working_flags: %s", str(Flags[0]))
                logging.debug("Start stress on guest: %s", cmd)
                session.sendline(cmd)

                # Listen on a port to get the migration port received from
                # dest machine
                s_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                s_socket.bind(('', comm_port))
                s_socket.listen(1)
                s_socket.settimeout(comm_timeout)

                # Wait 30 seconds for source and dest to reach this point
                test.job.barrier(srchost, 'socket_started',
                                 120).rendezvous(srchost, dsthost)

                c_socket = s_socket.accept()[0]

                mig_port = int(c_socket.recv(6))
                logging.info("Received from destination the"
                             " migration port %s" % mig_port)
                c_socket.close()

                #Wait for start cpuflags-test stress.
                time.sleep(10)
                logging.info("Start migrating now...")
                self.vm.monitor.migrate_set_speed(mig_speed)
                self.vm.migrate(dest_host=dsthost, remote_port=mig_port)

                # Wait up to 30 seconds for dest to reach this point
                test.job.barrier(srchost, 'mig_finished',
                                 30).rendezvous(srchost, dsthost)

            elif role == 'destination':
                # Wait up to login_timeout + 30 seconds for the source to
                # reach this point
                (self.vm,
                 _) = start_guest_with_cpuflags(cpuf_model, smp, True, False)

                test.job.barrier(dsthost, 'socket_started',
                                 login_timeout + 120).rendezvous(
                                     srchost, dsthost)

                c_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                c_socket.settimeout(comm_timeout)
                c_socket.connect((srchost, comm_port))

                logging.info("Communicating to source migration"
                             " port %s" % self.vm.migration_port)
                c_socket.send("%d" % self.vm.migration_port)
                c_socket.close()

                # Wait up to mig_timeout + 30 seconds for the source to
                # reach this point: migration finished
                test.job.barrier(dsthost, 'mig_finished',
                                 mig_timeout + 30).rendezvous(
                                     srchost, dsthost)

                if not guest_active(self.vm):
                    raise error.TestFail("Guest not active after" " migration")

                logging.info("Migrated guest appears to be running")

                # Log into the guest again
                logging.info("Logging into migrated guest after"
                             " migration...")
                session_serial = self.vm.wait_for_serial_login(
                    timeout=login_timeout)
                session_serial.cmd(regain_ip_cmd)

                self.vm.verify_illegal_instructonn()

                session = self.vm.wait_for_login(timeout=login_timeout)

                try:
                    session.cmd('killall cpuflags-test')
                except aexpect.ShellCmdError:
                    raise error.TestFail("The cpuflags-test program should"
                                         " be active after migration and"
                                         " it's not.")

                Flags = check_cpuflags_work(self.vm, install_path,
                                            flags.all_possible_guest_flags)
                logging.info("Woking CPU flags: %s", str(Flags[0]))
                logging.info("Not working CPU flags: %s", str(Flags[1]))
                logging.warning(
                    "Flags works even if not deffined on"
                    " guest cpu flags: %s", str(Flags[0] - flags.guest_flags))
                logging.warning("Not tested CPU flags: %s", str(Flags[2]))

            else:
                raise error.TestError('Invalid role specified')