aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests/cpupool/01_cpupool_basic_pos.py
blob: 66d1bf76cc487404eb2cb882042440b45c5f8ac8 (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python

import sys
import re
import time

from XmTestLib import *


#
# Check output of xm info. It must include field 'free_cpus'
# The value must be between 0 - nr_cpus
#
free_cpus = getInfo("free_cpus")
if free_cpus == "":
    FAIL("Missing 'free_cpus' entry in xm info output")
if int(free_cpus) not in range(int(getInfo("nr_cpus")) + 1):
    FAIL("Wrong value of 'free_cpus' (%s)" % int(free_cpus))


#
# Check output of xm list -l. It must contain the key 'pool_name'
# If XM_USES_API is set, output must also contain 'cpu_pool'.
#
status, output = traceCommand("xm list -l Domain-0")
if status != 0 or "Traceback" in output:
    raise XmError("xm failed", trace=output, status=status)
if not re.search("pool_name Pool-0", output):
    FAIL("Missing or wrong attribute 'pool_name' in output of 'xm list -l'")
if os.getenv("XM_USES_API"):
    if not re.search("cpu_pool (.+)", output):
        FAIL("Missing or wrong attribute 'cpu_pool' in output of 'xm list -l'")

#
# Test pool selection option of xm list.
#
status, output = traceCommand("xm list --pool=Pool-0")
if status != 0 or "Traceback" in output:
    raise XmError("xm failed", trace=output, status=status)
if not re.search("Domain-0 +0 +", output):
    FAIL("Missing 'Domain-0' in Pool-0")

status, output = traceCommand("xm list --pool=Dummy-Pool")
if status != 0 or "Traceback" in output:
    raise XmError("xm failed", trace=output, status=status)
if len(output.splitlines()) != 1:
    FAIL("Wrong pool selection; output must be empty")


#
# Create a Domain without pool specification.
# Default pool is Pool-0
#
name = "TestDomPool-1"
domain = XmTestDomain(name=name)
try:
    domain.start(noConsole=True)
except DomainError, ex:
    FAIL(str(e))

if not isDomainRunning(name):
    FAIL("Couldn't start domain without pool specification")

status, output = traceCommand("xm list -l %s" % name)
if status != 0 or "Traceback" in output:
    raise XmError("xm failed", trace=output, status=status)
if not re.search("pool_name Pool-0", output):
    FAIL("Missing or wrong attribute 'pool_name' in output of 'xm list -l %s'" % name)

destroyAllDomUs()