blob: 10f61bd2c4477d9ea4948c6e99ec61825a7af96c [file] [log] [blame]
A R Karthickb7e80902016-05-17 09:38:31 -07001import unittest
2from nose.tools import *
3from nose.twistedtools import reactor, deferred
4from twisted.internet import defer
5from scapy.all import *
6import time, monotonic
7import os, sys
8import tempfile
9import random
10import threading
11import json
12from Stats import Stats
13from OnosCtrl import OnosCtrl
14from DHCP import DHCPTest
15from EapTLS import TLSAuthTest
16from Channels import Channels, IgmpChannel
17from subscriberDb import SubscriberDB
18from threadPool import ThreadPool
A.R Karthick95d044e2016-06-10 18:44:36 -070019from portmaps import g_subscriber_port_map
A R Karthickb7e80902016-05-17 09:38:31 -070020from OltConfig import *
21from OnosFlowCtrl import get_mac
22from CordTestServer import cord_test_onos_restart
23
24log.setLevel('INFO')
25
26class Subscriber(Channels):
27 PORT_TX_DEFAULT = 2
28 PORT_RX_DEFAULT = 1
29 INTF_TX_DEFAULT = 'veth2'
30 INTF_RX_DEFAULT = 'veth0'
31 STATS_RX = 0
32 STATS_TX = 1
33 STATS_JOIN = 2
34 STATS_LEAVE = 3
35 SUBSCRIBER_SERVICES = 'DHCP IGMP TLS'
36 def __init__(self, name = 'sub', service = SUBSCRIBER_SERVICES, port_map = None,
37 num = 1, channel_start = 0,
38 tx_port = PORT_TX_DEFAULT, rx_port = PORT_RX_DEFAULT,
39 iface = INTF_RX_DEFAULT, iface_mcast = INTF_TX_DEFAULT,
40 mcast_cb = None, loginType = 'wireless'):
41 self.tx_port = tx_port
42 self.rx_port = rx_port
43 self.port_map = port_map or g_subscriber_port_map
44 try:
45 self.tx_intf = self.port_map[tx_port]
46 self.rx_intf = self.port_map[rx_port]
47 except:
48 self.tx_intf = self.port_map[self.PORT_TX_DEFAULT]
49 self.rx_intf = self.port_map[self.PORT_RX_DEFAULT]
50
A R Karthick338268f2016-06-21 17:12:13 -070051 log.info('Subscriber %s, rx interface %s, uplink interface %s' %(name, self.rx_intf, self.tx_intf))
A.R Karthick95d044e2016-06-10 18:44:36 -070052 Channels.__init__(self, num, channel_start = channel_start,
A R Karthickb7e80902016-05-17 09:38:31 -070053 iface = self.rx_intf, iface_mcast = self.tx_intf, mcast_cb = mcast_cb)
54 self.name = name
55 self.service = service
56 self.service_map = {}
57 services = self.service.strip().split(' ')
58 for s in services:
59 self.service_map[s] = True
60 self.loginType = loginType
61 ##start streaming channels
62 self.join_map = {}
63 ##accumulated join recv stats
64 self.join_rx_stats = Stats()
A R Karthick338268f2016-06-21 17:12:13 -070065 self.recv_timeout = False
A R Karthickb7e80902016-05-17 09:38:31 -070066
67 def has_service(self, service):
68 if self.service_map.has_key(service):
69 return self.service_map[service]
70 if self.service_map.has_key(service.upper()):
71 return self.service_map[service.upper()]
72 return False
73
74 def channel_join_update(self, chan, join_time):
75 self.join_map[chan] = ( Stats(), Stats(), Stats(), Stats() )
76 self.channel_update(chan, self.STATS_JOIN, 1, t = join_time)
77
78 def channel_join(self, chan = 0, delay = 2):
79 '''Join a channel and create a send/recv stats map'''
80 if self.join_map.has_key(chan):
81 del self.join_map[chan]
82 self.delay = delay
83 chan, join_time = self.join(chan)
84 self.channel_join_update(chan, join_time)
85 return chan
86
87 def channel_join_next(self, delay = 2):
88 '''Joins the next channel leaving the last channel'''
89 if self.last_chan:
90 if self.join_map.has_key(self.last_chan):
91 del self.join_map[self.last_chan]
92 self.delay = delay
93 chan, join_time = self.join_next()
94 self.channel_join_update(chan, join_time)
95 return chan
96
97 def channel_jump(self, delay = 2):
98 '''Jumps randomly to the next channel leaving the last channel'''
99 if self.last_chan is not None:
100 if self.join_map.has_key(self.last_chan):
101 del self.join_map[self.last_chan]
102 self.delay = delay
103 chan, join_time = self.jump()
104 self.channel_join_update(chan, join_time)
105 return chan
106
107 def channel_leave(self, chan = 0):
108 if self.join_map.has_key(chan):
109 del self.join_map[chan]
110 self.leave(chan)
111
112 def channel_update(self, chan, stats_type, packets, t=0):
113 if type(chan) == type(0):
114 chan_list = (chan,)
115 else:
116 chan_list = chan
A.R Karthick95d044e2016-06-10 18:44:36 -0700117 for c in chan_list:
A R Karthickb7e80902016-05-17 09:38:31 -0700118 if self.join_map.has_key(c):
119 self.join_map[c][stats_type].update(packets = packets, t = t)
120
A R Karthick338268f2016-06-21 17:12:13 -0700121 def channel_receive(self, chan, cb = None, count = 1, timeout = 5):
122 log.info('Subscriber %s on port %s receiving from group %s, channel %d' %
123 (self.name, self.rx_intf, self.gaddr(chan), chan))
124 r = self.recv(chan, cb = cb, count = count, timeout = timeout)
125 if self.recv_timeout:
126 ##Negative test case is disabled for now
127 assert_equal(len(r), 0)
A R Karthickb7e80902016-05-17 09:38:31 -0700128
129 def recv_channel_cb(self, pkt):
130 ##First verify that we have received the packet for the joined instance
A R Karthick338268f2016-06-21 17:12:13 -0700131 log.info('Packet received for group %s, subscriber %s, port %s' %
132 (pkt[IP].dst, self.name, self.rx_intf))
133 if self.recv_timeout:
134 return
A R Karthickb7e80902016-05-17 09:38:31 -0700135 chan = self.caddr(pkt[IP].dst)
136 assert_equal(chan in self.join_map.keys(), True)
137 recv_time = monotonic.monotonic() * 1000000
138 join_time = self.join_map[chan][self.STATS_JOIN].start
139 delta = recv_time - join_time
140 self.join_rx_stats.update(packets=1, t = delta, usecs = True)
141 self.channel_update(chan, self.STATS_RX, 1, t = delta)
142 log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst))
143
144class subscriber_pool:
145
146 def __init__(self, subscriber, test_cbs):
147 self.subscriber = subscriber
148 self.test_cbs = test_cbs
149
150 def pool_cb(self):
151 for cb in self.test_cbs:
152 if cb:
153 cb(self.subscriber)
A.R Karthick95d044e2016-06-10 18:44:36 -0700154
A R Karthickb7e80902016-05-17 09:38:31 -0700155class subscriber_exchange(unittest.TestCase):
156
A.R Karthick95d044e2016-06-10 18:44:36 -0700157 apps = ('org.opencord.aaa', 'org.onosproject.dhcp')
158 olt_apps = () #'org.opencord.cordmcast')
A R Karthickb7e80902016-05-17 09:38:31 -0700159 table_app = 'org.ciena.cordigmp'
160 dhcp_server_config = {
161 "ip": "10.1.11.50",
162 "mac": "ca:fe:ca:fe:ca:fe",
163 "subnet": "255.255.252.0",
164 "broadcast": "10.1.11.255",
165 "router": "10.1.8.1",
166 "domain": "8.8.8.8",
167 "ttl": "63",
168 "delay": "2",
169 "startip": "10.1.11.51",
170 "endip": "10.1.11.100"
171 }
172
173 aaa_loaded = False
174 test_path = os.path.dirname(os.path.realpath(__file__))
A R Karthick4b72d4b2016-06-15 11:09:17 -0700175 table_app_file = os.path.join(test_path, '..', 'apps/ciena-cordigmp-multitable-2.0-SNAPSHOT.oar')
176 app_file = os.path.join(test_path, '..', 'apps/ciena-cordigmp-2.0-SNAPSHOT.oar')
A R Karthickb7e80902016-05-17 09:38:31 -0700177 onos_config_path = os.path.join(test_path, '..', 'setup/onos-config')
178 olt_conf_file = os.path.join(test_path, '..', 'setup/olt_config_multitable.json')
179 cpqd_path = os.path.join(test_path, '..', 'setup')
180 ovs_path = cpqd_path
181 device_id = 'of:' + get_mac('ovsbr0')
A R Karthick4b72d4b2016-06-15 11:09:17 -0700182 device_dict = { "devices" : {
A R Karthickb7e80902016-05-17 09:38:31 -0700183 "{}".format(device_id) : {
184 "basic" : {
A R Karthick4b72d4b2016-06-15 11:09:17 -0700185 "driver" : "pmc-olt"
A R Karthickb7e80902016-05-17 09:38:31 -0700186 }
187 }
188 },
189 }
A R Karthick4b72d4b2016-06-15 11:09:17 -0700190 test_services = ('IGMP',)
A R Karthick338268f2016-06-21 17:12:13 -0700191 num_joins = 0
192 num_subscribers = 0
193 num_channels = 0
194 recv_timeout = False
A R Karthickb7e80902016-05-17 09:38:31 -0700195
196 @classmethod
197 def setUpClass(cls):
198 '''Load the OLT config and activate relevant apps'''
A R Karthick4b72d4b2016-06-15 11:09:17 -0700199 device_id = cls.start_cpqd(mac = RandMAC()._fix())
200 network_cfg = { "devices" : {
201 "{}".format(device_id) : {
202 "basic" : {
203 "driver" : "pmc-olt"
204 }
205 }
206 },
207 }
208 cls.device_id = device_id
209 ## Restart ONOS with cpqd driver config for OVS
210 cls.start_onos(network_cfg = network_cfg)
A R Karthickb7e80902016-05-17 09:38:31 -0700211 cls.install_app_table()
A R Karthickb7e80902016-05-17 09:38:31 -0700212 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
213 OnosCtrl.cord_olt_config(cls.olt.olt_device_data())
214 cls.port_map, cls.port_list = cls.olt.olt_port_map_multi()
215 cls.activate_apps(cls.apps + cls.olt_apps)
216
217 @classmethod
218 def tearDownClass(cls):
219 '''Deactivate the olt apps and restart OVS back'''
220 apps = cls.olt_apps + ( cls.table_app,)
221 for app in apps:
222 onos_ctrl = OnosCtrl(app)
223 onos_ctrl.deactivate()
224 cls.uninstall_app_table()
A R Karthick4b72d4b2016-06-15 11:09:17 -0700225 cls.remove_onos_config()
A R Karthickb7e80902016-05-17 09:38:31 -0700226 cls.start_ovs()
227
228 @classmethod
229 def activate_apps(cls, apps):
230 for app in apps:
231 onos_ctrl = OnosCtrl(app)
232 status, _ = onos_ctrl.activate()
233 assert_equal(status, True)
234 time.sleep(2)
235
236 @classmethod
237 def install_app_table(cls):
238 ##Uninstall the existing app if any
239 OnosCtrl.uninstall_app(cls.table_app)
240 time.sleep(2)
241 log.info('Installing the multi table app %s for subscriber test' %(cls.table_app_file))
242 OnosCtrl.install_app(cls.table_app_file)
243 time.sleep(3)
244
245 @classmethod
246 def uninstall_app_table(cls):
247 ##Uninstall the table app on class exit
248 OnosCtrl.uninstall_app(cls.table_app)
249 time.sleep(2)
250 log.info('Installing back the cord igmp app %s for subscriber test on exit' %(cls.app_file))
251 OnosCtrl.install_app(cls.app_file)
252
253 @classmethod
254 def start_onos(cls, network_cfg = None):
255 if network_cfg is None:
A R Karthick4b72d4b2016-06-15 11:09:17 -0700256 network_cfg = cls.device_dict
A R Karthickb7e80902016-05-17 09:38:31 -0700257
258 if type(network_cfg) is tuple:
259 res = []
260 for v in network_cfg:
261 res += v.items()
262 config = dict(res)
263 else:
264 config = network_cfg
265 log.info('Restarting ONOS with new network configuration')
A R Karthick338268f2016-06-21 17:12:13 -0700266 return cord_test_onos_restart(config = config)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700267
268 @classmethod
269 def remove_onos_config(cls):
270 try:
271 os.unlink('{}/network-cfg.json'.format(cls.onos_config_path))
272 except: pass
A R Karthickb7e80902016-05-17 09:38:31 -0700273
274 @classmethod
275 def start_cpqd(cls, mac = '00:11:22:33:44:55'):
276 dpid = mac.replace(':', '')
277 cpqd_file = os.sep.join( (cls.cpqd_path, 'cpqd.sh') )
278 cpqd_cmd = '{} {}'.format(cpqd_file, dpid)
279 ret = os.system(cpqd_cmd)
280 assert_equal(ret, 0)
281 time.sleep(10)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700282 device_id = 'of:{}{}'.format('0'*4, dpid)
283 return device_id
A R Karthickb7e80902016-05-17 09:38:31 -0700284
285 @classmethod
286 def start_ovs(cls):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700287 ovs_file = os.sep.join( (cls.ovs_path, 'of-bridge.sh') )
A R Karthickb7e80902016-05-17 09:38:31 -0700288 ret = os.system(ovs_file)
289 assert_equal(ret, 0)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700290 time.sleep(30)
A R Karthickb7e80902016-05-17 09:38:31 -0700291
292 def onos_aaa_load(self):
293 if self.aaa_loaded:
294 return
A.R Karthick95d044e2016-06-10 18:44:36 -0700295 aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password',
A R Karthickb7e80902016-05-17 09:38:31 -0700296 'radiusIp': '172.17.0.2' } } } }
297 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
298 aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip
299 self.onos_load_config('org.onosproject.aaa', aaa_dict)
300 self.aaa_loaded = True
301
302 def onos_dhcp_table_load(self, config = None):
303 dhcp_dict = {'apps' : { 'org.onosproject.dhcp' : { 'dhcp' : copy.copy(self.dhcp_server_config) } } }
304 dhcp_config = dhcp_dict['apps']['org.onosproject.dhcp']['dhcp']
305 if config:
306 for k in config.keys():
307 if dhcp_config.has_key(k):
308 dhcp_config[k] = config[k]
309 self.onos_load_config('org.onosproject.dhcp', dhcp_dict)
310
311 def onos_load_config(self, app, config):
312 status, code = OnosCtrl.config(config)
313 if status is False:
314 log.info('JSON config request for app %s returned status %d' %(app, code))
315 assert_equal(status, True)
316 time.sleep(2)
317
318 def dhcp_sndrcv(self, dhcp, update_seed = False):
319 cip, sip = dhcp.discover(update_seed = update_seed)
320 assert_not_equal(cip, None)
321 assert_not_equal(sip, None)
322 log.info('Got dhcp client IP %s from server %s for mac %s' %
323 (cip, sip, dhcp.get_mac(cip)[0]))
324 return cip,sip
325
326 def dhcp_request(self, subscriber, seed_ip = '10.10.10.1', update_seed = False):
327 config = {'startip':'10.10.10.20', 'endip':'10.10.10.200',
328 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe",
329 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'}
330 self.onos_dhcp_table_load(config)
331 dhcp = DHCPTest(seed_ip = seed_ip, iface = subscriber.iface)
332 cip, sip = self.dhcp_sndrcv(dhcp, update_seed = update_seed)
333 return cip, sip
334
335 def recv_channel_cb(self, pkt):
336 ##First verify that we have received the packet for the joined instance
337 chan = self.subscriber.caddr(pkt[IP].dst)
338 assert_equal(chan in self.subscriber.join_map.keys(), True)
339 recv_time = monotonic.monotonic() * 1000000
340 join_time = self.subscriber.join_map[chan][self.subscriber.STATS_JOIN].start
341 delta = recv_time - join_time
342 self.subscriber.join_rx_stats.update(packets=1, t = delta, usecs = True)
343 self.subscriber.channel_update(chan, self.subscriber.STATS_RX, 1, t = delta)
344 log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst))
345 self.test_status = True
346
347 def tls_verify(self, subscriber):
348 if subscriber.has_service('TLS'):
349 time.sleep(2)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700350 tls = TLSAuthTest(intf = subscriber.rx_intf)
A R Karthickb7e80902016-05-17 09:38:31 -0700351 log.info('Running subscriber %s tls auth test' %subscriber.name)
352 tls.runTest()
353 self.test_status = True
354
355 def dhcp_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700356 if subscriber.has_service('DHCP'):
357 cip, sip = self.dhcp_request(subscriber, update_seed = True)
358 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
359 subscriber.src_list = [cip]
360 self.test_status = True
361 else:
362 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
363 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700364
365 def dhcp_jump_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700366 if subscriber.has_service('DHCP'):
367 cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.200.1')
368 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
369 subscriber.src_list = [cip]
370 self.test_status = True
371 else:
372 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
373 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700374
375 def dhcp_next_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700376 if subscriber.has_service('DHCP'):
377 cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.150.1')
378 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
379 subscriber.src_list = [cip]
380 self.test_status = True
381 else:
382 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
383 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700384
385 def igmp_verify(self, subscriber):
386 chan = 0
387 if subscriber.has_service('IGMP'):
A R Karthick338268f2016-06-21 17:12:13 -0700388 ##We wait for all the subscribers to join before triggering leaves
389 if subscriber.rx_port > 1:
390 time.sleep(5)
391 subscriber.channel_join(chan, delay = 0)
392 self.num_joins += 1
393 while self.num_joins < self.num_subscribers:
394 time.sleep(5)
395 log.info('All subscribers have joined the channel')
396 for i in range(10):
397 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 10)
A R Karthickb7e80902016-05-17 09:38:31 -0700398 log.info('Leaving channel %d for subscriber %s' %(chan, subscriber.name))
399 subscriber.channel_leave(chan)
A R Karthick338268f2016-06-21 17:12:13 -0700400 time.sleep(5)
A R Karthickb7e80902016-05-17 09:38:31 -0700401 log.info('Interface %s Join RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name,subscriber.join_rx_stats))
A R Karthick338268f2016-06-21 17:12:13 -0700402 #Should not receive packets for this subscriber
403 self.recv_timeout = True
404 subscriber.recv_timeout = True
405 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 10)
406 subscriber.recv_timeout = False
407 self.recv_timeout = False
408 log.info('Joining channel %d for subscriber %s' %(chan, subscriber.name))
409 subscriber.channel_join(chan, delay = 0)
A R Karthickb7e80902016-05-17 09:38:31 -0700410 self.test_status = True
411
412 def igmp_jump_verify(self, subscriber):
413 if subscriber.has_service('IGMP'):
414 for i in xrange(subscriber.num):
415 log.info('Subscriber %s jumping channel' %subscriber.name)
416 chan = subscriber.channel_jump(delay=0)
417 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1)
418 log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name))
419 time.sleep(3)
420 log.info('Interface %s Jump RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats))
421 self.test_status = True
422
423 def igmp_next_verify(self, subscriber):
424 if subscriber.has_service('IGMP'):
425 for i in xrange(subscriber.num):
426 if i:
427 chan = subscriber.channel_join_next(delay=0)
428 else:
429 chan = subscriber.channel_join(i, delay=0)
430 log.info('Joined next channel %d for subscriber %s' %(chan, subscriber.name))
431 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count=1)
432 log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name))
433 time.sleep(3)
434 log.info('Interface %s Join Next RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats))
435 self.test_status = True
436
437 def generate_port_list(self, subscribers, channels):
438 return self.port_list[:subscribers]
439
440 def subscriber_load(self, create = True, num = 10, num_channels = 1, channel_start = 0, port_list = []):
441 '''Load the subscriber from the database'''
A R Karthick4b72d4b2016-06-15 11:09:17 -0700442 self.subscriber_db = SubscriberDB(create = create, services = self.test_services)
A R Karthickb7e80902016-05-17 09:38:31 -0700443 if create is True:
444 self.subscriber_db.generate(num)
445 self.subscriber_info = self.subscriber_db.read(num)
446 self.subscriber_list = []
447 if not port_list:
448 port_list = self.generate_port_list(num, num_channels)
449
450 index = 0
451 for info in self.subscriber_info:
A.R Karthick95d044e2016-06-10 18:44:36 -0700452 self.subscriber_list.append(Subscriber(name=info['Name'],
A R Karthickb7e80902016-05-17 09:38:31 -0700453 service=info['Service'],
454 port_map = self.port_map,
455 num=num_channels,
456 channel_start = channel_start,
457 tx_port = port_list[index][0],
458 rx_port = port_list[index][1]))
459 if num_channels > 1:
460 channel_start += num_channels
461 index += 1
462
463 #load the ssm list for all subscriber channels
464 igmpChannel = IgmpChannel()
465 ssm_groups = map(lambda sub: sub.channels, self.subscriber_list)
466 ssm_list = reduce(lambda ssm1, ssm2: ssm1+ssm2, ssm_groups)
467 igmpChannel.igmp_load_ssm_config(ssm_list)
468
A.R Karthick95d044e2016-06-10 18:44:36 -0700469 def subscriber_join_verify( self, num_subscribers = 10, num_channels = 1,
A R Karthickb7e80902016-05-17 09:38:31 -0700470 channel_start = 0, cbs = None, port_list = []):
471 self.test_status = False
472 self.num_subscribers = num_subscribers
473 self.subscriber_load(create = True, num = num_subscribers,
474 num_channels = num_channels, channel_start = channel_start, port_list = port_list)
475 self.onos_aaa_load()
476 self.thread_pool = ThreadPool(min(100, self.num_subscribers), queue_size=1, wait_timeout=1)
A R Karthick338268f2016-06-21 17:12:13 -0700477 chan_leave = False #for single channel, multiple subscribers
A R Karthickb7e80902016-05-17 09:38:31 -0700478 if cbs is None:
479 cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify)
A R Karthick338268f2016-06-21 17:12:13 -0700480 chan_leave = True
A R Karthickb7e80902016-05-17 09:38:31 -0700481 for subscriber in self.subscriber_list:
482 subscriber.start()
483 pool_object = subscriber_pool(subscriber, cbs)
484 self.thread_pool.addTask(pool_object.pool_cb)
485 self.thread_pool.cleanUpThreads()
486 for subscriber in self.subscriber_list:
487 subscriber.stop()
A R Karthick338268f2016-06-21 17:12:13 -0700488 if chan_leave is True:
489 subscriber.channel_leave(0)
490 self.num_subscribers = 0
A R Karthickb7e80902016-05-17 09:38:31 -0700491 return self.test_status
492
493 def test_subscriber_join_recv(self):
494 """Test subscriber join and receive"""
A R Karthick338268f2016-06-21 17:12:13 -0700495 self.num_subscribers = 5
496 self.num_channels = 1
497 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
498 num_channels = self.num_channels,
499 port_list = self.generate_port_list(self.num_subscribers,
500 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700501 assert_equal(test_status, True)
502
503 def test_subscriber_join_jump(self):
A.R Karthick95d044e2016-06-10 18:44:36 -0700504 """Test subscriber join and receive for channel surfing"""
A R Karthick338268f2016-06-21 17:12:13 -0700505 self.num_subscribers = 5
506 self.num_channels = 10
507 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
508 num_channels = self.num_channels,
A R Karthickb7e80902016-05-17 09:38:31 -0700509 cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify),
A R Karthick338268f2016-06-21 17:12:13 -0700510 port_list = self.generate_port_list(self.num_subscribers,
511 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700512 assert_equal(test_status, True)
513
514 def test_subscriber_join_next(self):
515 """Test subscriber join next for channels"""
A R Karthick338268f2016-06-21 17:12:13 -0700516 self.num_subscribers = 5
517 self.num_channels = 10
518 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
519 num_channels = self.num_channels,
A R Karthickb7e80902016-05-17 09:38:31 -0700520 cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify),
A R Karthick338268f2016-06-21 17:12:13 -0700521 port_list = self.generate_port_list(self.num_subscribers,
522 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700523 assert_equal(test_status, True)