direct-io.hg

changeset 14455:bea7ff5ebd60

Have xm-test wait for the network device to detach. This is an asynchronous
process, so xm-test needs to poll.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Mar 20 16:52:33 2007 +0000 (2007-03-20)
parents fc918d15c981
children a6d888593117
files tools/xm-test/tests/network-attach/network_utils.py
line diff
     1.1 --- a/tools/xm-test/tests/network-attach/network_utils.py	Tue Mar 20 15:15:37 2007 +0000
     1.2 +++ b/tools/xm-test/tests/network-attach/network_utils.py	Tue Mar 20 16:52:33 2007 +0000
     1.3 @@ -12,6 +12,18 @@ def count_eth(console):
     1.4          FAIL(str(e))
     1.5      return len(run['output'].splitlines())
     1.6  
     1.7 +def get_state(domain_name, number):
     1.8 +    s, o = traceCommand("xm network-list %s | awk '/^%d/ {print $5}'" %
     1.9 +                        (domain_name, number))
    1.10 +    print o
    1.11 +    
    1.12 +    if s != 0:
    1.13 +        FAIL("network-list failed")
    1.14 +    if o == "":
    1.15 +        return 0
    1.16 +    else:
    1.17 +        return int(o)
    1.18 +
    1.19  def network_attach(domain_name, console):
    1.20      eths_before = count_eth(console)
    1.21      status, output = traceCommand("xm network-attach %s" % domain_name)
    1.22 @@ -30,6 +42,13 @@ def network_detach(domain_name, console,
    1.23      if status != 0:
    1.24          return -1, "xm network-detach returned invalid %i != 0" % status
    1.25  
    1.26 +    for i in range(10):
    1.27 +        if get_state(domain_name, num) == 0:
    1.28 +            break
    1.29 +        time.sleep(1)
    1.30 +    else:
    1.31 +        FAIL("network-detach failed: device did not disappear")
    1.32 +
    1.33      eths_after = count_eth(console)
    1.34      if eths_after != (eths_before-1):
    1.35      	return -2, "Network device was not actually disconnected from domU"