9
9
import logging
10
10
import time
11
11
12
- from autotest . client import utils
13
- from autotest . client . shared import error
14
- from autotest . client . shared .service import SpecificServiceManager
12
+ from avocado . utils import process
13
+ from avocado . core import exceptions
14
+ from avocado . utils .service import SpecificServiceManager
15
15
from virttest import remote
16
+ from virttest import error_context
16
17
17
18
18
- # error .context_aware decorator initializes context, which provides additional
19
+ # error_context .context_aware decorator initializes context, which provides additional
19
20
# information on exceptions.
20
- @error .context_aware
21
+ @error_context .context_aware
21
22
def run (test , params , env ):
22
23
"""
23
24
Logs guest's hostname.
@@ -33,22 +34,23 @@ def run(test, params, env):
33
34
:param env: Dictionary with test environment.
34
35
"""
35
36
if params .get ('test_on_guest' ) == "yes" :
36
- # error .context() is common method to log test steps used to verify
37
+ # error_context .context() is common method to log test steps used to verify
37
38
# what exactly was tested.
38
- error .context ("Using guest." , logging .info )
39
+ error_context .context ("Using guest." , logging .info )
39
40
vm = env .get_vm (params ["main_vm" ])
40
41
session = vm .wait_for_login ()
41
42
# RemoteRunner is object, which simulates the utils.run() behavior
42
43
# on remote consoles
43
44
runner = remote .RemoteRunner (session = session ).run
44
45
else :
45
- error .context ("Using host" , logging .info )
46
- runner = utils .run
46
+ error_context .context ("Using host" , logging .info )
47
+ runner = process .run
47
48
48
- error .context ("Initialize service manager" , logging .info )
49
+ error_context .context ("Initialize service manager" , logging .info )
49
50
service = SpecificServiceManager (params ["test_service" ], runner )
50
51
51
- error .context ("Testing service %s" % params ["test_service" ], logging .info )
52
+ error_context .context ("Testing service %s" %
53
+ params ["test_service" ], logging .info )
52
54
original_status = service .status ()
53
55
logging .info ("Original status=%s" , original_status )
54
56
@@ -58,17 +60,17 @@ def run(test, params, env):
58
60
if service .status () is not False :
59
61
logging .error ("Fail to stop service" )
60
62
service .start ()
61
- raise error .TestFail ("Fail to stop service" )
63
+ raise exceptions .TestFail ("Fail to stop service" )
62
64
service .start ()
63
65
else :
64
66
service .start ()
65
67
time .sleep (5 )
66
68
if service .status () is not True :
67
69
logging .error ("Fail to start service" )
68
70
service .stop ()
69
- raise error .TestFail ("Fail to start service" )
71
+ raise exceptions .TestFail ("Fail to start service" )
70
72
service .start ()
71
73
time .sleep (5 )
72
74
if not service .status () is original_status :
73
- raise error .TestFail ("Fail to restore original status of the %s "
74
- "service" % params ["test_service" ])
75
+ raise exceptions .TestFail ("Fail to restore original status of the %s "
76
+ "service" % params ["test_service" ])
0 commit comments