1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/usr/bin/python
"""Check the state file of a utah client run.
Returncode would be the same as would have been returned by the client itself
if there were no reboots involved:
PASS: All test cases were executed and passed
FAIL: All test cases were executed, but at least one of them failed
ERROR: At least one error was detected that prevented a test case from being
executed. Examples of situations that are considered an error are:
- Fetch command failure
- Setup command failure
UNKNOWN: Unable to retrieve state file to check if client finished properly.
"""
import sys
import yaml
from utah.client.common import (
DEFAULT_STATE_FILE,
ReturnCodes,
)
try:
with open(DEFAULT_STATE_FILE) as f:
state = yaml.load(f)
except IOError:
sys.exit(ReturnCodes.UNKNOWN)
if state['status'] == 'DONE':
if (state['errors'] > 0 or state['fetch_errors'] > 0):
sys.exit(ReturnCodes.ERROR)
if (state['failures'] > 0):
sys.exit(ReturnCodes.FAIL)
sys.exit(ReturnCodes.PASS)
else:
sys.exit(ReturnCodes.UNKNOWN)
|