예제 #1
0
 def setUp(self):
     utils_lib.init_case(self)
     if utils_lib.is_arch(self, arch='aarch64'):
         ltp_url = self.params.get('ltp_url_aarch64')
     else:
         ltp_url = self.params.get('ltp_url_x86_64')
     utils_lib.pkg_install(self, pkg_name='ltp', pkg_url=ltp_url)
     self.cursor = utils_lib.get_cmd_cursor(self, cmd='journalctl --since today', rmt_redirect_stdout=True)
예제 #2
0
 def setUp(self):
     utils_lib.init_case(self)
     if utils_lib.is_arch(self, arch='aarch64'):
         blktests_url = self.params.get('blktests_url_aarch64')
     else:
         blktests_url = self.params.get('blktests_url_x86_64')
     utils_lib.pkg_install(self, pkg_name='blktests', pkg_url=blktests_url)
     self.cursor = utils_lib.get_cmd_cursor(self,
                                            cmd='journalctl --since today')
예제 #3
0
 def setUp(self):
     utils_lib.init_case(self)
     if utils_lib.is_arch(self, arch='aarch64'):
         ltp_rpm = self.utils_dir + '/ltp-master.aarch64.rpm'
         ltp_rpm_tmp = '/tmp/ltp-master.aarch64.rpm'
     else:
         ltp_rpm = self.utils_dir + '/ltp-master.x86_64.rpm'
         ltp_rpm_tmp = '/tmp/ltp-master.x86_64.rpm'
     cmd = 'ls -l /opt/ltp/runtest/smoketest'
     ret = utils_lib.run_cmd(self, cmd, ret_status=True, msg='Check if it is ltp version with smoketest')
     if not utils_lib.is_pkg_installed(self, pkg_name='ltp',is_install=False) or ret != 0:
         if self.params['remote_node'] is not None:
             self.log.info('Copy {} to remote'.format(ltp_rpm))
             self.SSH.put_file(local_file=ltp_rpm, rmt_file=ltp_rpm_tmp)
             ltp_rpm = ltp_rpm_tmp
     if ret != 0:
         force = True
     else:
         force = False
     utils_lib.pkg_install(self, pkg_name='ltp', pkg_url=ltp_rpm, force=force)
     self.cursor = utils_lib.get_cmd_cursor(self, rmt_redirect_stdout=True)
예제 #4
0
    def test_hibernate_resume(self):
        """
        case_tag:
            lifecycle
        case_name:
            test_hibernate_resume
        case_file:
            https://github.com/virt-s1/os-tests/blob/master/os_tests/tests/test_vm_operation.py
        component:
            kernel
        bugzilla_id:
            1898677
        is_customer_case:
            True
        testplan:
            N/A
        maintainer:
            [email protected]
        description:
            Test system hibernation and process is still running after resumed
        key_steps: |
            1. enable hibernation on system
            2. start a test process, eg. sleep 1800
            3. hibernate system
            4. start system
            5. the test process still running
        expect_result:
            test process resume successfully
        debug_want:
            dmesg or console output
        """
        if not self.vm:
            self.skipTest('vm not init')
        utils_lib.run_cmd(self,
                          'lscpu',
                          expect_ret=0,
                          cancel_not_kw="Xen",
                          msg="Not support in xen instance")
        utils_lib.is_cmd_exist(self, "acpid")
        if self.vm.provider == 'aws':
            product_id = utils_lib.get_os_release_info(self,
                                                       field='VERSION_ID')
            if float(product_id) >= 8.0 and float(product_id) < 9.0:
                pkg_url = 'https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/e/ec2-hibinit-agent-1.0.4-1.el8.noarch.rpm'
            elif float(product_id) < 8.0:
                self.skipTest('not supported earlier than rhel8')
            else:
                pkg_url = "https://dl.fedoraproject.org/pub/fedora/linux/releases/34/Everything/x86_64/os/Packages/e/ec2-hibinit-agent-1.0.3-5.fc34.noarch.rpm"
            utils_lib.pkg_install(self,
                                  pkg_name='ec2-hibinit-agent',
                                  pkg_url=pkg_url,
                                  force=True)
            cmd = 'sudo systemctl is-enabled hibinit-agent.service'
            output = utils_lib.run_cmd(self, cmd)
            if 'enabled' not in output:
                cmd = 'sudo systemctl enable --now hibinit-agent.service'
                utils_lib.run_cmd(self, cmd)
                utils_lib.run_cmd(self,
                                  'sudo reboot',
                                  msg='reboot system under test')
                utils_lib.init_connection(self, timeout=self.ssh_timeout)
                timeout = 180
                interval = 5
                time_start = int(time.time())
                while True:
                    cmd = 'sudo systemctl is-active hibinit-agent.service'
                    out = utils_lib.run_cmd(self, cmd)
                    if 'inactive' in out:
                        break
                    time_end = int(time.time())
                    if time_end - time_start > timeout:
                        self.log.info('timeout ended: {}'.format(timeout))
                        break
                    self.log.info('retry after {}s'.format(interval))
                    time.sleep(interval)
                cmd = 'sudo systemctl status hibinit-agent.service'
                utils_lib.run_cmd(self, cmd)
        else:
            cmd = 'cat /proc/swaps'
            output = utils_lib.run_cmd(self,
                                       cmd,
                                       msg='check whether system has swap on')
            if '-2' not in output:
                self.log.info("No swap found, creating new one")
                cmd = """
                    sudo dd if=/dev/zero of=/swap bs=1024 count=2000000;
                    sudo chmod 0600 /swap;
                    sudo mkswap /swap;
                    sudo swapon /swap;
                    offset=$(filefrag -v /swap| awk '{if($1==\"0:\"){print $4}}');
                    uuid=$(findmnt -no UUID -T /swap);
                    sudo grubby --update-kernel=ALL  --args=\"resume_offset=${offset//.} resume=UUID=$uuid\";
                    sudo echo '/swap    swap    swap   defaults 0 0' >> /etc/fstab
                    """
                utils_lib.run_cmd(self, cmd, timeout=240)

        cmd = "sleep 360 > /dev/null 2>&1 &"
        utils_lib.run_cmd(self, cmd)
        vm_hibernate_success = False
        try:
            if not self.vm.send_hibernation():
                self.skipTest('send hibernate not succeed')
            vm_hibernate_success = True
        except NotImplementedError:
            self.log.info(
                'send_hibernation func is not implemented in {}'.format(
                    self.vm.provider))
        except UnSupportedAction:
            self.log.info(
                'send_hibernation func is not supported in {}'.format(
                    self.vm.provider))
        if not vm_hibernate_success:
            cmd = "sudo systemctl hibernate"
            utils_lib.run_cmd(self, cmd, msg="Try to hibernate inside system!")
            time.sleep(20)

        self.vm.start()
        time.sleep(10)
        self.params['remote_node'] = self.vm.floating_ip
        utils_lib.init_connection(self, timeout=self.ssh_timeout)
        utils_lib.run_cmd(self,
                          'dmesg',
                          expect_kw="Restarting tasks",
                          expect_not_kw="Call",
                          msg="check the system is resumed")
        cmd = 'pgrep -a sleep'
        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          msg='check sleep process still exists')