Chetan Gaonker | cb122cc | 2016-05-10 10:58:34 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2016-present Ciena Corporation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 17 | from argparse import ArgumentParser |
| 18 | import os,sys,time |
Chetan Gaonker | 4d842ad | 2016-04-26 10:04:24 -0700 | [diff] [blame] | 19 | utils_dir = os.path.join( os.path.dirname(os.path.realpath(__file__)), '../utils') |
Chetan Gaonker | 7142a34 | 2016-04-07 14:53:12 -0700 | [diff] [blame] | 20 | sys.path.append(utils_dir) |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 21 | from OnosCtrl import OnosCtrl |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 22 | from OltConfig import OltConfig |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 23 | from CordContainer import * |
| 24 | from CordTestServer import cord_test_server_start, cord_test_server_stop |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 25 | |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 26 | class CordTester(Container): |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 27 | sandbox = '/root/test' |
Chetan Gaonker | 7142a34 | 2016-04-07 14:53:12 -0700 | [diff] [blame] | 28 | sandbox_setup = '/root/test/src/test/setup' |
Chetan Gaonker | 4d842ad | 2016-04-26 10:04:24 -0700 | [diff] [blame] | 29 | tester_base = os.path.dirname(os.path.realpath(__file__)) |
| 30 | tester_paths = os.path.realpath(__file__).split(os.path.sep) |
Chetan Gaonker | 7142a34 | 2016-04-07 14:53:12 -0700 | [diff] [blame] | 31 | tester_path_index = tester_paths.index('cord-tester') |
| 32 | sandbox_host = os.path.sep.join(tester_paths[:tester_path_index+1]) |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 33 | |
| 34 | host_guest_map = ( (sandbox_host, sandbox), |
Chetan Gaonker | 85b7bd5 | 2016-04-20 10:29:12 -0700 | [diff] [blame] | 35 | ('/lib/modules', '/lib/modules'), |
| 36 | ('/var/run/docker.sock', '/var/run/docker.sock') |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 37 | ) |
| 38 | basename = 'cord-tester' |
| 39 | |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 40 | def __init__(self, ctlr_ip = None, image = 'cord-test/nose', tag = 'latest', |
Chetan Gaonker | 85b7bd5 | 2016-04-20 10:29:12 -0700 | [diff] [blame] | 41 | env = None, rm = False, update = False): |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 42 | self.ctlr_ip = ctlr_ip |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 43 | self.rm = rm |
| 44 | self.name = self.get_name() |
| 45 | super(CordTester, self).__init__(self.name, image = image, tag = tag) |
| 46 | host_config = self.create_host_config(host_guest_map = self.host_guest_map, privileged = True) |
| 47 | volumes = [] |
Chetan Gaonker | b84835f | 2016-04-19 15:12:10 -0700 | [diff] [blame] | 48 | for _, g in self.host_guest_map: |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 49 | volumes.append(g) |
Chetan Gaonker | 85b7bd5 | 2016-04-20 10:29:12 -0700 | [diff] [blame] | 50 | if update is True or not self.img_exists(): |
Chetan Gaonker | b84835f | 2016-04-19 15:12:10 -0700 | [diff] [blame] | 51 | self.build_image(image) |
Chetan Gaonker | 7142a34 | 2016-04-07 14:53:12 -0700 | [diff] [blame] | 52 | ##Remove test container if any |
| 53 | self.remove_container(self.name, force=True) |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 54 | if env is not None and env.has_key('OLT_CONFIG'): |
| 55 | self.olt = True |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 56 | olt_conf_file = os.path.join(self.tester_base, 'olt_config.json') |
| 57 | olt_config = OltConfig(olt_conf_file) |
| 58 | self.port_map = olt_config.olt_port_map() |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 59 | else: |
| 60 | self.olt = False |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 61 | self.port_map = None |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 62 | print('Starting test container %s, image %s, tag %s' %(self.name, self.image, self.tag)) |
| 63 | self.start(rm = False, volumes = volumes, environment = env, |
| 64 | host_config = host_config, tty = True) |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 65 | |
| 66 | def execute_switch(self, cmd, shell = False): |
| 67 | if self.olt: |
| 68 | return os.system(cmd) |
| 69 | return self.execute(cmd, shell = shell) |
| 70 | |
| 71 | def start_switch(self, bridge = 'ovsbr0', boot_delay = 2): |
| 72 | """Start OVS""" |
| 73 | ##Determine if OVS has to be started locally or not |
| 74 | s_file,s_sandbox = ('of-bridge-local.sh',self.tester_base) if self.olt else ('of-bridge.sh',self.sandbox_setup) |
| 75 | ovs_cmd = os.path.join(s_sandbox, '{0}'.format(s_file)) + ' {0}'.format(bridge) |
| 76 | if self.olt: |
| 77 | ovs_cmd += ' {0}'.format(self.ctlr_ip) |
| 78 | print('Starting OVS on the host') |
| 79 | else: |
| 80 | print('Starting OVS on test container %s' %self.name) |
| 81 | self.execute_switch(ovs_cmd) |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 82 | status = 1 |
| 83 | ## Wait for the LLDP flows to be added to the switch |
| 84 | tries = 0 |
Chetan Gaonker | a52016e | 2016-05-05 15:19:59 -0700 | [diff] [blame] | 85 | while status != 0 and tries < 200: |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 86 | cmd = 'sudo ovs-ofctl dump-flows {0} | grep \"type=0x8942\"'.format(bridge) |
| 87 | status = self.execute_switch(cmd, shell = True) |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 88 | tries += 1 |
| 89 | if tries % 10 == 0: |
| 90 | print('Waiting for test switch to be connected to ONOS controller ...') |
| 91 | |
| 92 | if status != 0: |
| 93 | print('Test Switch not connected to ONOS container.' |
| 94 | 'Please remove ONOS container and restart the test') |
| 95 | if self.rm: |
| 96 | self.kill() |
| 97 | sys.exit(1) |
| 98 | |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 99 | if boot_delay: |
| 100 | time.sleep(boot_delay) |
| 101 | |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 102 | def setup_intfs(self): |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 103 | if not self.olt: |
| 104 | return 0 |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 105 | tester_intf_subnet = '192.168.100' |
| 106 | res = 0 |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 107 | port_num = 0 |
| 108 | host_intf = self.port_map['host'] |
| 109 | start_vlan = self.port_map['start_vlan'] |
| 110 | for port in self.port_map['ports']: |
| 111 | guest_if = port |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 112 | local_if = guest_if |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 113 | guest_ip = '{0}.{1}/24'.format(tester_intf_subnet, str(port_num+1)) |
| 114 | ##Use pipeworks to configure container interfaces on host/bridge interfaces |
| 115 | pipework_cmd = 'pipework {0} -i {1} -l {2} {3} {4}'.format(host_intf, guest_if, local_if, self.name, guest_ip) |
| 116 | if start_vlan != 0: |
| 117 | pipework_cmd += ' @{}'.format(str(start_vlan + port_num)) |
| 118 | |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 119 | res += os.system(pipework_cmd) |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 120 | port_num += 1 |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 121 | |
| 122 | return res |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 123 | |
| 124 | @classmethod |
| 125 | def get_name(cls): |
| 126 | cnt_name = '/{0}'.format(cls.basename) |
| 127 | cnt_name_len = len(cnt_name) |
| 128 | names = list(flatten(n['Names'] for n in cls.dckr.containers(all=True))) |
| 129 | test_names = filter(lambda n: n.startswith(cnt_name), names) |
| 130 | last_cnt_number = 0 |
| 131 | if test_names: |
| 132 | last_cnt_name = reduce(lambda n1, n2: n1 if int(n1[cnt_name_len:]) > \ |
| 133 | int(n2[cnt_name_len:]) else n2, |
| 134 | test_names) |
| 135 | last_cnt_number = int(last_cnt_name[cnt_name_len:]) |
| 136 | test_cnt_name = cls.basename + str(last_cnt_number+1) |
| 137 | return test_cnt_name |
| 138 | |
| 139 | @classmethod |
| 140 | def build_image(cls, image): |
| 141 | print('Building test container docker image %s' %image) |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 142 | ovs_version = '2.5.0' |
| 143 | image_format = (ovs_version,)*4 |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 144 | dockerfile = ''' |
| 145 | FROM ubuntu:14.04 |
| 146 | MAINTAINER chetan@ciena.com |
| 147 | RUN apt-get update |
| 148 | RUN apt-get -y install git python python-pip python-setuptools python-scapy tcpdump doxygen doxypy wget |
| 149 | RUN easy_install nose |
| 150 | RUN apt-get -y install openvswitch-common openvswitch-switch |
| 151 | RUN mkdir -p /root/ovs |
| 152 | WORKDIR /root |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 153 | RUN wget http://openvswitch.org/releases/openvswitch-{}.tar.gz -O /root/ovs/openvswitch-{}.tar.gz && \ |
| 154 | (cd /root/ovs && tar zxpvf openvswitch-{}.tar.gz && \ |
| 155 | cd openvswitch-{} && \ |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 156 | ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-ssl && make && make install) |
| 157 | RUN service openvswitch-switch restart || /bin/true |
Chetan Gaonker | c170f3f | 2016-04-19 17:24:45 -0700 | [diff] [blame] | 158 | RUN apt-get -y install python-twisted python-sqlite sqlite3 python-pexpect telnet |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 159 | RUN pip install scapy-ssl_tls |
| 160 | RUN pip install -U scapy |
| 161 | RUN pip install monotonic |
Chetan Gaonker | 3ff8eae | 2016-04-12 14:50:26 -0700 | [diff] [blame] | 162 | RUN pip install configObj |
Chetan Gaonker | c170f3f | 2016-04-19 17:24:45 -0700 | [diff] [blame] | 163 | RUN pip install -U docker-py |
| 164 | RUN pip install -U pyyaml |
| 165 | RUN pip install -U nsenter |
| 166 | RUN pip install -U pyroute2 |
| 167 | RUN pip install -U netaddr |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 168 | RUN apt-get -y install arping |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 169 | RUN mv /usr/sbin/tcpdump /sbin/ |
| 170 | RUN ln -sf /sbin/tcpdump /usr/sbin/tcpdump |
| 171 | CMD ["/bin/bash"] |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 172 | '''.format(*image_format) |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 173 | super(CordTester, cls).build_image(dockerfile, image) |
| 174 | print('Done building docker image %s' %image) |
| 175 | |
| 176 | def run_tests(self, tests): |
| 177 | '''Run the list of tests''' |
| 178 | for t in tests: |
| 179 | test = t.split(':')[0] |
| 180 | if test == 'tls': |
| 181 | test_file = test + 'AuthTest.py' |
| 182 | else: |
| 183 | test_file = test + 'Test.py' |
| 184 | |
| 185 | if t.find(':') >= 0: |
| 186 | test_case = test_file + ':' + t.split(':')[1] |
| 187 | else: |
| 188 | test_case = test_file |
Chetan Gaonker | 7142a34 | 2016-04-07 14:53:12 -0700 | [diff] [blame] | 189 | cmd = 'nosetests -v {0}/src/test/{1}/{2}'.format(self.sandbox, test, test_case) |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 190 | status = self.execute(cmd, shell = True) |
| 191 | print('Test %s %s' %(test_case, 'Success' if status == 0 else 'Failure')) |
| 192 | print('Done running tests') |
| 193 | if self.rm: |
| 194 | print('Removing test container %s' %self.name) |
| 195 | self.kill(remove=True) |
| 196 | |
Chetan Gaonker | fb3cb5e | 2016-05-06 11:55:44 -0700 | [diff] [blame] | 197 | @classmethod |
| 198 | def list_tests(cls, tests): |
| 199 | print('Listing test cases') |
| 200 | for test in tests: |
| 201 | if test == 'tls': |
| 202 | test_file = test + 'AuthTest.py' |
| 203 | else: |
| 204 | test_file = test + 'Test.py' |
| 205 | cmd = 'nosetests -v --collect-only {0}/../{1}/{2}'.format(cls.tester_base, test, test_file) |
| 206 | os.system(cmd) |
| 207 | |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 208 | ##default onos/radius/test container images and names |
| 209 | onos_image_default='onosproject/onos:latest' |
| 210 | nose_image_default='cord-test/nose:latest' |
| 211 | test_type_default='dhcp' |
| 212 | onos_app_version = '1.0-SNAPSHOT' |
Chetan Gaonker | 4d842ad | 2016-04-26 10:04:24 -0700 | [diff] [blame] | 213 | cord_tester_base = os.path.dirname(os.path.realpath(__file__)) |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 214 | onos_app_file = os.path.abspath('{0}/../apps/ciena-cordigmp-'.format(cord_tester_base) + onos_app_version + '.oar') |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 215 | |
| 216 | def runTest(args): |
Chetan Gaonker | 823cdc5 | 2016-05-09 15:51:23 -0700 | [diff] [blame] | 217 | #Start the cord test tcp server |
| 218 | test_server = cord_test_server_start() |
Chetan Gaonker | fb3cb5e | 2016-05-06 11:55:44 -0700 | [diff] [blame] | 219 | tests = args.test_type.split('-') |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 220 | onos_cnt = {'tag':'latest'} |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 221 | nose_cnt = {'image': 'cord-test/nose','tag': 'latest'} |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 222 | radius_ip = None |
Chetan Gaonker | c170f3f | 2016-04-19 17:24:45 -0700 | [diff] [blame] | 223 | quagga_ip = None |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 224 | if args.cleanup: |
| 225 | cleanup_container = args.cleanup |
| 226 | if cleanup_container.find(':') < 0: |
| 227 | cleanup_container += ':latest' |
| 228 | print('Cleaning up containers %s' %cleanup_container) |
| 229 | Container.cleanup(cleanup_container) |
| 230 | sys.exit(0) |
| 231 | |
Chetan Gaonker | fb3cb5e | 2016-05-06 11:55:44 -0700 | [diff] [blame] | 232 | if args.list: |
| 233 | CordTester.list_tests(tests) |
| 234 | sys.exit(0) |
| 235 | |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 236 | #don't spawn onos if the user has specified external test controller with test interface config |
| 237 | if args.test_controller: |
| 238 | ips = args.test_controller.split('/') |
| 239 | onos_ip = ips[0] |
| 240 | if len(ips) > 1: |
| 241 | radius_ip = ips[1] |
| 242 | else: |
| 243 | radius_ip = None |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 244 | else: |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 245 | onos_cnt['image'] = args.onos.split(':')[0] |
| 246 | if args.onos.find(':') >= 0: |
| 247 | onos_cnt['tag'] = args.onos.split(':')[1] |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 248 | |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 249 | onos = Onos(image = onos_cnt['image'], tag = onos_cnt['tag'], boot_delay = 60) |
| 250 | onos_ip = onos.ip() |
| 251 | |
| 252 | ##Start Radius container if specified |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 253 | if args.radius == True: |
| 254 | radius = Radius() |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 255 | radius_ip = radius.ip() |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 256 | print('Radius server running with IP %s' %radius_ip) |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 257 | else: |
| 258 | radius_ip = None |
| 259 | |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 260 | print('Onos IP %s, Test type %s' %(onos_ip, args.test_type)) |
| 261 | print('Installing ONOS app %s' %onos_app_file) |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 262 | OnosCtrl.install_app(args.app, onos_ip = onos_ip) |
Chetan Gaonker | b84835f | 2016-04-19 15:12:10 -0700 | [diff] [blame] | 263 | |
| 264 | if args.quagga == True: |
| 265 | #Start quagga. Builds container if required |
| 266 | quagga = Quagga() |
Chetan Gaonker | c170f3f | 2016-04-19 17:24:45 -0700 | [diff] [blame] | 267 | quagga_ip = quagga.ip() |
Chetan Gaonker | b84835f | 2016-04-19 15:12:10 -0700 | [diff] [blame] | 268 | |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 269 | test_cnt_env = { 'ONOS_CONTROLLER_IP' : onos_ip, |
Chetan Gaonker | c170f3f | 2016-04-19 17:24:45 -0700 | [diff] [blame] | 270 | 'ONOS_AAA_IP' : radius_ip if radius_ip is not None else '', |
| 271 | 'QUAGGA_IP': quagga_ip if quagga_ip is not None else '', |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 272 | } |
| 273 | if args.olt: |
Chetan Gaonker | 7142a34 | 2016-04-07 14:53:12 -0700 | [diff] [blame] | 274 | olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json') |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 275 | test_cnt_env['OLT_CONFIG'] = olt_conf_test_loc |
| 276 | |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 277 | test_cnt = CordTester(ctlr_ip = onos_ip, image = nose_cnt['image'], tag = nose_cnt['tag'], |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 278 | env = test_cnt_env, |
Chetan Gaonker | 678743f | 2016-04-26 09:54:31 -0700 | [diff] [blame] | 279 | rm = False if args.keep else True, |
Chetan Gaonker | 85b7bd5 | 2016-04-20 10:29:12 -0700 | [diff] [blame] | 280 | update = args.update) |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 281 | if args.start_switch or not args.olt: |
| 282 | test_cnt.start_switch() |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 283 | test_cnt.setup_intfs() |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 284 | test_cnt.run_tests(tests) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 285 | cord_test_server_stop(test_server) |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 286 | |
| 287 | if __name__ == '__main__': |
Chetan Gaonker | 678743f | 2016-04-26 09:54:31 -0700 | [diff] [blame] | 288 | parser = ArgumentParser(description='Cord Tester') |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 289 | parser.add_argument('-t', '--test-type', default=test_type_default, type=str) |
| 290 | parser.add_argument('-o', '--onos', default=onos_image_default, type=str, help='ONOS container image') |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 291 | parser.add_argument('-r', '--radius',action='store_true', help='Start Radius service') |
Chetan Gaonker | b84835f | 2016-04-19 15:12:10 -0700 | [diff] [blame] | 292 | parser.add_argument('-q', '--quagga',action='store_true',help='Provision quagga container for vrouter') |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 293 | parser.add_argument('-a', '--app', default=onos_app_file, type=str, help='Cord ONOS app filename') |
Chetan Gaonker | fb3cb5e | 2016-05-06 11:55:44 -0700 | [diff] [blame] | 294 | parser.add_argument('-p', '--olt', action='store_true', help='Use OLT config') |
| 295 | parser.add_argument('-l', '--list', action='store_true', help='List test cases') |
Chetan Gaonker | 5209fe8 | 2016-04-19 10:09:53 -0700 | [diff] [blame] | 296 | parser.add_argument('-e', '--test-controller', default='', type=str, help='External test controller ip for Onos and/or radius server.' |
| 297 | 'Eg: 10.0.0.2/10.0.0.3 to specify ONOS and Radius ip to connect') |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 298 | parser.add_argument('-c', '--cleanup', default='', type=str, help='Cleanup test containers') |
Chetan Gaonker | 678743f | 2016-04-26 09:54:31 -0700 | [diff] [blame] | 299 | parser.add_argument('-k', '--keep', action='store_true', help='Keep test container after tests') |
| 300 | parser.add_argument('-s', '--start-switch', action='store_true', help='Start OVS when running under OLT config') |
Chetan Gaonker | 85b7bd5 | 2016-04-20 10:29:12 -0700 | [diff] [blame] | 301 | parser.add_argument('-u', '--update', action='store_true', help='Update test container image') |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 302 | parser.set_defaults(func=runTest) |
| 303 | args = parser.parse_args() |
| 304 | args.func(args) |