| 1 | #!/usr/bin/python |
|---|
| 2 | |
|---|
| 3 | # Copyright (C) International Business Machines Corp., 2006 |
|---|
| 4 | # Author: <dykman@us.ibm.com> |
|---|
| 5 | |
|---|
| 6 | # TCP tests on local interfaces. |
|---|
| 7 | # - creates a single guest domain |
|---|
| 8 | # - sets up a single NIC |
|---|
| 9 | # - conducts hping tcp tests to the local loopback and IP address |
|---|
| 10 | |
|---|
| 11 | # hping2 127.0.0.1 -c 1 -d $size |
|---|
| 12 | # hping2 $local_IP -c 1 -d $size |
|---|
| 13 | # where $size = 1, 48, 64, 512, 1440, 1448, 1500, 1505, |
|---|
| 14 | # 4096, 4192, 32767, 65507, 65508 |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | trysizes = [ 1, 48, 64, 512, 1440, 1448, 1500, 1505, 4096, 4192, |
|---|
| 18 | 32767, 65495 ] |
|---|
| 19 | |
|---|
| 20 | from XmTestLib import * |
|---|
| 21 | rc = 0 |
|---|
| 22 | |
|---|
| 23 | # Test creates 1 domain, which requires 2 ips: 1 for the domains and 1 for |
|---|
| 24 | # aliases on dom0 |
|---|
| 25 | if xmtest_netconf.canRunNetTest(2) == False: |
|---|
| 26 | SKIP("Don't have enough free configured IPs to run this test") |
|---|
| 27 | |
|---|
| 28 | # Fire up a guest domain w/1 nic |
|---|
| 29 | domain = XmTestDomain() |
|---|
| 30 | domain.newDevice(XenNetDevice, "eth0") |
|---|
| 31 | |
|---|
| 32 | try: |
|---|
| 33 | console = domain.start() |
|---|
| 34 | except DomainError, e: |
|---|
| 35 | if verbose: |
|---|
| 36 | print "Failed to create test domain because:" |
|---|
| 37 | print e.extra |
|---|
| 38 | FAIL(str(e)) |
|---|
| 39 | |
|---|
| 40 | try: |
|---|
| 41 | console.setHistorySaveCmds(value=True) |
|---|
| 42 | |
|---|
| 43 | # First do loopback |
|---|
| 44 | lofails="" |
|---|
| 45 | for size in trysizes: |
|---|
| 46 | out = console.runCmd("hping2 127.0.0.1 -E /dev/urandom -q -c 20 " |
|---|
| 47 | + "--fast -d " + str(size) + " -N " + str(size)) |
|---|
| 48 | if out["return"]: |
|---|
| 49 | lofails += " " + str(size) |
|---|
| 50 | |
|---|
| 51 | # Next comes eth0 |
|---|
| 52 | eth0fails="" |
|---|
| 53 | netdev = domain.getDevice("eth0") |
|---|
| 54 | ip = netdev.getNetDevIP() |
|---|
| 55 | for size in trysizes: |
|---|
| 56 | out = console.runCmd("hping2 " + ip + " -E /dev/urandom -q -c 20 " |
|---|
| 57 | + "--fast -d "+ str(size) + " -N " + str(size)) |
|---|
| 58 | if out["return"]: |
|---|
| 59 | eth0fails += " " + str(size) |
|---|
| 60 | except ConsoleError, e: |
|---|
| 61 | FAIL(str(e)) |
|---|
| 62 | except NetworkError, e: |
|---|
| 63 | FAIL(str(e)) |
|---|
| 64 | |
|---|
| 65 | domain.stop() |
|---|
| 66 | |
|---|
| 67 | # Tally up failures |
|---|
| 68 | failures="" |
|---|
| 69 | if len(lofails): |
|---|
| 70 | failures += "TCP hping2 over loopback failed for size" + lofails + ". " |
|---|
| 71 | if len(eth0fails): |
|---|
| 72 | failures += "TCP hping2 over eth0 failed for size" + eth0fails + "." |
|---|
| 73 | if len(failures): |
|---|
| 74 | FAIL(failures) |
|---|
| 75 | |
|---|