未验证 提交 43bf981b 编写于 作者: Q Qianqian Zhu 提交者: GitHub

Merge pull request #1510 from sitoliu/drop_ntpdate_in_case

Replace ntpdate use in cases
...@@ -114,11 +114,9 @@ ...@@ -114,11 +114,9 @@
online = 1 online = 1
offline = 1 offline = 1
vcpu_num_rechek = no vcpu_num_rechek = no
ntp_server = "clock.redhat.com" ntp_sync_cmd = "(systemctl stop chronyd || service ntpdate stop)"
pre_command = "ntpdate ${ntp_server}" ntp_sync_cmd += " && chronyd -q 'server clock.redhat.com iburst'"
ntp_sync_cmd = "ntpdate ${ntp_server}" ntp_query_cmd = "chronyd -Q 'server clock.redhat.com iburst'"
ntp_query_cmd = "ntpdate -q ${ntp_server}"
ntp_service_stop_cmd = "service chronyd stop || service ntpdate stop"
variants: variants:
- after_10mins: - after_10mins:
# seconds switch vcpus between online and offline # seconds switch vcpus between online and offline
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
kill_vm = yes kill_vm = yes
requries_root = yes requries_root = yes
image_snapshot = yes image_snapshot = yes
pre_command = "service chronyd stop || service ntpdate stop" pre_command = "systemctl stop chronyd || service ntpdate stop"
post_command = "service chronyd restart || service ntpdate restart" post_command = "systemctl restart chronyd || service ntpdate restart"
sync_host_time_cmd = 'ntpdate clock.redhat.com; hwclock -w' sync_host_time_cmd = "chronyd -q 'server clock.redhat.com iburst'; hwclock -w"
host_epoch_time_cmd = 'epoch=$(date +%s); datetime=$(date);' host_epoch_time_cmd = 'epoch=$(date +%s); datetime=$(date);'
host_epoch_time_cmd += 'echo "datetime: $datetime epoch: $epoch"' host_epoch_time_cmd += 'echo "datetime: $datetime epoch: $epoch"'
time_difference = 0 time_difference = 0
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
type = timedrift_check_when_crash type = timedrift_check_when_crash
start_vm = no start_vm = no
ntp_server = "clock.redhat.com" ntp_server = "clock.redhat.com"
clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)"
clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'"
sleep_time = 1800 sleep_time = 1800
variants: variants:
- bsod: - bsod:
...@@ -32,5 +34,6 @@ ...@@ -32,5 +34,6 @@
# else guest will reboot immedicately that is unexpected in this test; # else guest will reboot immedicately that is unexpected in this test;
only Linux only Linux
nmi_cmd = "guest: echo '1' > /proc/sys/kernel/sysrq && echo '0' > /proc/sys/kernel/panic && service kdump stop; echo 'c' > /proc/sysrq-trigger" nmi_cmd = "guest: echo '1' > /proc/sys/kernel/sysrq && echo '0' > /proc/sys/kernel/panic && service kdump stop; echo 'c' > /proc/sysrq-trigger"
ntp_cmd = "ntpdate ${ntp_server}" ntp_cmd = "(systemctl stop chronyd || service ntpdate stop)"
ntp_query_cmd = "ntpdate -q ${ntp_server}" ntp_cmd += " && chronyd -q 'server clock.redhat.com iburst'"
ntp_query_cmd = "chronyd -Q 'server clock.redhat.com iburst'"
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
nettype = none nettype = none
login_timeout = 240 login_timeout = 240
guest_clock_source = "kvm-clock" guest_clock_source = "kvm-clock"
clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)"
clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'"
Linux: Linux:
type = timedrift_no_net type = timedrift_no_net
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
host_cpu_cnt_cmd = "cat /proc/cpuinfo | grep "physical id" | wc -l" host_cpu_cnt_cmd = "cat /proc/cpuinfo | grep "physical id" | wc -l"
variants: variants:
- tscwrite: - tscwrite:
only Fedora.19 RHEL.7 no RHEL.6
type = timerdevice_tscwrite type = timerdevice_tscwrite
msr_tools_install_cmd = "yum install -y msr-tools" msr_tools_install_cmd = "yum install -y msr-tools"
msr_tools_cmd = "a=$(rdmsr -d 0x00000010); echo -e ibase=16\\n $a | tail -n 1 | while read n; do wrmsr 0x00000010 $(($n+100000000000)); echo $n; done" msr_tools_cmd = "a=$(rdmsr -d 0x00000010); echo -e ibase=16\\n $a | tail -n 1 | while read n; do wrmsr 0x00000010 $(($n+100000000000)); echo $n; done"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
ntp_sync_cmd = "(systemctl stop chronyd || service ntpdate stop)" ntp_sync_cmd = "(systemctl stop chronyd || service ntpdate stop)"
ntp_sync_cmd += " && chronyd -q 'server clock.redhat.com iburst'" ntp_sync_cmd += " && chronyd -q 'server clock.redhat.com iburst'"
- clock_drift_with_ntp: - clock_drift_with_ntp:
only Fedora.19 RHEL.7 no RHEL.6
type = timerdevice_clock_drift_with_ntp type = timerdevice_clock_drift_with_ntp
test_run_timeout = 7200 test_run_timeout = 7200
- change_guest_clksource: - change_guest_clksource:
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
i386, x86_64: i386, x86_64:
rtc_drift = slew rtc_drift = slew
timerdevice_drift_threshold = 3 timerdevice_drift_threshold = 3
clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)"
clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'"
variants: variants:
- clock_host: - clock_host:
rtc_clock = host rtc_clock = host
...@@ -51,7 +53,7 @@ ...@@ -51,7 +53,7 @@
only Windows only Windows
timerdevice_clksource = "" timerdevice_clksource = ""
- clksource_kvm-clock: - clksource_kvm-clock:
only Fedora.19 RHEL only RHEL
timerdevice_clksource = "kvm-clock" timerdevice_clksource = "kvm-clock"
- clksource_tsc: - clksource_tsc:
# Fedora guest can't bootup without '-kvmclock' option. # Fedora guest can't bootup without '-kvmclock' option.
...@@ -78,7 +80,7 @@ ...@@ -78,7 +80,7 @@
- reboot_after_sleep: - reboot_after_sleep:
timerdevice_sleep_time = 3600 timerdevice_sleep_time = 3600
- tscsync: - tscsync:
only Fedora.19 RHEL.7 no RHEL.6
variants: variants:
- change_host_clksource: - change_host_clksource:
type = timerdevice_tscsync_change_host_clksource type = timerdevice_tscsync_change_host_clksource
......
...@@ -17,14 +17,13 @@ def run(test, params, env): ...@@ -17,14 +17,13 @@ def run(test, params, env):
2) After logged into the vm, check CPUs number 2) After logged into the vm, check CPUs number
3) Stop the guest if config 'stop_before_hotplug' 3) Stop the guest if config 'stop_before_hotplug'
4) sync guest clock via ntp server if config ntp_sync_cmd 4) sync guest clock via ntp server if config ntp_sync_cmd
5) stop ntp service in guest if config ntp_service_stop_cmd 5) Do cpu hotplug
6) Do cpu hotplug 6) Resume the guest if config 'stop_before_hotplug'
7) Resume the guest if config 'stop_before_hotplug' 7) Recheck guest get hot-pluged CPUs
8) Recheck guest get hot-pluged CPUs 8) Do cpu online/offline in guest and check clock
9) Do cpu online/offline in guest and check clock
offset via ntp server if config online/offline_cpus offset via ntp server if config online/offline_cpus
10) Run sub test after CPU Hotplug if run_sub_test is 'yes' 9) Run sub test after CPU Hotplug if run_sub_test is 'yes'
11) Recheck guest cpus after sub test if vcpu_num_rechek is 'yes' 10) Recheck guest cpus after sub test if vcpu_num_rechek is 'yes'
:param test: QEMU test object. :param test: QEMU test object.
:param params: Dictionary with test parameters. :param params: Dictionary with test parameters.
...@@ -96,7 +95,6 @@ def run(test, params, env): ...@@ -96,7 +95,6 @@ def run(test, params, env):
acceptable_offset = float(params.get("acceptable_offset", 5)) acceptable_offset = float(params.get("acceptable_offset", 5))
ntp_query_cmd = params.get("ntp_query_cmd", "") ntp_query_cmd = params.get("ntp_query_cmd", "")
ntp_sync_cmd = params.get("ntp_sync_cmd", "") ntp_sync_cmd = params.get("ntp_sync_cmd", "")
ntp_service_stop_cmd = params.get("ntp_service_stop_cmd")
error_context.context("Boot the vm, with '-smp X,maxcpus=Y' option", error_context.context("Boot the vm, with '-smp X,maxcpus=Y' option",
logging.info) logging.info)
...@@ -110,9 +108,6 @@ def run(test, params, env): ...@@ -110,9 +108,6 @@ def run(test, params, env):
if ntp_sync_cmd: if ntp_sync_cmd:
error_context.context("sync guest time via ntp server", logging.info) error_context.context("sync guest time via ntp server", logging.info)
session.cmd(ntp_sync_cmd) session.cmd(ntp_sync_cmd)
if ntp_service_stop_cmd:
logging.info("stop ntp service in guest")
session.cmd(ntp_service_stop_cmd)
error_context.context("Check if cpus in guest match qemu " error_context.context("Check if cpus in guest match qemu "
"cmd before hotplug", logging.info) "cmd before hotplug", logging.info)
......
...@@ -89,7 +89,7 @@ class TimedriftTest(object): ...@@ -89,7 +89,7 @@ class TimedriftTest(object):
timeout = int(self.params.get("execute_timeout", 360)) timeout = int(self.params.get("execute_timeout", 360))
ret = session.cmd_output(cmd, timeout=timeout) ret = session.cmd_output(cmd, timeout=timeout)
else: else:
ret = process.system_output(cmd, shell=True) ret = process.system_output(cmd, shell=True).decode()
target = session and "guest" or "host" target = session and "guest" or "host"
logging.debug("(%s) Execute command('%s')" % (target, cmd)) logging.debug("(%s) Execute command('%s')" % (target, cmd))
return ret return ret
...@@ -101,7 +101,7 @@ class TimedriftTest(object): ...@@ -101,7 +101,7 @@ class TimedriftTest(object):
calibrate guest time else calibrate host time; calibrate guest time else calibrate host time;
:param session: ShellSession object or None :param session: ShellSession object or None
:return: ntpdate command output; :return: sync command output;
:rtype: str :rtype: str
""" """
error_context.context("Sync host time from ntp server", logging.info) error_context.context("Sync host time from ntp server", logging.info)
...@@ -120,7 +120,7 @@ class TimedriftTest(object): ...@@ -120,7 +120,7 @@ class TimedriftTest(object):
guest_epoch_time_cmd, guest_epoch_time_cmd,
timeout=240) timeout=240)
host_timestr = process.system_output(host_epoch_time_cmd, host_timestr = process.system_output(host_epoch_time_cmd,
shell=True) shell=True).decode()
epoch_host, epoch_guest = list( epoch_host, epoch_guest = list(
map(lambda x: re.findall(regex, x)[0], map(lambda x: re.findall(regex, x)[0],
[host_timestr, guest_timestr])) [host_timestr, guest_timestr]))
......
...@@ -14,7 +14,7 @@ def run(test, params, env): ...@@ -14,7 +14,7 @@ def run(test, params, env):
Time clock offset check when guest crash/bsod test: Time clock offset check when guest crash/bsod test:
1) boot guest with '-rtc base=utc,clock=host,driftfix=slew'; 1) boot guest with '-rtc base=utc,clock=host,driftfix=slew';
2) sync host system time with "ntpdate clock.redhat.com"; 2) sync host system time with ntp server;
3) inject nmi to guest/ make linux kernel crash; 3) inject nmi to guest/ make linux kernel crash;
4) sleep long time, then reset vm via system_reset; 4) sleep long time, then reset vm via system_reset;
5) query clock offset from ntp server; 5) query clock offset from ntp server;
...@@ -23,7 +23,7 @@ def run(test, params, env): ...@@ -23,7 +23,7 @@ def run(test, params, env):
:param params: Dictionary with test parameters. :param params: Dictionary with test parameters.
:param env: Dictionary with the test environment. :param env: Dictionary with the test environment.
""" """
ntp_server = params.get("ntp_server", "clock.redhat.com") clock_sync_command = params["clock_sync_command"]
ntp_cmd = params["ntp_cmd"] ntp_cmd = params["ntp_cmd"]
ntp_query_cmd = params["ntp_query_cmd"] ntp_query_cmd = params["ntp_query_cmd"]
nmi_cmd = params.get("nmi_cmd", "inject-nmi") nmi_cmd = params.get("nmi_cmd", "inject-nmi")
...@@ -31,7 +31,7 @@ def run(test, params, env): ...@@ -31,7 +31,7 @@ def run(test, params, env):
deviation = float(params.get("deviation", 5)) deviation = float(params.get("deviation", 5))
error_context.context("sync host time with ntp server", logging.info) error_context.context("sync host time with ntp server", logging.info)
process.system("ntpdate %s" % ntp_server) process.system(clock_sync_command, shell=True)
error_context.context("start guest", logging.info) error_context.context("start guest", logging.info)
params["start_vm"] = "yes" params["start_vm"] = "yes"
......
import logging import logging
import time import time
from avocado.utils import path, process from avocado.utils import process
from virttest import utils_test from virttest import utils_test
from virttest import error_context from virttest import error_context
...@@ -86,8 +86,6 @@ def run(test, params, env): ...@@ -86,8 +86,6 @@ def run(test, params, env):
:param params: Dictionary with the test parameters :param params: Dictionary with the test parameters
:param env: Dictionary with test environmen. :param env: Dictionary with test environmen.
""" """
clock_server = params.get("clock_server", "clock.redhat.com")
ntputil_install = params.get("ntputil_install", "yum install -y ntpdate")
login_timeout = int(params.get("login_timeout", "240")) login_timeout = int(params.get("login_timeout", "240"))
guest_clock_source = params.get("guest_clock_source", "kvm-clock") guest_clock_source = params.get("guest_clock_source", "kvm-clock")
date_time_command = params.get("date_time_command", date_time_command = params.get("date_time_command",
...@@ -108,17 +106,11 @@ def run(test, params, env): ...@@ -108,17 +106,11 @@ def run(test, params, env):
vm_name = params.get("vms") vm_name = params.get("vms")
vm = env.get_vm(vm_name) vm = env.get_vm(vm_name)
error_context.context("Check if ntp utils are host in system.",
logging.info) error_context.context("Sync host machine with clock server %s", logging.info)
try: clock_sync_command = params["clock_sync_command"]
path.find_command("ntpdate") process.system(clock_sync_command, shell=True)
except path.CmdNotFoundError:
error_context.context("Install ntp utils `%s`." % (ntputil_install),
logging.info)
process.run(ntputil_install, shell=True)
error_context.context("Sync host machine with clock server %s" %
(clock_server), logging.info)
process.run("ntpdate %s" % (clock_server))
error_context.context("Check clock source on guest VM", logging.info) error_context.context("Check clock source on guest VM", logging.info)
session = vm.wait_for_serial_login(timeout=login_timeout) session = vm.wait_for_serial_login(timeout=login_timeout)
out = session.cmd_output("cat /sys/devices/system/clocksource/" out = session.cmd_output("cat /sys/devices/system/clocksource/"
......
import logging import logging
import time import time
from avocado.utils import path, process from avocado.utils import process
from virttest import utils_test from virttest import utils_test
from virttest import error_context from virttest import error_context
...@@ -100,8 +100,7 @@ def run(test, params, env): ...@@ -100,8 +100,7 @@ def run(test, params, env):
:param params: Dictionary with the test parameters :param params: Dictionary with the test parameters
:param env: Dictionary with test environmen. :param env: Dictionary with test environmen.
""" """
clock_server = params.get("clock_server", "clock.redhat.com") clock_sync_command = params["clock_sync_command"]
ntputil_install = params.get("ntputil_install", "yum install -y ntpdate")
login_timeout = int(params.get("login_timeout", "240")) login_timeout = int(params.get("login_timeout", "240"))
date_time_command = params.get("date_time_command", date_time_command = params.get("date_time_command",
r"date -u +'TIME: %a %m/%d/%Y %H:%M:%S.%N'") r"date -u +'TIME: %a %m/%d/%Y %H:%M:%S.%N'")
...@@ -117,17 +116,8 @@ def run(test, params, env): ...@@ -117,17 +116,8 @@ def run(test, params, env):
vm_name = params.get("vms") vm_name = params.get("vms")
vm = env.get_vm(vm_name) vm = env.get_vm(vm_name)
error_context.context("Check if ntp utils are host in system.", error_context.context("Sync host machine with clock server", logging.info)
logging.info) process.system(clock_sync_command, shell=True)
try:
path.find_command("ntpdate")
except path.CmdNotFoundError:
error_context.context("Install ntp utils `%s`." % (ntputil_install),
logging.info)
process.run(ntputil_install, shell=True)
error_context.context("Sync host machine with clock server %s" %
(clock_server), logging.info)
process.run("ntpdate %s" % (clock_server))
session = vm.wait_for_login(timeout=login_timeout) session = vm.wait_for_login(timeout=login_timeout)
error_context.context("Get clock from host and guest VM using `date`", error_context.context("Get clock from host and guest VM using `date`",
......
...@@ -47,7 +47,8 @@ def run(test, params, env): ...@@ -47,7 +47,8 @@ def run(test, params, env):
error_context.context("Sync the host system time with ntp server", error_context.context("Sync the host system time with ntp server",
logging.info) logging.info)
process.system("ntpdate clock.redhat.com") clock_sync_command = params["clock_sync_command"]
process.system(clock_sync_command, shell=True)
timerdevice_host_load_cmd = params.get("timerdevice_host_load_cmd") timerdevice_host_load_cmd = params.get("timerdevice_host_load_cmd")
if timerdevice_host_load_cmd: if timerdevice_host_load_cmd:
......
...@@ -11,18 +11,18 @@ from virttest import error_context ...@@ -11,18 +11,18 @@ from virttest import error_context
@error_context.context_aware @error_context.context_aware
def run(test, params, env): def run(test, params, env):
""" """
Timer device check clock frequency offset using NTP on CPU starved guest: Timer device check clock frequency offset using chrony on CPU starved guest:
1) Check for an appropriate clocksource on host. 1) Check for an appropriate clocksource on host.
2) Boot the guest. 2) Boot the guest.
3) Copy time-warp-test.c to guest. 3) Copy time-warp-test.c to guest.
4) Compile the time-warp-test.c. 4) Compile the time-warp-test.c.
5) Stop ntpd and apply load on guest. 5) Stop chronyd and apply load on guest.
6) Pin every vcpu to a physical cpu. 6) Pin every vcpu to a physical cpu.
7) Verify each vcpu is pinned on host. 7) Verify each vcpu is pinned on host.
8) Run time-warp-test on guest. 8) Run time-warp-test on guest.
9) Start ntpd on guest. 9) Start chronyd on guest.
10) Check the drift in /var/lib/ntp/drift file on guest after hours 10) Check the drift in /var/lib/chrony/drift file on guest after hours
of running. of running.
:param test: QEMU test object. :param test: QEMU test object.
...@@ -31,7 +31,7 @@ def run(test, params, env): ...@@ -31,7 +31,7 @@ def run(test, params, env):
""" """
def _drift_file_exist(): def _drift_file_exist():
try: try:
session.cmd("test -f /var/lib/ntp/drift") session.cmd("test -f /var/lib/chrony/drift")
return True return True
except Exception: except Exception:
return False return False
...@@ -62,8 +62,8 @@ def run(test, params, env): ...@@ -62,8 +62,8 @@ def run(test, params, env):
cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt" cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt"
sess_guest_load.cmd(cmd) sess_guest_load.cmd(cmd)
error_context.context("Stop ntpd and apply load on guest", logging.info) error_context.context("Stop chronyd and apply load on guest", logging.info)
sess_guest_load.cmd("yum install -y ntp; service ntpd stop") sess_guest_load.cmd("systemctl stop chronyd")
load_cmd = "for ((I=0; I<`grep 'processor id' /proc/cpuinfo| wc -l`; I++));" load_cmd = "for ((I=0; I<`grep 'processor id' /proc/cpuinfo| wc -l`; I++));"
load_cmd += " do taskset $(( 1 << $I )) /bin/bash -c 'for ((;;)); do X=1; done &';" load_cmd += " do taskset $(( 1 << $I )) /bin/bash -c 'for ((;;)); do X=1; done &';"
load_cmd += " done" load_cmd += " done"
...@@ -86,8 +86,8 @@ def run(test, params, env): ...@@ -86,8 +86,8 @@ def run(test, params, env):
cmd = "/tmp/time-warp-test > /dev/null &" cmd = "/tmp/time-warp-test > /dev/null &"
session.sendline(cmd) session.sendline(cmd)
error_context.context("Start ntpd on guest", logging.info) error_context.context("Start chronyd on guest", logging.info)
cmd = "service ntpd start; sleep 1; echo" cmd = "systemctl start chronyd; sleep 1; echo"
session.cmd(cmd) session.cmd(cmd)
error_context.context("Check if the drift file exists on guest", error_context.context("Check if the drift file exists on guest",
...@@ -97,10 +97,10 @@ def run(test, params, env): ...@@ -97,10 +97,10 @@ def run(test, params, env):
utils_misc.wait_for(_drift_file_exist, test_run_timeout, step=5) utils_misc.wait_for(_drift_file_exist, test_run_timeout, step=5)
except aexpect.ShellCmdError as detail: except aexpect.ShellCmdError as detail:
test.error("Failed to wait for the creation of" test.error("Failed to wait for the creation of"
" /var/lib/ntp/drift file. Detail: '%s'" % detail) " /var/lib/chronyd/drift file. Detail: '%s'" % detail)
error_context.context("Verify the drift file content on guest", error_context.context("Verify the drift file content on guest",
logging.info) logging.info)
output = session.cmd("cat /var/lib/ntp/drift") output = session.cmd("cat /var/lib/chrony/drift").strip().split()[0]
if int(abs(float(output))) > 20: if int(abs(float(output))) > 20:
test.fail("Failed to check the ntp drift. Output: '%s'" % output) test.fail("Failed to check the chrony drift. Output: '%s'" % output)
...@@ -99,11 +99,6 @@ def run(test, params, env): ...@@ -99,11 +99,6 @@ def run(test, params, env):
vm.verify_alive() vm.verify_alive()
session = vm.wait_for_login(timeout=timeout) session = vm.wait_for_login(timeout=timeout)
error_context.context("Stop auto sync service in guest", logging.info)
cmd = "(service chronyd status | grep 'Loaded: loaded')"
cmd += " && service chronyd stop"
session.cmd_status_output(cmd)
error_context.context("Sync time from guest to ntpserver", logging.info) error_context.context("Sync time from guest to ntpserver", logging.info)
session.cmd(ntp_sync_cmd, timeout=timeout) session.cmd(ntp_sync_cmd, timeout=timeout)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册