aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests/cpupool/04_cpupool_migrate.py
blob: 2eeacd41835afc6cfc1c9b7cc3b2969f43d2a65e (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
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python

import sys
import re
import time

from XmTestLib import *
from pools import *



#
# Check requirements of test case
# - min 2 free cpus (not assigned to a pool)
#
if int(getInfo("free_cpus")) < 2:
    SKIP("Need at least 2 free cpus")



#
# Create 2 pools with one cpu per pool.
#
createStdPool({'name' : 'Pool-1'})
createStdPool({'name' : 'Pool-2'})



#
# Create a domain with vcpus=1 in Pool-0.
# Migrate it to one of the created pools afterwards to the other pool
#
name = "TestDomPool-1"
domain = XmTestDomain(extraConfig={'pool' : 'Pool-0'}, name=name)
try:
    domain.start(noConsole=True)
except DomainError, ex:
    FAIL(str(e))
if not domInPool(name, 'Pool-0'):
    FAIL("missing '%s' in Pool-0" % name)

if not migrateToPool(name, 'Pool-1'):
    FAIL("missing '%s' in Pool-1" % name)
if not migrateToPool(name, 'Pool-2'):
    FAIL("missing '%s' in Pool-2" % name)



#
# Create a domain in Pool-0.
# Migrate it to one of the created pools afterwards to the other pool
#
name = "TestDomPool-2"
domain = XmTestDomain(extraConfig={'pool' : 'Pool-0'}, name=name)
try:
    domain.start(noConsole=True)
except DomainError, ex:
    FAIL(str(e))
if not domInPool(name, 'Pool-0'):
    FAIL("missing '%s' in Pool-0" % name)

if not migrateToPool(name, 'Pool-1'):
    FAIL("missing '%s' in Pool-1" % name)
if not migrateToPool(name, 'Pool-2'):
    FAIL("missing '%s' in Pool-2" % name)



#
# Migrate other domains between pools
#
for cnt in range(10):
    for pool in ['Pool-0', 'Pool-1', 'Pool-2']:
        for domain in getRunningDomains():
            if domain != 'Domain-0':
                if not migrateToPool(domain, pool):
                    FAIL("missing '%s' in %s" % (domain, pool))


#
# Cleanup
#
cleanupPoolsDomains()