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