提交 9a9d4a2d 编写于 作者: L Lucas Meneghel Rodrigues

Merge pull request #1350 from clebergnu/autotest_regression

Autotest regression test
......@@ -35,21 +35,24 @@ def run(test, params, env):
autotest_install_timeout = int(
params.get('autotest_install_timeout', 1800))
unittests_run_timeout = int(params.get('unittests_run_timeout', 1800))
unittests_args = params.get('unittests_args', '')
pylint_run_timeout = int(params.get('pylint_run_timeout', 1800))
vm_names = params["vms"].split()
has_client_vm = len(vm_names) > 1
server_name = vm_names[0]
client_name = vm_names[1]
vm_server = env.get_vm(server_name)
vm_server.verify_alive()
vm_client = env.get_vm(client_name)
vm_client.verify_alive()
timeout = float(params.get("login_timeout", 240))
session_server = vm_server.wait_for_login(timeout=timeout)
session_client = vm_client.wait_for_login(timeout=timeout)
client_ip = vm_client.get_address()
server_ip = vm_server.get_address()
if has_client_vm:
client_name = vm_names[1]
vm_client = env.get_vm(client_name)
vm_client.verify_alive()
session_client = vm_client.wait_for_login(timeout=timeout)
client_ip = vm_client.get_address()
step1 = "autotest-server-install"
try:
installer_file = "install-autotest-server.sh"
......@@ -104,7 +107,7 @@ def run(test, params, env):
step2 = "unittests"
try:
session_server.cmd("cd /usr/local/autotest")
session_server.cmd("utils/unittest_suite.py --full",
session_server.cmd("utils/unittest_suite.py %s" % unittests_args,
timeout=unittests_run_timeout)
except aexpect.ShellCmdError, e:
for line in e.output.splitlines():
......@@ -132,127 +135,129 @@ def run(test, params, env):
logging.error(line)
step_failures.append(step4)
step5 = "server_run"
try:
session_client.cmd("iptables -F")
session_server.cmd("cd /usr/local/autotest")
session_server.cmd("server/autotest-remote -m %s --ssh-user root "
"--ssh-pass %s "
"-c client/tests/sleeptest/control" %
(client_ip, password),
timeout=pylint_run_timeout)
session_server.cmd("rm -rf results-*")
except aexpect.ShellCmdError, e:
for line in e.output.splitlines():
logging.error(line)
step_failures.append(step5)
step6 = "registering_client_cli"
try:
label_name = "label-%s" % utils_misc.generate_random_id()
create_label_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"label create -t %s -w %s" %
(label_name, server_ip))
session_server.cmd(create_label_cmd)
list_labels_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"label list -a -w %s" % server_ip)
list_labels_output = session_server.cmd(list_labels_cmd)
for line in list_labels_output.splitlines():
logging.debug(line)
if not label_name in list_labels_output:
raise ValueError("No label %s in the output of %s" %
(label_name, list_labels_cmd))
create_host_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"host create -t %s %s -w %s" %
(label_name, client_ip, server_ip))
session_server.cmd(create_host_cmd)
list_hosts_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"host list -w %s" % server_ip)
list_hosts_output = session_server.cmd(list_hosts_cmd)
for line in list_hosts_output.splitlines():
logging.debug(line)
if not client_ip in list_hosts_output:
raise ValueError("No client %s in the output of %s" %
(client_ip, create_label_cmd))
if not label_name in list_hosts_output:
raise ValueError("No label %s in the output of %s" %
(label_name, create_label_cmd))
except (aexpect.ShellCmdError, ValueError), e:
if isinstance(e, aexpect.ShellCmdError):
if has_client_vm:
step5 = "server_run"
try:
session_client.cmd("iptables -F")
session_server.cmd("cd /usr/local/autotest")
session_server.cmd("server/autotest-remote -m %s --ssh-user root "
"--ssh-pass %s "
"-c client/tests/sleeptest/control" %
(client_ip, password),
timeout=pylint_run_timeout)
session_server.cmd("rm -rf results-*")
except aexpect.ShellCmdError, e:
for line in e.output.splitlines():
logging.error(line)
elif isinstance(e, ValueError):
logging.error(e)
step_failures.append(step6)
step7 = "running_job_cli"
try:
session_client.cmd("iptables -F")
job_name = "Sleeptest %s" % utils_misc.generate_random_id()
def job_is_status(status):
list_jobs_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"job list -a -w %s" % server_ip)
list_jobs_output = session_server.cmd(list_jobs_cmd)
if job_name in list_jobs_output:
if status in list_jobs_output:
return True
elif "Aborted" in list_jobs_output:
raise ValueError("Job is in aborted state")
elif "Failed" in list_jobs_output:
raise ValueError("Job is in failed state")
step_failures.append(step5)
step6 = "registering_client_cli"
try:
label_name = "label-%s" % utils_misc.generate_random_id()
create_label_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"label create -t %s -w %s" %
(label_name, server_ip))
session_server.cmd(create_label_cmd)
list_labels_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"label list -a -w %s" % server_ip)
list_labels_output = session_server.cmd(list_labels_cmd)
for line in list_labels_output.splitlines():
logging.debug(line)
if not label_name in list_labels_output:
raise ValueError("No label %s in the output of %s" %
(label_name, list_labels_cmd))
create_host_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"host create -t %s %s -w %s" %
(label_name, client_ip, server_ip))
session_server.cmd(create_host_cmd)
list_hosts_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"host list -w %s" % server_ip)
list_hosts_output = session_server.cmd(list_hosts_cmd)
for line in list_hosts_output.splitlines():
logging.debug(line)
if not client_ip in list_hosts_output:
raise ValueError("No client %s in the output of %s" %
(client_ip, create_label_cmd))
if not label_name in list_hosts_output:
raise ValueError("No label %s in the output of %s" %
(label_name, create_label_cmd))
except (aexpect.ShellCmdError, ValueError), e:
if isinstance(e, aexpect.ShellCmdError):
for line in e.output.splitlines():
logging.error(line)
elif isinstance(e, ValueError):
logging.error(e)
step_failures.append(step6)
step7 = "running_job_cli"
try:
session_client.cmd("iptables -F")
job_name = "Sleeptest %s" % utils_misc.generate_random_id()
def job_is_status(status):
list_jobs_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"job list -a -w %s" % server_ip)
list_jobs_output = session_server.cmd(list_jobs_cmd)
if job_name in list_jobs_output:
if status in list_jobs_output:
return True
elif "Aborted" in list_jobs_output:
raise ValueError("Job is in aborted state")
elif "Failed" in list_jobs_output:
raise ValueError("Job is in failed state")
else:
return False
else:
return False
else:
raise ValueError("Job %s does not show in the "
"output of %s" % (job_name, list_jobs_cmd))
def job_is_completed():
return job_is_status("Completed")
def job_is_running():
return job_is_status("Running")
job_create_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"job create --test sleeptest -m %s '%s' -w %s" %
(client_ip, job_name, server_ip))
session_server.cmd(job_create_cmd)
if not utils_misc.wait_for(job_is_running, 300, 0, 10,
"Waiting for job to start running"):
raise ValueError("Job did not start running")
# Wait for the session to become unresponsive
if not utils_misc.wait_for(
lambda: not session_client.is_responsive(),
timeout=300):
raise ValueError("Client machine did not reboot")
# Establish a new client session
session_client = vm_client.wait_for_login(timeout=timeout)
# Wait for the job to complete
if not utils_misc.wait_for(job_is_completed, 300, 0, 10,
"Waiting for job to complete"):
raise ValueError("Job did not complete")
# Copy logs back so we can analyze them
vm_server.copy_files_from(
guest_path="/usr/local/autotest/results/*",
host_path=test.resultsdir)
except (aexpect.ShellCmdError, ValueError), e:
if isinstance(e, aexpect.ShellCmdError):
for line in e.output.splitlines():
logging.error(line)
elif isinstance(e, ValueError):
logging.error(e)
step_failures.append(step7)
raise ValueError("Job %s does not show in the "
"output of %s" % (job_name, list_jobs_cmd))
def job_is_completed():
return job_is_status("Completed")
def job_is_running():
return job_is_status("Running")
job_create_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
"job create --test sleeptest -m %s '%s' -w %s" %
(client_ip, job_name, server_ip))
session_server.cmd(job_create_cmd)
if not utils_misc.wait_for(job_is_running, 300, 0, 10,
"Waiting for job to start running"):
raise ValueError("Job did not start running")
# Wait for the session to become unresponsive
if not utils_misc.wait_for(
lambda: not session_client.is_responsive(),
timeout=300):
raise ValueError("Client machine did not reboot")
# Establish a new client session
session_client = vm_client.wait_for_login(timeout=timeout)
# Wait for the job to complete
if not utils_misc.wait_for(job_is_completed, 300, 0, 10,
"Waiting for job to complete"):
raise ValueError("Job did not complete")
# Copy logs back so we can analyze them
vm_server.copy_files_from(
guest_path="/usr/local/autotest/results/*",
host_path=test.resultsdir)
except (aexpect.ShellCmdError, ValueError), e:
if isinstance(e, aexpect.ShellCmdError):
for line in e.output.splitlines():
logging.error(line)
elif isinstance(e, ValueError):
logging.error(e)
step_failures.append(step7)
def report_version():
if top_commit is not None:
......
......@@ -6,8 +6,8 @@
kill_vm_on_error = yes
login_timeout = 240
vms = "autotest_server_vm autotest_client_vm"
autotest_install_timeout = 1800
autotest_install_timeout = 7200
autotest_repo = git://github.com/autotest/autotest.git
autotest_branch = master
autotest_commit =
unittests_args = --full
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册