]> git.proxmox.com Git - mirror_ovs.git/blob - utilities/ovs-test.in
FAQ: Fix version number for 2.0.
[mirror_ovs.git] / utilities / ovs-test.in
1 #! @PYTHON@
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 """
16 ovs test utility that allows to do tests between remote hosts
17 """
18
19 import fcntl
20 import math
21 import os
22 import select
23 import signal
24 import socket
25 import subprocess
26 import sys
27 import time
28 import xmlrpclib
29
30 import argparse
31 import twisted
32
33 import ovstest.args as args
34 import ovstest.rpcserver as rpcserver
35 import ovstest.tests as tests
36 import ovstest.util as util
37
38 DEFAULT_TEST_BRIDGE = "ovstestbr0"
39 DEFAULT_TEST_PORT = "ovstestport0"
40 DEFAULT_TEST_TUN = "ovstestport1"
41
42
43 def collect_information(node):
44 """Print information about hosts that will do testing"""
45 print "Node %s:%u " % (node[0], node[1])
46 server = util.rpc_client(node[0], node[1])
47 interface_name = server.get_interface(node[0])
48 phys_iface = None
49 uname = server.uname()
50 mtu = 1500
51
52 if not interface_name:
53 print ("Could not find interface that has %s IP address."
54 "Make sure that you specified correct Outer IP." % (node[0]))
55 else:
56 if server.is_ovs_bridge(interface_name):
57 phys_iface = server.get_iface_from_bridge(interface_name)
58 else:
59 phys_iface = interface_name
60
61 if phys_iface:
62 driver = server.get_driver(phys_iface)
63 mtu = server.get_interface_mtu(phys_iface)
64
65 print "Will be using %s (%s) with MTU %u" % (phys_iface, node[0],
66 mtu)
67 if not driver:
68 print "Unable to get driver information from ethtool."
69 else:
70 print "On this host %s has %s." % (phys_iface, driver)
71
72 if not uname:
73 print "Unable to retrieve kernel information. Is this Linux?"
74 else:
75 print "Running kernel %s." % uname
76 print "\n"
77
78 return mtu
79
80
81 if __name__ == '__main__':
82 local_server = None
83 try:
84 ovs_args = args.ovs_initialize_args()
85
86 if ovs_args.port is not None: # Start in pure server mode
87 rpcserver.start_rpc_server(ovs_args.port)
88
89 elif ovs_args.servers is not None: # Run in client mode
90 node1 = ovs_args.servers[0]
91 node2 = ovs_args.servers[1]
92
93 # Verify whether client will need to spawn a local instance of
94 # ovs-test server by looking at the first OuterIP. if it is a
95 # 127.0.0.1 then spawn local ovs-test server.
96 if node1[0] == "127.0.0.1":
97 local_server = util.start_local_server(node1[1])
98 # We must determine the IP address that local ovs-test server
99 # will use:
100 me = util.rpc_client(node1[0], node1[1])
101 my_ip = me.get_my_address_from(node2[0], node2[1])
102 node1 = (my_ip, node1[1], node1[2], node1[3])
103
104 mtu_node2 = collect_information(node2)
105 mtu_node1 = collect_information(node1)
106
107 bandwidth = ovs_args.targetBandwidth
108 interval = ovs_args.testInterval
109 ps = util.get_datagram_sizes(mtu_node1, mtu_node2)
110
111 direct = ovs_args.direct
112 vlan_tag = ovs_args.vlanTag
113 tunnel_modes = ovs_args.tunnelModes
114
115 if direct is not None:
116 print "Performing direct tests"
117 tests.do_direct_tests(node2, node1, bandwidth, interval, ps)
118
119 if vlan_tag is not None:
120 print "Performing VLAN tests"
121 tests.do_vlan_tests(node2, node1, bandwidth, interval, ps,
122 vlan_tag)
123
124 for tmode in tunnel_modes:
125 print "Performing", tmode, "tests"
126 tests.do_l3_tests(node2, node1, bandwidth, interval, ps,
127 tmode)
128
129 except KeyboardInterrupt:
130 pass
131 except xmlrpclib.Fault:
132 print "Couldn't establish XMLRPC control channel"
133 except socket.error:
134 print "Couldn't establish XMLRPC control channel"
135 except xmlrpclib.ProtocolError:
136 print "XMLRPC control channel was abruptly terminated"
137 except twisted.internet.error.CannotListenError:
138 print "Couldn't start XMLRPC server on port %u" % ovs_args.port
139 finally:
140 if local_server is not None:
141 local_server.terminate()