diff --git a/qemu/tests/cfg/cpu_add.cfg b/qemu/tests/cfg/cpu_add.cfg index 0bf4b9696f8ecdc30be13c3ff9a487119f813d4e..8eb12b439aa44460a29d746de89f7d7d70310a1b 100644 --- a/qemu/tests/cfg/cpu_add.cfg +++ b/qemu/tests/cfg/cpu_add.cfg @@ -114,11 +114,9 @@ online = 1 offline = 1 vcpu_num_rechek = no - ntp_server = "clock.redhat.com" - pre_command = "ntpdate ${ntp_server}" - ntp_sync_cmd = "ntpdate ${ntp_server}" - ntp_query_cmd = "ntpdate -q ${ntp_server}" - ntp_service_stop_cmd = "service chronyd stop || service ntpdate stop" + ntp_sync_cmd = "(systemctl stop chronyd || service ntpdate stop)" + ntp_sync_cmd += " && chronyd -q 'server clock.redhat.com iburst'" + ntp_query_cmd = "chronyd -Q 'server clock.redhat.com iburst'" variants: - after_10mins: # seconds switch vcpus between online and offline diff --git a/qemu/tests/cfg/timedrift_adjust_time.cfg b/qemu/tests/cfg/timedrift_adjust_time.cfg index 9b6879176f74e43ffad5bd41cdc7df080a638378..3a69b62bd0517007b367cc941edf11672e4830e0 100644 --- a/qemu/tests/cfg/timedrift_adjust_time.cfg +++ b/qemu/tests/cfg/timedrift_adjust_time.cfg @@ -8,9 +8,9 @@ kill_vm = yes requries_root = yes image_snapshot = yes - pre_command = "service chronyd stop || service ntpdate stop" - post_command = "service chronyd restart || service ntpdate restart" - sync_host_time_cmd = 'ntpdate clock.redhat.com; hwclock -w' + pre_command = "systemctl stop chronyd || service ntpdate stop" + post_command = "systemctl restart chronyd || service ntpdate restart" + 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 += 'echo "datetime: $datetime epoch: $epoch"' time_difference = 0 diff --git a/qemu/tests/cfg/timedrift_check_clock_offset.cfg b/qemu/tests/cfg/timedrift_check_clock_offset.cfg index 3395edede7f46dacf640ab5f5063a582aa303fd1..fefa8f45a678ac7452142a3b154b8a39f318ecd2 100644 --- a/qemu/tests/cfg/timedrift_check_clock_offset.cfg +++ b/qemu/tests/cfg/timedrift_check_clock_offset.cfg @@ -18,6 +18,8 @@ type = timedrift_check_when_crash start_vm = no 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 variants: - bsod: @@ -32,5 +34,6 @@ # else guest will reboot immedicately that is unexpected in this test; 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" - ntp_cmd = "ntpdate ${ntp_server}" - ntp_query_cmd = "ntpdate -q ${ntp_server}" + ntp_cmd = "(systemctl stop chronyd || service ntpdate stop)" + ntp_cmd += " && chronyd -q 'server clock.redhat.com iburst'" + ntp_query_cmd = "chronyd -Q 'server clock.redhat.com iburst'" diff --git a/qemu/tests/cfg/timedrift_no_net.cfg b/qemu/tests/cfg/timedrift_no_net.cfg index 4fb13afcfc9289e74683704e8313856ea091586b..e1c8eb91b128551bab43d7d3f4c3d1d8495552c0 100644 --- a/qemu/tests/cfg/timedrift_no_net.cfg +++ b/qemu/tests/cfg/timedrift_no_net.cfg @@ -3,6 +3,8 @@ nettype = none login_timeout = 240 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: type = timedrift_no_net diff --git a/qemu/tests/cfg/timerdevice.cfg b/qemu/tests/cfg/timerdevice.cfg index 0ece11839aa86abc1b9f3d0d08990beb3061551a..5ef7d1b8c7a109b4be56d5f5221dc7486ac69640 100644 --- a/qemu/tests/cfg/timerdevice.cfg +++ b/qemu/tests/cfg/timerdevice.cfg @@ -4,7 +4,7 @@ host_cpu_cnt_cmd = "cat /proc/cpuinfo | grep "physical id" | wc -l" variants: - tscwrite: - only Fedora.19 RHEL.7 + no RHEL.6 type = timerdevice_tscwrite 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" @@ -19,7 +19,7 @@ ntp_sync_cmd = "(systemctl stop chronyd || service ntpdate stop)" ntp_sync_cmd += " && chronyd -q 'server clock.redhat.com iburst'" - clock_drift_with_ntp: - only Fedora.19 RHEL.7 + no RHEL.6 type = timerdevice_clock_drift_with_ntp test_run_timeout = 7200 - change_guest_clksource: @@ -34,6 +34,8 @@ i386, x86_64: rtc_drift = slew timerdevice_drift_threshold = 3 + clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)" + clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'" variants: - clock_host: rtc_clock = host @@ -51,7 +53,7 @@ only Windows timerdevice_clksource = "" - clksource_kvm-clock: - only Fedora.19 RHEL + only RHEL timerdevice_clksource = "kvm-clock" - clksource_tsc: # Fedora guest can't bootup without '-kvmclock' option. @@ -78,7 +80,7 @@ - reboot_after_sleep: timerdevice_sleep_time = 3600 - tscsync: - only Fedora.19 RHEL.7 + no RHEL.6 variants: - change_host_clksource: type = timerdevice_tscsync_change_host_clksource diff --git a/qemu/tests/cpu_add.py b/qemu/tests/cpu_add.py index 7a59df2244cbbdf7d75d5a6b956d0b1579985e21..8ae9c0fe8e2ef619f929414777f7644dac1cf1e9 100644 --- a/qemu/tests/cpu_add.py +++ b/qemu/tests/cpu_add.py @@ -17,14 +17,13 @@ def run(test, params, env): 2) After logged into the vm, check CPUs number 3) Stop the guest if config 'stop_before_hotplug' 4) sync guest clock via ntp server if config ntp_sync_cmd - 5) stop ntp service in guest if config ntp_service_stop_cmd - 6) Do cpu hotplug - 7) Resume the guest if config 'stop_before_hotplug' - 8) Recheck guest get hot-pluged CPUs - 9) Do cpu online/offline in guest and check clock + 5) Do cpu hotplug + 6) Resume the guest if config 'stop_before_hotplug' + 7) Recheck guest get hot-pluged CPUs + 8) Do cpu online/offline in guest and check clock offset via ntp server if config online/offline_cpus - 10) 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' + 9) Run sub test after CPU Hotplug if run_sub_test is 'yes' + 10) Recheck guest cpus after sub test if vcpu_num_rechek is 'yes' :param test: QEMU test object. :param params: Dictionary with test parameters. @@ -96,7 +95,6 @@ def run(test, params, env): acceptable_offset = float(params.get("acceptable_offset", 5)) ntp_query_cmd = params.get("ntp_query_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", logging.info) @@ -110,9 +108,6 @@ def run(test, params, env): if ntp_sync_cmd: error_context.context("sync guest time via ntp server", logging.info) 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 " "cmd before hotplug", logging.info) diff --git a/qemu/tests/timedrift_adjust_time.py b/qemu/tests/timedrift_adjust_time.py index 94ed09074bc457596077bf5631392b4ab808b0c5..518dd768953f0082ed7fe7cb2470abd8fd60a53b 100644 --- a/qemu/tests/timedrift_adjust_time.py +++ b/qemu/tests/timedrift_adjust_time.py @@ -89,7 +89,7 @@ class TimedriftTest(object): timeout = int(self.params.get("execute_timeout", 360)) ret = session.cmd_output(cmd, timeout=timeout) else: - ret = process.system_output(cmd, shell=True) + ret = process.system_output(cmd, shell=True).decode() target = session and "guest" or "host" logging.debug("(%s) Execute command('%s')" % (target, cmd)) return ret @@ -101,7 +101,7 @@ class TimedriftTest(object): calibrate guest time else calibrate host time; :param session: ShellSession object or None - :return: ntpdate command output; + :return: sync command output; :rtype: str """ error_context.context("Sync host time from ntp server", logging.info) @@ -120,7 +120,7 @@ class TimedriftTest(object): guest_epoch_time_cmd, timeout=240) host_timestr = process.system_output(host_epoch_time_cmd, - shell=True) + shell=True).decode() epoch_host, epoch_guest = list( map(lambda x: re.findall(regex, x)[0], [host_timestr, guest_timestr])) diff --git a/qemu/tests/timedrift_check_when_crash.py b/qemu/tests/timedrift_check_when_crash.py index 18f69e6b909870d289f3c44b6c5761ddf4de8294..ac52ca22260a2f9c8e5716c73448ae7224c20655 100644 --- a/qemu/tests/timedrift_check_when_crash.py +++ b/qemu/tests/timedrift_check_when_crash.py @@ -14,7 +14,7 @@ def run(test, params, env): Time clock offset check when guest crash/bsod test: 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; 4) sleep long time, then reset vm via system_reset; 5) query clock offset from ntp server; @@ -23,7 +23,7 @@ def run(test, params, env): :param params: Dictionary with test parameters. :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_query_cmd = params["ntp_query_cmd"] nmi_cmd = params.get("nmi_cmd", "inject-nmi") @@ -31,7 +31,7 @@ def run(test, params, env): deviation = float(params.get("deviation", 5)) 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) params["start_vm"] = "yes" diff --git a/qemu/tests/timedrift_no_net.py b/qemu/tests/timedrift_no_net.py index 744904bd418ef42678122aea9f87676ff623c047..f2e444d4500c106b891b4426ebe9b090d9186ddf 100644 --- a/qemu/tests/timedrift_no_net.py +++ b/qemu/tests/timedrift_no_net.py @@ -1,7 +1,7 @@ import logging import time -from avocado.utils import path, process +from avocado.utils import process from virttest import utils_test from virttest import error_context @@ -86,8 +86,6 @@ def run(test, params, env): :param params: Dictionary with the test parameters :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")) guest_clock_source = params.get("guest_clock_source", "kvm-clock") date_time_command = params.get("date_time_command", @@ -108,17 +106,11 @@ def run(test, params, env): vm_name = params.get("vms") vm = env.get_vm(vm_name) - error_context.context("Check if ntp utils are host in system.", - logging.info) - 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)) + + error_context.context("Sync host machine with clock server %s", logging.info) + clock_sync_command = params["clock_sync_command"] + process.system(clock_sync_command, shell=True) + error_context.context("Check clock source on guest VM", logging.info) session = vm.wait_for_serial_login(timeout=login_timeout) out = session.cmd_output("cat /sys/devices/system/clocksource/" diff --git a/qemu/tests/timedrift_no_net_win.py b/qemu/tests/timedrift_no_net_win.py index 3f0962b4ff06c5c6759aa812d280df7312aeff7a..5349efa5d8d7da6e63fac09de5d77e1e29349c93 100644 --- a/qemu/tests/timedrift_no_net_win.py +++ b/qemu/tests/timedrift_no_net_win.py @@ -1,7 +1,7 @@ import logging import time -from avocado.utils import path, process +from avocado.utils import process from virttest import utils_test from virttest import error_context @@ -100,8 +100,7 @@ def run(test, params, env): :param params: Dictionary with the test parameters :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") + clock_sync_command = params["clock_sync_command"] login_timeout = int(params.get("login_timeout", "240")) date_time_command = params.get("date_time_command", r"date -u +'TIME: %a %m/%d/%Y %H:%M:%S.%N'") @@ -117,17 +116,8 @@ def run(test, params, env): vm_name = params.get("vms") vm = env.get_vm(vm_name) - error_context.context("Check if ntp utils are host in system.", - logging.info) - 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)) + error_context.context("Sync host machine with clock server", logging.info) + process.system(clock_sync_command, shell=True) session = vm.wait_for_login(timeout=login_timeout) error_context.context("Get clock from host and guest VM using `date`", diff --git a/qemu/tests/timerdevice_boot.py b/qemu/tests/timerdevice_boot.py index 68114374b02e642329dbae429e4a80d881dca81a..90e2ce9f9fe00e532306c1de1a5a76ccb3432e35 100644 --- a/qemu/tests/timerdevice_boot.py +++ b/qemu/tests/timerdevice_boot.py @@ -47,7 +47,8 @@ def run(test, params, env): error_context.context("Sync the host system time with ntp server", 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") if timerdevice_host_load_cmd: diff --git a/qemu/tests/timerdevice_clock_drift_with_ntp.py b/qemu/tests/timerdevice_clock_drift_with_ntp.py index e06be92963b653ef371b16557441d17687816615..4ce2cbf446a7df1688dd56aa59e351d8f1dc3ed1 100644 --- a/qemu/tests/timerdevice_clock_drift_with_ntp.py +++ b/qemu/tests/timerdevice_clock_drift_with_ntp.py @@ -11,18 +11,18 @@ from virttest import error_context @error_context.context_aware 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. 2) Boot the guest. 3) Copy time-warp-test.c to guest. 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. 7) Verify each vcpu is pinned on host. 8) Run time-warp-test on guest. - 9) Start ntpd on guest. - 10) Check the drift in /var/lib/ntp/drift file on guest after hours + 9) Start chronyd on guest. + 10) Check the drift in /var/lib/chrony/drift file on guest after hours of running. :param test: QEMU test object. @@ -31,7 +31,7 @@ def run(test, params, env): """ def _drift_file_exist(): try: - session.cmd("test -f /var/lib/ntp/drift") + session.cmd("test -f /var/lib/chrony/drift") return True except Exception: return False @@ -62,8 +62,8 @@ def run(test, params, env): cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt" sess_guest_load.cmd(cmd) - error_context.context("Stop ntpd and apply load on guest", logging.info) - sess_guest_load.cmd("yum install -y ntp; service ntpd stop") + error_context.context("Stop chronyd and apply load on guest", logging.info) + sess_guest_load.cmd("systemctl stop chronyd") 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 += " done" @@ -86,8 +86,8 @@ def run(test, params, env): cmd = "/tmp/time-warp-test > /dev/null &" session.sendline(cmd) - error_context.context("Start ntpd on guest", logging.info) - cmd = "service ntpd start; sleep 1; echo" + error_context.context("Start chronyd on guest", logging.info) + cmd = "systemctl start chronyd; sleep 1; echo" session.cmd(cmd) error_context.context("Check if the drift file exists on guest", @@ -97,10 +97,10 @@ def run(test, params, env): utils_misc.wait_for(_drift_file_exist, test_run_timeout, step=5) except aexpect.ShellCmdError as detail: 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", 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: - test.fail("Failed to check the ntp drift. Output: '%s'" % output) + test.fail("Failed to check the chrony drift. Output: '%s'" % output) diff --git a/qemu/tests/timerdevice_clock_drift_with_sleep.py b/qemu/tests/timerdevice_clock_drift_with_sleep.py index 8e0ba8d135c8c0030f545d8db4e7e0c20f83d954..98c6b50ccdf27668d47677e1f9cd8c00f33f02eb 100644 --- a/qemu/tests/timerdevice_clock_drift_with_sleep.py +++ b/qemu/tests/timerdevice_clock_drift_with_sleep.py @@ -99,11 +99,6 @@ def run(test, params, env): vm.verify_alive() 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) session.cmd(ntp_sync_cmd, timeout=timeout)