def test_check_timedrift_stress(self): ''' :avocado: tags=test_check_timedrift_stress After 120 seconds stress test, if the average drift time over 1 seconds, we are considering it as fail. polarion_id: RHEL7-110673 ''' utils_lib.run_cmd(self, r"sudo cat /etc/redhat-release", expect_ret=0, cancel_kw="release 7,release 6", msg="Only run in RHEL7 and RHEL6") utils_lib.run_cmd(self, "sudo systemctl stop ntpd") utils_lib.run_cmd(self, "sudo systemctl disable ntpd") utils_lib.run_cmd(self, "sudo systemctl stop chronyd") utils_lib.run_cmd(self, "sudo systemctl disable chronyd") utils_lib.run_cmd(self, "sudo timedatectl set-ntp 0") offset1 = aws.get_drift(self) stress_url = self.params.get('stress_url') aws.install_pkgs(self.session, stress_url) cpu_count = utils_lib.run_cmd( self, 'cat /proc/cpuinfo |grep -i "model name"|wc -l') utils_lib.run_cmd(self, "stress -c %s -t 120" % cpu_count, timeout=160) offset2 = aws.get_drift(self) x = decimal.Decimal(offset2) - decimal.Decimal(offset1) drift = math.fabs(x) * 10 self.assertLess(drift, 10, msg="Drift is over 1 seconds") self.log.info("Average drift is less than 1 seconfs. %d/10" % drift)
def test_check_timedrift_reboot(self): ''' :avocado: tags=test_check_timedrift_reboot After 3 times reboot, if the average drift time over 1 seconds, we are considering it as fail. polarion_id: RHEL7-110672 ''' utils_lib.run_cmd(self, "sudo cat /etc/redhat-release", expect_ret=0, cancel_kw="release 7,release 6", msg="Only run in RHEL7 and RHEL6") utils_lib.run_cmd(self, "sudo systemctl stop ntpd") utils_lib.run_cmd(self, "sudo systemctl disable ntpd") utils_lib.run_cmd(self, "sudo systemctl stop chronyd") utils_lib.run_cmd(self, "sudo systemctl disable chronyd") utils_lib.run_cmd(self, "sudo timedatectl set-ntp 0") offset1 = aws.get_drift(self) self.vm.reboot() self.session.connect(timeout=self.ssh_wait_timeout) offset2 = aws.get_drift(self) self.vm.reboot() self.session.connect(timeout=self.ssh_wait_timeout) offset3 = aws.get_drift(self) self.vm.reboot() self.session.connect(timeout=self.ssh_wait_timeout) offset4 = aws.get_drift(self) x = decimal.Decimal(offset2) - decimal.Decimal(offset1) y = decimal.Decimal(offset3) - decimal.Decimal(offset1) z = decimal.Decimal(offset4) - decimal.Decimal(offset1) drift = math.fabs(x) * 10 + math.fabs(y) * 10 + math.fabs(z) * 10 self.assertLess(drift, 30, msg="Drift is over 1 seconds") self.log.info("Average drift is less than 1 seconds. %d/30" % drift)