[34] | 1 | #!/usr/bin/python |
---|
| 2 | |
---|
| 3 | # Copyright (C) International Business Machines Corp., 2005 |
---|
| 4 | # Author: Paul Larson <pl@us.ibm.com> |
---|
| 5 | |
---|
| 6 | # Description: |
---|
| 7 | # Positive Tests: |
---|
| 8 | # Tests for xm unpause |
---|
| 9 | # 1) Create domain, verify it's up with console |
---|
| 10 | # 2) randomly pause and unpause the domain |
---|
| 11 | # 3) unpause it one last time |
---|
| 12 | # 4) verify it's still alive with console |
---|
| 13 | |
---|
| 14 | import time |
---|
| 15 | import commands |
---|
| 16 | from random import * |
---|
| 17 | |
---|
| 18 | from XmTestLib import * |
---|
| 19 | |
---|
| 20 | # Create a domain (default XmTestDomain, with our ramdisk) |
---|
| 21 | domain = XmTestDomain() |
---|
| 22 | |
---|
| 23 | # Start it |
---|
| 24 | try: |
---|
| 25 | console = domain.start() |
---|
| 26 | except DomainError, e: |
---|
| 27 | if verbose: |
---|
| 28 | print "Failed to create test domain because:" |
---|
| 29 | print e.extra |
---|
| 30 | FAIL(str(e)) |
---|
| 31 | |
---|
| 32 | try: |
---|
| 33 | # Make sure a command succeeds |
---|
| 34 | run = console.runCmd("ls") |
---|
| 35 | except ConsoleError, e: |
---|
| 36 | FAIL(str(e)) |
---|
| 37 | |
---|
| 38 | # Close the console |
---|
| 39 | domain.closeConsole() |
---|
| 40 | |
---|
| 41 | seed(time.time()) |
---|
| 42 | |
---|
| 43 | for i in range(100): |
---|
| 44 | pauseit = randint(0,1) |
---|
| 45 | if(pauseit): |
---|
| 46 | # Pause the domain |
---|
| 47 | status, output = traceCommand("xm pause %s" % domain.getName()) |
---|
| 48 | if status != 0: |
---|
| 49 | FAIL("xm pause returned invalid %i != 0", status) |
---|
| 50 | else: |
---|
| 51 | # Unpause the domain |
---|
| 52 | status, output = traceCommand("xm unpause %s" % domain.getName()) |
---|
| 53 | if status != 0: |
---|
| 54 | FAIL("xm unpause returned invalid %i != 0", status) |
---|
| 55 | |
---|
| 56 | # Make sure the domain is unpaused before we finish up |
---|
| 57 | status, output = traceCommand("xm unpause %s" % domain.getName()) |
---|
| 58 | if status != 0: |
---|
| 59 | FAIL("xm unpause returned invalid %i != 0", status) |
---|
| 60 | |
---|
| 61 | # Are we still alive after all that? |
---|
| 62 | try: |
---|
| 63 | console = domain.getConsole() |
---|
| 64 | run = console.runCmd("ls") |
---|
| 65 | except ConsoleError, e: |
---|
| 66 | FAIL(str(e)) |
---|
| 67 | |
---|
| 68 | # Close the console |
---|
| 69 | domain.closeConsole() |
---|
| 70 | |
---|
| 71 | if run["return"] != 0: |
---|
| 72 | FAIL("console failed to attach to supposedly unpaused domain") |
---|
| 73 | |
---|
| 74 | # Stop the domain (nice shutdown) |
---|
| 75 | domain.stop() |
---|
| 76 | |
---|