提交 38c9d58e 编写于 作者: S Sitong Liu

timedrift: add case to check time offset after hotplugging vcpu

Signed-off-by: NSitong Liu <siliu@redhat.com>
上级 2934f8df
......@@ -37,3 +37,15 @@
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'"
- hotplug_vcpu:
type = timedrift_check_when_hotplug_vcpu
start_vm = yes
vcpu_sockets = 2
smp = 4
vcpus_maxcpus = 6
ntp_query_cmd = "chronyd -Q 'server clock.redhat.com iburst'"
clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)"
clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'"
query_internal = 600
query_times = 4
drift_threshold = 3
import re
import time
import logging
from avocado.utils import process
from virttest import error_context
@error_context.context_aware
def run(test, params, env):
"""
Check time offset after hotplug a vcpu.
1) sync host time with ntpserver
2) boot guest with '-rtc base=utc,clock=host,driftfix=slew'
3) stop auto sync service in guest (rhel7 only)
4) sync guest system time with ntpserver
5) hotplug a vcpu by qmp command
6) query guest time offset with ntpserver for several times
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
clock_sync_command = params["clock_sync_command"]
error_context.context("Sync host system time with ntpserver", logging.info)
process.system(clock_sync_command, shell=True)
vm = env.get_vm(params["main_vm"])
session = vm.wait_for_login()
ntp_query_cmd = params.get("ntp_query_cmd", "")
query_times = int(params.get("query_times", "4"))
query_internal = float(params.get("query_internal", "600"))
drift_threshold = float(params.get("drift_threshold", "3"))
error_context.context("Sync time from guest to ntpserver", logging.info)
session.cmd(clock_sync_command)
error_context.context("Hotplug a vcpu to guest", logging.info)
if int(params["smp"]) < int(params["vcpus_maxcpus"]):
vm.hotplug_vcpu()
time.sleep(1)
else:
test.error("Invalid operation, valid index range 0:%d, used range 0:%d"
% (int(params["vcpus_maxcpus"])-1, int(params["smp"]) - 1))
error_context.context("Check time offset via ntp server", logging.info)
for query in range(query_times):
output = session.cmd_output(ntp_query_cmd)
try:
offset = re.findall(r"([+-]*\d+\.\d+) seconds", output, re.M)[0]
except IndexError:
test.error("Failed to get time offset")
if float(offset) >= drift_threshold:
test.fail("Uacceptable offset '%s', " % offset +
"threshold '%s'" % drift_threshold)
time.sleep(query_internal)
session.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册