aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests/create/12_create_concurrent_stress_pos.py
blob: 5235491d885583a6811f5e9f3e920d9a17c85011 (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
#!/usr/bin/python

# Copyright (C) International Business Machines Corp., 2005
# Authors: Dan Smith <danms@us.ibm.com>

from XmTestLib import *

import time

DOMS=5
MEM=minSafeMem()
DUR=60

domains = []

free_mem = int(getInfo("free_memory"))
NUM_DOMS = int(free_mem / MEM)

if NUM_DOMS < DOMS:
    SKIP("Need %i MB of RAM to start %i@%iMB domains! (%i MB avail)" %
         (DOMS * MEM, DOMS, MEM, free_mem))

for i in range(0,DOMS):
    dom = XmTestDomain(extraConfig={"memory" : MEM})

    try:
        cons = dom.start()
    except DomainError, e:
        if verbose:
            print str(e)
        FAIL("Failed to start %s" % dom.getName())

    if verbose:
        print "[%i/%i] Started %s" % (i, DOMS, dom.getName())

    domains.append([dom, cons])

# Started DOMS domains, now we put them to work

for d, c in domains:
    if verbose:
        print "Starting task on %s" % d.getName()
    c.sendInput("gzip -c </dev/zero >/dev/null &\n")

if verbose:
    print "Waiting %i seconds..." % DUR

time.sleep(DUR)

for d, c in domains:

    if verbose:
        print "Testing domain %s..." % d.getName()
    
    run = c.runCmd("ls")

    if run["return"] != 0:
        FAIL("Domain %s didn't survive!" % d.getName())