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:
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 ovs test utility that allows to do tests between remote hosts
33 import ovstest.args as args
34 import ovstest.rpcserver as rpcserver
35 import ovstest.tests as tests
36 import ovstest.util as util
38 DEFAULT_TEST_BRIDGE = "ovstestbr0"
39 DEFAULT_TEST_PORT = "ovstestport0"
40 DEFAULT_TEST_TUN = "ovstestport1"
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])
49 uname = server.uname()
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]))
56 if server.is_ovs_bridge(interface_name):
57 phys_iface = server.get_iface_from_bridge(interface_name)
59 phys_iface = interface_name
62 driver = server.get_driver(phys_iface)
63 mtu = server.get_interface_mtu(phys_iface)
65 print "Will be using %s (%s) with MTU %u" % (phys_iface, node[0],
68 print "Unable to get driver information from ethtool."
70 print "On this host %s has %s." % (phys_iface, driver)
73 print "Unable to retrieve kernel information. Is this Linux?"
75 print "Running kernel %s." % uname
81 if __name__ == '__main__':
84 ovs_args = args.ovs_initialize_args()
86 if ovs_args.port is not None: # Start in pure server mode
87 rpcserver.start_rpc_server(ovs_args.port)
89 elif ovs_args.servers is not None: # Run in client mode
90 node1 = ovs_args.servers[0]
91 node2 = ovs_args.servers[1]
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
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])
104 mtu_node2 = collect_information(node2)
105 mtu_node1 = collect_information(node1)
107 bandwidth = ovs_args.targetBandwidth
108 interval = ovs_args.testInterval
109 ps = util.get_datagram_sizes(mtu_node1, mtu_node2)
111 direct = ovs_args.direct
112 vlan_tag = ovs_args.vlanTag
113 tunnel_modes = ovs_args.tunnelModes
115 if direct is not None:
116 print "Performing direct tests"
117 tests.do_direct_tests(node2, node1, bandwidth, interval, ps)
119 if vlan_tag is not None:
120 print "Performing VLAN tests"
121 tests.do_vlan_tests(node2, node1, bandwidth, interval, ps,
124 for tmode in tunnel_modes:
125 print "Performing", tmode, "tests"
126 tests.do_l3_tests(node2, node1, bandwidth, interval, ps,
129 except KeyboardInterrupt:
131 except xmlrpclib.Fault:
132 print "Couldn't establish XMLRPC control channel"
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
140 if local_server is not None:
141 local_server.terminate()