]> git.proxmox.com Git - mirror_ovs.git/blame - utilities/ovs-test.in
rhel: Add option to enable AF_XDP on rpm package.
[mirror_ovs.git] / utilities / ovs-test.in
CommitLineData
1ca0323e 1#! @PYTHON3@
0be6140a
AA
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"""
16ovs test utility that allows to do tests between remote hosts
17"""
18
8d25d9a2 19import fcntl
0be6140a 20import math
8d25d9a2
AA
21import os
22import select
23import signal
24import socket
25import subprocess
26import sys
27import time
28import xmlrpclib
29
30import argparse
31import twisted
32
33import ovstest.args as args
34import ovstest.rpcserver as rpcserver
2d8bdd8f
AA
35import ovstest.tests as tests
36import ovstest.util as util
8d25d9a2
AA
37
38DEFAULT_TEST_BRIDGE = "ovstestbr0"
39DEFAULT_TEST_PORT = "ovstestport0"
40DEFAULT_TEST_TUN = "ovstestport1"
41
42
0be6140a
AA
43def collect_information(node):
44 """Print information about hosts that will do testing"""
45 print "Node %s:%u " % (node[0], node[1])
2d8bdd8f 46 server = util.rpc_client(node[0], node[1])
8d25d9a2
AA
47 interface_name = server.get_interface(node[0])
48 phys_iface = None
49 uname = server.uname()
0be6140a
AA
50 mtu = 1500
51
8d25d9a2 52 if not interface_name:
0be6140a 53 print ("Could not find interface that has %s IP address."
8d25d9a2 54 "Make sure that you specified correct Outer IP." % (node[0]))
0be6140a 55 else:
8d25d9a2
AA
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],
0be6140a 66 mtu)
8d25d9a2
AA
67 if not driver:
68 print "Unable to get driver information from ethtool."
0be6140a 69 else:
8d25d9a2 70 print "On this host %s has %s." % (phys_iface, driver)
0be6140a 71
8d25d9a2 72 if not uname:
0be6140a
AA
73 print "Unable to retrieve kernel information. Is this Linux?"
74 else:
75 print "Running kernel %s." % uname
76 print "\n"
8d25d9a2 77
0be6140a
AA
78 return mtu
79
80
0be6140a 81if __name__ == '__main__':
8d25d9a2 82 local_server = None
0be6140a
AA
83 try:
84 ovs_args = args.ovs_initialize_args()
85
8d25d9a2
AA
86 if ovs_args.port is not None: # Start in pure server mode
87 rpcserver.start_rpc_server(ovs_args.port)
0be6140a 88
8d25d9a2 89 elif ovs_args.servers is not None: # Run in client mode
0be6140a
AA
90 node1 = ovs_args.servers[0]
91 node2 = ovs_args.servers[1]
0be6140a 92
8d25d9a2
AA
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":
2d8bdd8f 97 local_server = util.start_local_server(node1[1])
8d25d9a2
AA
98 # We must determine the IP address that local ovs-test server
99 # will use:
2d8bdd8f 100 me = util.rpc_client(node1[0], node1[1])
8d25d9a2
AA
101 my_ip = me.get_my_address_from(node2[0], node2[1])
102 node1 = (my_ip, node1[1], node1[2], node1[3])
103
0be6140a 104 mtu_node2 = collect_information(node2)
8d25d9a2
AA
105 mtu_node1 = collect_information(node1)
106
107 bandwidth = ovs_args.targetBandwidth
108 interval = ovs_args.testInterval
2d8bdd8f 109 ps = util.get_datagram_sizes(mtu_node1, mtu_node2)
8d25d9a2
AA
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"
2d8bdd8f 117 tests.do_direct_tests(node2, node1, bandwidth, interval, ps)
8d25d9a2
AA
118
119 if vlan_tag is not None:
120 print "Performing VLAN tests"
2d8bdd8f
AA
121 tests.do_vlan_tests(node2, node1, bandwidth, interval, ps,
122 vlan_tag)
8d25d9a2
AA
123
124 for tmode in tunnel_modes:
125 print "Performing", tmode, "tests"
2d8bdd8f
AA
126 tests.do_l3_tests(node2, node1, bandwidth, interval, ps,
127 tmode)
0be6140a 128
0be6140a
AA
129 except KeyboardInterrupt:
130 pass
8d25d9a2
AA
131 except xmlrpclib.Fault:
132 print "Couldn't establish XMLRPC control channel"
0be6140a
AA
133 except socket.error:
134 print "Couldn't establish XMLRPC control channel"
8d25d9a2
AA
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()