Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: client/tests/kvm/tests/vmstop.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 import logging, time, os
2 from autotest_lib.client.common_lib import error
3 from autotest_lib.client.bin import utils
4 import kvm_utils
5
6
7 def run_vmstop(test, params, env):
8 """
9 KVM guest stop test:
10 1) Log into a guest
11 2) Copy a file into guest
12 3) Stop guest
13 4) Check the status through monitor
14 5) Check the session
15 6) Migrat the vm to a file twice and compare them.
16
17 @param test: kvm test object
18 @param params: Dictionary with the test parameters
19 @param env: Dictionary with test environment.
20 """
21 vm = env.get_vm(params["main_vm"])
22 vm.verify_alive()
23 timeout = float(params.get("login_timeout", 240))
24 session = vm.wait_for_login(timeout=timeout)
25
26 save_path = params.get("save_path", "/tmp")
27 clean_save = params.get("clean_save") == "yes"
28 save1 = os.path.join(save_path, "save1")
29 save2 = os.path.join(save_path, "save2")
30
31 guest_path = params.get("guest_path", "/tmp")
32 file_size = params.get("file_size", "1000")
33
34 try:
35 utils.run("dd if=/dev/zero of=/tmp/file bs=1M count=%s" % file_size)
36 # Transfer file from host to guest, we didn't expect the finish of
37 # transfer, we just let it to be a kind of stress in guest.
38 bg = kvm_utils.Thread(vm.copy_files_to, ("/tmp/file", guest_path),
39 dict(verbose=True, timeout=60))
40 logging.info("Start the background transfer")
41 bg.start()
42
43 try:
44 # wait for the transfer start
45 time.sleep(5)
46 logging.info("Stop the VM")
47 vm.monitor.cmd("stop")
48
49 # check with monitor
50 logging.info("Check the status through monitor")
51 if "paused" not in vm.monitor.info("status"):
52 raise error.TestFail("Guest did not pause after sending stop")
53
54 # check through session
55 logging.info("Check the session")
56 if session.is_responsive():
57 raise error.TestFail("Session still alive after sending stop")
58
59 # Check with the migration file
60 logging.info("Save and check the state files")
61 for p in [save1, save2]:
62 vm.save_to_file(p)
63 time.sleep(1)
64 if not os.path.isfile(p):
65 raise error.TestFail("VM failed to save state file %s" % p)
66
67 # Fail if we see deltas
68 md5_save1 = utils.hash_file(save1)
69 md5_save2 = utils.hash_file(save2)
70 if md5_save1 != md5_save2:
71 raise error.TestFail("The produced state files differ")
72 finally:
73 bg.join(suppress_exception=True)
74
75 finally:
76 session.close()
77 if clean_save:
78 logging.debug("Clean the state files")
79 if os.path.isfile(save1):
80 os.remove(save1)
81 if os.path.isfile(save2):
82 os.remove(save2)
83 vm.monitor.cmd("cont")
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698