blob: a8ef4124c1fc2d28a0fdd3a7987618e2935e3a08 [file] [log] [blame]
Chetan Gaonkercb122cc2016-05-10 10:58:34 -07001#!/usr/bin/env python
Chetan Gaonkercfcce782016-05-10 10:10:42 -07002#
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 Gaonker93e302d2016-04-05 10:51:07 -070017from argparse import ArgumentParser
18import os,sys,time
Chetan Gaonker4d842ad2016-04-26 10:04:24 -070019utils_dir = os.path.join( os.path.dirname(os.path.realpath(__file__)), '../utils')
Chetan Gaonker7142a342016-04-07 14:53:12 -070020sys.path.append(utils_dir)
Chetan Gaonker93e302d2016-04-05 10:51:07 -070021from OnosCtrl import OnosCtrl
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070022from OltConfig import OltConfig
Chetan Gaonker3533faa2016-04-25 17:50:14 -070023from CordContainer import *
24from CordTestServer import cord_test_server_start, cord_test_server_stop
Chetan Gaonker93e302d2016-04-05 10:51:07 -070025
Chetan Gaonker93e302d2016-04-05 10:51:07 -070026class CordTester(Container):
Chetan Gaonker93e302d2016-04-05 10:51:07 -070027 sandbox = '/root/test'
Chetan Gaonker7142a342016-04-07 14:53:12 -070028 sandbox_setup = '/root/test/src/test/setup'
Chetan Gaonker4d842ad2016-04-26 10:04:24 -070029 tester_base = os.path.dirname(os.path.realpath(__file__))
30 tester_paths = os.path.realpath(__file__).split(os.path.sep)
A R Karthickb7e80902016-05-17 09:38:31 -070031 tester_path_index = tester_paths.index('src') - 1
Chetan Gaonker7142a342016-04-07 14:53:12 -070032 sandbox_host = os.path.sep.join(tester_paths[:tester_path_index+1])
Chetan Gaonker93e302d2016-04-05 10:51:07 -070033
34 host_guest_map = ( (sandbox_host, sandbox),
Chetan Gaonker85b7bd52016-04-20 10:29:12 -070035 ('/lib/modules', '/lib/modules'),
36 ('/var/run/docker.sock', '/var/run/docker.sock')
Chetan Gaonker93e302d2016-04-05 10:51:07 -070037 )
38 basename = 'cord-tester'
Chetan Gaonker503032a2016-05-12 12:06:29 -070039 IMAGE = 'cord-test/nose'
40 ALL_TESTS = ('tls', 'dhcp', 'igmp', 'subscriber', 'vrouter', 'flows')
Chetan Gaonker93e302d2016-04-05 10:51:07 -070041
Chetan Gaonker503032a2016-05-12 12:06:29 -070042 def __init__(self, ctlr_ip = None, image = IMAGE, tag = 'latest',
Chetan Gaonker85b7bd52016-04-20 10:29:12 -070043 env = None, rm = False, update = False):
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070044 self.ctlr_ip = ctlr_ip
Chetan Gaonker93e302d2016-04-05 10:51:07 -070045 self.rm = rm
46 self.name = self.get_name()
47 super(CordTester, self).__init__(self.name, image = image, tag = tag)
48 host_config = self.create_host_config(host_guest_map = self.host_guest_map, privileged = True)
49 volumes = []
Chetan Gaonkerb84835f2016-04-19 15:12:10 -070050 for _, g in self.host_guest_map:
Chetan Gaonker93e302d2016-04-05 10:51:07 -070051 volumes.append(g)
Chetan Gaonker85b7bd52016-04-20 10:29:12 -070052 if update is True or not self.img_exists():
Chetan Gaonkerb84835f2016-04-19 15:12:10 -070053 self.build_image(image)
Chetan Gaonker7142a342016-04-07 14:53:12 -070054 ##Remove test container if any
55 self.remove_container(self.name, force=True)
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070056 if env is not None and env.has_key('OLT_CONFIG'):
57 self.olt = True
Chetan Gaonker5209fe82016-04-19 10:09:53 -070058 olt_conf_file = os.path.join(self.tester_base, 'olt_config.json')
59 olt_config = OltConfig(olt_conf_file)
60 self.port_map = olt_config.olt_port_map()
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070061 else:
62 self.olt = False
Chetan Gaonker5209fe82016-04-19 10:09:53 -070063 self.port_map = None
Chetan Gaonker93e302d2016-04-05 10:51:07 -070064 print('Starting test container %s, image %s, tag %s' %(self.name, self.image, self.tag))
65 self.start(rm = False, volumes = volumes, environment = env,
66 host_config = host_config, tty = True)
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070067
68 def execute_switch(self, cmd, shell = False):
69 if self.olt:
70 return os.system(cmd)
71 return self.execute(cmd, shell = shell)
72
73 def start_switch(self, bridge = 'ovsbr0', boot_delay = 2):
74 """Start OVS"""
75 ##Determine if OVS has to be started locally or not
76 s_file,s_sandbox = ('of-bridge-local.sh',self.tester_base) if self.olt else ('of-bridge.sh',self.sandbox_setup)
77 ovs_cmd = os.path.join(s_sandbox, '{0}'.format(s_file)) + ' {0}'.format(bridge)
78 if self.olt:
79 ovs_cmd += ' {0}'.format(self.ctlr_ip)
80 print('Starting OVS on the host')
81 else:
82 print('Starting OVS on test container %s' %self.name)
83 self.execute_switch(ovs_cmd)
Chetan Gaonker93e302d2016-04-05 10:51:07 -070084 status = 1
85 ## Wait for the LLDP flows to be added to the switch
86 tries = 0
Chetan Gaonkera52016e2016-05-05 15:19:59 -070087 while status != 0 and tries < 200:
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070088 cmd = 'sudo ovs-ofctl dump-flows {0} | grep \"type=0x8942\"'.format(bridge)
89 status = self.execute_switch(cmd, shell = True)
Chetan Gaonker93e302d2016-04-05 10:51:07 -070090 tries += 1
91 if tries % 10 == 0:
92 print('Waiting for test switch to be connected to ONOS controller ...')
93
94 if status != 0:
95 print('Test Switch not connected to ONOS container.'
96 'Please remove ONOS container and restart the test')
97 if self.rm:
98 self.kill()
99 sys.exit(1)
100
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700101 if boot_delay:
102 time.sleep(boot_delay)
103
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700104 def setup_intfs(self):
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700105 if not self.olt:
106 return 0
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700107 tester_intf_subnet = '192.168.100'
108 res = 0
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700109 port_num = 0
110 host_intf = self.port_map['host']
111 start_vlan = self.port_map['start_vlan']
112 for port in self.port_map['ports']:
113 guest_if = port
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700114 local_if = guest_if
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700115 guest_ip = '{0}.{1}/24'.format(tester_intf_subnet, str(port_num+1))
116 ##Use pipeworks to configure container interfaces on host/bridge interfaces
117 pipework_cmd = 'pipework {0} -i {1} -l {2} {3} {4}'.format(host_intf, guest_if, local_if, self.name, guest_ip)
118 if start_vlan != 0:
119 pipework_cmd += ' @{}'.format(str(start_vlan + port_num))
120
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700121 res += os.system(pipework_cmd)
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700122 port_num += 1
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700123
124 return res
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700125
126 @classmethod
127 def get_name(cls):
128 cnt_name = '/{0}'.format(cls.basename)
129 cnt_name_len = len(cnt_name)
130 names = list(flatten(n['Names'] for n in cls.dckr.containers(all=True)))
131 test_names = filter(lambda n: n.startswith(cnt_name), names)
132 last_cnt_number = 0
133 if test_names:
134 last_cnt_name = reduce(lambda n1, n2: n1 if int(n1[cnt_name_len:]) > \
135 int(n2[cnt_name_len:]) else n2,
136 test_names)
137 last_cnt_number = int(last_cnt_name[cnt_name_len:])
138 test_cnt_name = cls.basename + str(last_cnt_number+1)
139 return test_cnt_name
140
141 @classmethod
142 def build_image(cls, image):
143 print('Building test container docker image %s' %image)
Chetan Gaonkerb6064fa2016-05-02 16:29:57 -0700144 ovs_version = '2.5.0'
145 image_format = (ovs_version,)*4
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700146 dockerfile = '''
147FROM ubuntu:14.04
148MAINTAINER chetan@ciena.com
149RUN apt-get update
150RUN apt-get -y install git python python-pip python-setuptools python-scapy tcpdump doxygen doxypy wget
151RUN easy_install nose
152RUN apt-get -y install openvswitch-common openvswitch-switch
153RUN mkdir -p /root/ovs
154WORKDIR /root
Chetan Gaonkerb6064fa2016-05-02 16:29:57 -0700155RUN wget http://openvswitch.org/releases/openvswitch-{}.tar.gz -O /root/ovs/openvswitch-{}.tar.gz && \
156(cd /root/ovs && tar zxpvf openvswitch-{}.tar.gz && \
157 cd openvswitch-{} && \
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700158 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-ssl && make && make install)
159RUN service openvswitch-switch restart || /bin/true
Chetan Gaonkerc170f3f2016-04-19 17:24:45 -0700160RUN apt-get -y install python-twisted python-sqlite sqlite3 python-pexpect telnet
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700161RUN pip install scapy-ssl_tls
162RUN pip install -U scapy
163RUN pip install monotonic
Chetan Gaonker3ff8eae2016-04-12 14:50:26 -0700164RUN pip install configObj
Chetan Gaonkerc170f3f2016-04-19 17:24:45 -0700165RUN pip install -U docker-py
166RUN pip install -U pyyaml
167RUN pip install -U nsenter
168RUN pip install -U pyroute2
169RUN pip install -U netaddr
Chetan Gaonker3533faa2016-04-25 17:50:14 -0700170RUN apt-get -y install arping
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700171RUN mv /usr/sbin/tcpdump /sbin/
172RUN ln -sf /sbin/tcpdump /usr/sbin/tcpdump
A R Karthickb7e80902016-05-17 09:38:31 -0700173RUN apt-get install -y git-core autoconf automake autotools-dev pkg-config \
174 make gcc g++ libtool libc6-dev cmake libpcap-dev libxerces-c2-dev \
175 unzip libpcre3-dev flex bison libboost-dev
176WORKDIR /root
177RUN wget -nc http://de.archive.ubuntu.com/ubuntu/pool/main/b/bison/bison_2.5.dfsg-2.1_amd64.deb \
178 http://de.archive.ubuntu.com/ubuntu/pool/main/b/bison/libbison-dev_2.5.dfsg-2.1_amd64.deb
179RUN sudo dpkg -i bison_2.5.dfsg-2.1_amd64.deb libbison-dev_2.5.dfsg-2.1_amd64.deb
180RUN rm bison_2.5.dfsg-2.1_amd64.deb libbison-dev_2.5.dfsg-2.1_amd64.deb
181RUN wget -nc http://www.nbee.org/download/nbeesrc-jan-10-2013.zip && \
182 unzip nbeesrc-jan-10-2013.zip && \
183 cd nbeesrc-jan-10-2013/src && cmake . && make && \
184 cp ../bin/libn*.so /usr/local/lib && ldconfig && \
185 cp -R ../include/* /usr/include/
186WORKDIR /root
187RUN git clone https://github.com/CPqD/ofsoftswitch13.git && \
188 cd ofsoftswitch13 && \
189 git checkout d174464dcc414510990e38426e2e274a25330902 && \
190 ./boot.sh && \
191 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-ssl && \
192 make && make install
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700193CMD ["/bin/bash"]
Chetan Gaonkerb6064fa2016-05-02 16:29:57 -0700194'''.format(*image_format)
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700195 super(CordTester, cls).build_image(dockerfile, image)
196 print('Done building docker image %s' %image)
197
198 def run_tests(self, tests):
199 '''Run the list of tests'''
200 for t in tests:
201 test = t.split(':')[0]
A R Karthick24f1de62016-05-12 15:16:38 -0700202 test_file = '{}Test.py'.format(test)
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700203 if t.find(':') >= 0:
A R Karthick24f1de62016-05-12 15:16:38 -0700204 test_case = '{0}:{1}'.format(test_file, t.split(':')[1])
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700205 else:
206 test_case = test_file
Chetan Gaonker7142a342016-04-07 14:53:12 -0700207 cmd = 'nosetests -v {0}/src/test/{1}/{2}'.format(self.sandbox, test, test_case)
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700208 status = self.execute(cmd, shell = True)
209 print('Test %s %s' %(test_case, 'Success' if status == 0 else 'Failure'))
210 print('Done running tests')
211 if self.rm:
212 print('Removing test container %s' %self.name)
213 self.kill(remove=True)
214
Chetan Gaonkerfb3cb5e2016-05-06 11:55:44 -0700215 @classmethod
216 def list_tests(cls, tests):
217 print('Listing test cases')
218 for test in tests:
A R Karthick24f1de62016-05-12 15:16:38 -0700219 test_file = '{}Test.py'.format(test)
Chetan Gaonkerfb3cb5e2016-05-06 11:55:44 -0700220 cmd = 'nosetests -v --collect-only {0}/../{1}/{2}'.format(cls.tester_base, test, test_file)
221 os.system(cmd)
222
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700223##default onos/radius/test container images and names
224onos_image_default='onosproject/onos:latest'
Chetan Gaonker503032a2016-05-12 12:06:29 -0700225nose_image_default= '{}:latest'.format(CordTester.IMAGE)
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700226test_type_default='dhcp'
227onos_app_version = '1.0-SNAPSHOT'
Chetan Gaonker4d842ad2016-04-26 10:04:24 -0700228cord_tester_base = os.path.dirname(os.path.realpath(__file__))
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700229onos_app_file = os.path.abspath('{0}/../apps/ciena-cordigmp-'.format(cord_tester_base) + onos_app_version + '.oar')
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700230
231def runTest(args):
Chetan Gaonker823cdc52016-05-09 15:51:23 -0700232 #Start the cord test tcp server
233 test_server = cord_test_server_start()
Chetan Gaonker503032a2016-05-12 12:06:29 -0700234 if args.test_type.lower() == 'all':
235 tests = CordTester.ALL_TESTS
236 args.radius = True
237 args.quagga = True
238 else:
A R Karthickacae3b42016-05-12 15:27:24 -0700239 tests = args.test_type.split('-')
Chetan Gaonker503032a2016-05-12 12:06:29 -0700240
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700241 onos_cnt = {'tag':'latest'}
Chetan Gaonker503032a2016-05-12 12:06:29 -0700242 nose_cnt = {'image': CordTester.IMAGE, 'tag': 'latest'}
243 update_map = { 'quagga' : False, 'test' : False, 'radius' : False }
244 update_map[args.update.lower()] = True
245
246 if args.update.lower() == 'all':
247 for c in update_map.keys():
248 update_map[c] = True
249
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700250 radius_ip = None
Chetan Gaonkerc170f3f2016-04-19 17:24:45 -0700251 quagga_ip = None
Chetan Gaonkerfb3cb5e2016-05-06 11:55:44 -0700252
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700253 #don't spawn onos if the user has specified external test controller with test interface config
254 if args.test_controller:
255 ips = args.test_controller.split('/')
256 onos_ip = ips[0]
257 if len(ips) > 1:
258 radius_ip = ips[1]
259 else:
260 radius_ip = None
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700261 else:
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700262 onos_cnt['image'] = args.onos.split(':')[0]
263 if args.onos.find(':') >= 0:
264 onos_cnt['tag'] = args.onos.split(':')[1]
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700265
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700266 onos = Onos(image = onos_cnt['image'], tag = onos_cnt['tag'], boot_delay = 60)
267 onos_ip = onos.ip()
268
269 ##Start Radius container if specified
Chetan Gaonker7f4bf742016-05-04 15:56:08 -0700270 if args.radius == True:
Chetan Gaonker503032a2016-05-12 12:06:29 -0700271 radius = Radius( update = update_map['radius'])
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700272 radius_ip = radius.ip()
Chetan Gaonker7f4bf742016-05-04 15:56:08 -0700273 print('Radius server running with IP %s' %radius_ip)
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700274 else:
275 radius_ip = None
276
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700277 print('Onos IP %s, Test type %s' %(onos_ip, args.test_type))
278 print('Installing ONOS app %s' %onos_app_file)
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700279 OnosCtrl.install_app(args.app, onos_ip = onos_ip)
Chetan Gaonkerb84835f2016-04-19 15:12:10 -0700280
281 if args.quagga == True:
282 #Start quagga. Builds container if required
Chetan Gaonker503032a2016-05-12 12:06:29 -0700283 quagga = Quagga(update = update_map['quagga'])
Chetan Gaonkerc170f3f2016-04-19 17:24:45 -0700284 quagga_ip = quagga.ip()
Chetan Gaonkerb84835f2016-04-19 15:12:10 -0700285
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700286 test_cnt_env = { 'ONOS_CONTROLLER_IP' : onos_ip,
Chetan Gaonkerc170f3f2016-04-19 17:24:45 -0700287 '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 Gaonker93e302d2016-04-05 10:51:07 -0700289 }
290 if args.olt:
Chetan Gaonker7142a342016-04-07 14:53:12 -0700291 olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json')
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700292 test_cnt_env['OLT_CONFIG'] = olt_conf_test_loc
293
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700294 test_cnt = CordTester(ctlr_ip = onos_ip, image = nose_cnt['image'], tag = nose_cnt['tag'],
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700295 env = test_cnt_env,
Chetan Gaonker678743f2016-04-26 09:54:31 -0700296 rm = False if args.keep else True,
Chetan Gaonker503032a2016-05-12 12:06:29 -0700297 update = update_map['test'])
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -0700298 if args.start_switch or not args.olt:
299 test_cnt.start_switch()
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700300 test_cnt.setup_intfs()
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700301 test_cnt.run_tests(tests)
Chetan Gaonker3533faa2016-04-25 17:50:14 -0700302 cord_test_server_stop(test_server)
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700303
Chetan Gaonker503032a2016-05-12 12:06:29 -0700304def cleanupTests(args):
305 test_container = '{}:latest'.format(CordTester.IMAGE)
306 print('Cleaning up Test containers ...')
307 Container.cleanup(test_container)
308
309def listTests(args):
310 if args.test == 'all':
311 tests = CordTester.ALL_TESTS
312 else:
A R Karthickacae3b42016-05-12 15:27:24 -0700313 tests = args.test.split('-')
Chetan Gaonker503032a2016-05-12 12:06:29 -0700314 CordTester.list_tests(tests)
315
316def buildImages(args):
317 if args.image == 'all' or args.image == 'quagga':
318 Quagga.build_image(Quagga.IMAGE)
319
320 if args.image == 'all' or args.image == 'radius':
321 Radius.build_image(Radius.IMAGE)
322
323 if args.image == 'all' or args.image == 'test':
324 CordTester.build_image(CordTester.IMAGE)
325
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700326if __name__ == '__main__':
Chetan Gaonker678743f2016-04-26 09:54:31 -0700327 parser = ArgumentParser(description='Cord Tester')
Chetan Gaonker503032a2016-05-12 12:06:29 -0700328 subparser = parser.add_subparsers()
329 parser_run = subparser.add_parser('run', help='Run cord tester')
330 parser_run.add_argument('-t', '--test-type', default=test_type_default, help='Specify test type or test case to run')
331 parser_run.add_argument('-o', '--onos', default=onos_image_default, type=str, help='ONOS container image')
332 parser_run.add_argument('-r', '--radius',action='store_true', help='Start Radius service')
333 parser_run.add_argument('-q', '--quagga',action='store_true',help='Provision quagga container for vrouter')
334 parser_run.add_argument('-a', '--app', default=onos_app_file, type=str, help='Cord ONOS app filename')
335 parser_run.add_argument('-p', '--olt', action='store_true', help='Use OLT config')
336 parser_run.add_argument('-e', '--test-controller', default='', type=str, help='External test controller ip for Onos and/or radius server. '
Chetan Gaonker5209fe82016-04-19 10:09:53 -0700337 'Eg: 10.0.0.2/10.0.0.3 to specify ONOS and Radius ip to connect')
Chetan Gaonker503032a2016-05-12 12:06:29 -0700338 parser_run.add_argument('-k', '--keep', action='store_true', help='Keep test container after tests')
339 parser_run.add_argument('-s', '--start-switch', action='store_true', help='Start OVS when running under OLT config')
340 parser_run.add_argument('-u', '--update', default='none', choices=['test','quagga','radius', 'all'], type=str, help='Update cord tester container images. '
341 'Eg: --update=quagga to rebuild quagga image.'
342 ' --update=radius to rebuild radius server image.'
343 ' --update=test to rebuild cord test image.(Default)'
344 ' --update=all to rebuild all cord tester images.')
345 parser_run.set_defaults(func=runTest)
346
347 parser_list = subparser.add_parser('list', help='List test cases')
348 parser_list.add_argument('-t', '--test', default='all', help='Specify test type to list test cases. '
349 'Eg: -t tls to list tls test cases.'
350 ' -t tls-dhcp-vrouter to list tls,dhcp and vrouter test cases.'
351 ' -t all to list all test cases.')
352 parser_list.set_defaults(func=listTests)
353
354 parser_build = subparser.add_parser('build', help='Build cord test container images')
355 parser_build.add_argument('image', choices=['quagga', 'radius', 'test', 'all'])
356 parser_build.set_defaults(func=buildImages)
357
358 parser_cleanup = subparser.add_parser('cleanup', help='Cleanup test containers')
359 parser_cleanup.set_defaults(func=cleanupTests)
360
Chetan Gaonker93e302d2016-04-05 10:51:07 -0700361 args = parser.parse_args()
362 args.func(args)