blob: 948f9df5e07673ab6b0a8f6feb3a2879328c79b6 [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 network_cfg = { "devices" : {
A R Karthicke0f33fa2016-06-22 13:36:02 -0700200 "{}".format(cls.device_id) : {
A R Karthick4b72d4b2016-06-15 11:09:17 -0700201 "basic" : {
202 "driver" : "pmc-olt"
203 }
204 }
205 },
206 }
A R Karthick4b72d4b2016-06-15 11:09:17 -0700207 ## Restart ONOS with cpqd driver config for OVS
208 cls.start_onos(network_cfg = network_cfg)
A R Karthickb7e80902016-05-17 09:38:31 -0700209 cls.install_app_table()
A R Karthickb7e80902016-05-17 09:38:31 -0700210 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
211 OnosCtrl.cord_olt_config(cls.olt.olt_device_data())
212 cls.port_map, cls.port_list = cls.olt.olt_port_map_multi()
213 cls.activate_apps(cls.apps + cls.olt_apps)
214
215 @classmethod
216 def tearDownClass(cls):
217 '''Deactivate the olt apps and restart OVS back'''
218 apps = cls.olt_apps + ( cls.table_app,)
219 for app in apps:
220 onos_ctrl = OnosCtrl(app)
221 onos_ctrl.deactivate()
222 cls.uninstall_app_table()
A R Karthicke0f33fa2016-06-22 13:36:02 -0700223 cls.start_onos(network_cfg = {})
A R Karthickb7e80902016-05-17 09:38:31 -0700224
225 @classmethod
226 def activate_apps(cls, apps):
227 for app in apps:
228 onos_ctrl = OnosCtrl(app)
229 status, _ = onos_ctrl.activate()
230 assert_equal(status, True)
231 time.sleep(2)
232
233 @classmethod
234 def install_app_table(cls):
235 ##Uninstall the existing app if any
236 OnosCtrl.uninstall_app(cls.table_app)
237 time.sleep(2)
238 log.info('Installing the multi table app %s for subscriber test' %(cls.table_app_file))
239 OnosCtrl.install_app(cls.table_app_file)
240 time.sleep(3)
241
242 @classmethod
243 def uninstall_app_table(cls):
244 ##Uninstall the table app on class exit
245 OnosCtrl.uninstall_app(cls.table_app)
246 time.sleep(2)
247 log.info('Installing back the cord igmp app %s for subscriber test on exit' %(cls.app_file))
248 OnosCtrl.install_app(cls.app_file)
249
250 @classmethod
251 def start_onos(cls, network_cfg = None):
252 if network_cfg is None:
A R Karthick4b72d4b2016-06-15 11:09:17 -0700253 network_cfg = cls.device_dict
A R Karthickb7e80902016-05-17 09:38:31 -0700254
255 if type(network_cfg) is tuple:
256 res = []
257 for v in network_cfg:
258 res += v.items()
259 config = dict(res)
260 else:
261 config = network_cfg
262 log.info('Restarting ONOS with new network configuration')
A R Karthick338268f2016-06-21 17:12:13 -0700263 return cord_test_onos_restart(config = config)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700264
265 @classmethod
266 def remove_onos_config(cls):
267 try:
268 os.unlink('{}/network-cfg.json'.format(cls.onos_config_path))
269 except: pass
A R Karthickb7e80902016-05-17 09:38:31 -0700270
271 @classmethod
272 def start_cpqd(cls, mac = '00:11:22:33:44:55'):
273 dpid = mac.replace(':', '')
274 cpqd_file = os.sep.join( (cls.cpqd_path, 'cpqd.sh') )
275 cpqd_cmd = '{} {}'.format(cpqd_file, dpid)
276 ret = os.system(cpqd_cmd)
277 assert_equal(ret, 0)
278 time.sleep(10)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700279 device_id = 'of:{}{}'.format('0'*4, dpid)
280 return device_id
A R Karthickb7e80902016-05-17 09:38:31 -0700281
282 @classmethod
283 def start_ovs(cls):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700284 ovs_file = os.sep.join( (cls.ovs_path, 'of-bridge.sh') )
A R Karthickb7e80902016-05-17 09:38:31 -0700285 ret = os.system(ovs_file)
286 assert_equal(ret, 0)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700287 time.sleep(30)
A R Karthickb7e80902016-05-17 09:38:31 -0700288
289 def onos_aaa_load(self):
290 if self.aaa_loaded:
291 return
A.R Karthick95d044e2016-06-10 18:44:36 -0700292 aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password',
A R Karthickb7e80902016-05-17 09:38:31 -0700293 'radiusIp': '172.17.0.2' } } } }
294 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
295 aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip
296 self.onos_load_config('org.onosproject.aaa', aaa_dict)
297 self.aaa_loaded = True
298
299 def onos_dhcp_table_load(self, config = None):
300 dhcp_dict = {'apps' : { 'org.onosproject.dhcp' : { 'dhcp' : copy.copy(self.dhcp_server_config) } } }
301 dhcp_config = dhcp_dict['apps']['org.onosproject.dhcp']['dhcp']
302 if config:
303 for k in config.keys():
304 if dhcp_config.has_key(k):
305 dhcp_config[k] = config[k]
306 self.onos_load_config('org.onosproject.dhcp', dhcp_dict)
307
308 def onos_load_config(self, app, config):
309 status, code = OnosCtrl.config(config)
310 if status is False:
311 log.info('JSON config request for app %s returned status %d' %(app, code))
312 assert_equal(status, True)
313 time.sleep(2)
314
315 def dhcp_sndrcv(self, dhcp, update_seed = False):
316 cip, sip = dhcp.discover(update_seed = update_seed)
317 assert_not_equal(cip, None)
318 assert_not_equal(sip, None)
319 log.info('Got dhcp client IP %s from server %s for mac %s' %
320 (cip, sip, dhcp.get_mac(cip)[0]))
321 return cip,sip
322
323 def dhcp_request(self, subscriber, seed_ip = '10.10.10.1', update_seed = False):
324 config = {'startip':'10.10.10.20', 'endip':'10.10.10.200',
325 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe",
326 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'}
327 self.onos_dhcp_table_load(config)
328 dhcp = DHCPTest(seed_ip = seed_ip, iface = subscriber.iface)
329 cip, sip = self.dhcp_sndrcv(dhcp, update_seed = update_seed)
330 return cip, sip
331
332 def recv_channel_cb(self, pkt):
333 ##First verify that we have received the packet for the joined instance
334 chan = self.subscriber.caddr(pkt[IP].dst)
335 assert_equal(chan in self.subscriber.join_map.keys(), True)
336 recv_time = monotonic.monotonic() * 1000000
337 join_time = self.subscriber.join_map[chan][self.subscriber.STATS_JOIN].start
338 delta = recv_time - join_time
339 self.subscriber.join_rx_stats.update(packets=1, t = delta, usecs = True)
340 self.subscriber.channel_update(chan, self.subscriber.STATS_RX, 1, t = delta)
341 log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst))
342 self.test_status = True
343
344 def tls_verify(self, subscriber):
345 if subscriber.has_service('TLS'):
346 time.sleep(2)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700347 tls = TLSAuthTest(intf = subscriber.rx_intf)
A R Karthickb7e80902016-05-17 09:38:31 -0700348 log.info('Running subscriber %s tls auth test' %subscriber.name)
349 tls.runTest()
350 self.test_status = True
351
352 def dhcp_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700353 if subscriber.has_service('DHCP'):
354 cip, sip = self.dhcp_request(subscriber, update_seed = True)
355 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
356 subscriber.src_list = [cip]
357 self.test_status = True
358 else:
359 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
360 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700361
362 def dhcp_jump_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700363 if subscriber.has_service('DHCP'):
364 cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.200.1')
365 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
366 subscriber.src_list = [cip]
367 self.test_status = True
368 else:
369 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
370 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700371
372 def dhcp_next_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700373 if subscriber.has_service('DHCP'):
374 cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.150.1')
375 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
376 subscriber.src_list = [cip]
377 self.test_status = True
378 else:
379 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
380 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700381
382 def igmp_verify(self, subscriber):
383 chan = 0
384 if subscriber.has_service('IGMP'):
A R Karthick338268f2016-06-21 17:12:13 -0700385 ##We wait for all the subscribers to join before triggering leaves
386 if subscriber.rx_port > 1:
387 time.sleep(5)
388 subscriber.channel_join(chan, delay = 0)
389 self.num_joins += 1
390 while self.num_joins < self.num_subscribers:
391 time.sleep(5)
392 log.info('All subscribers have joined the channel')
393 for i in range(10):
394 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 10)
A R Karthickb7e80902016-05-17 09:38:31 -0700395 log.info('Leaving channel %d for subscriber %s' %(chan, subscriber.name))
396 subscriber.channel_leave(chan)
A R Karthick338268f2016-06-21 17:12:13 -0700397 time.sleep(5)
A R Karthickb7e80902016-05-17 09:38:31 -0700398 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 -0700399 #Should not receive packets for this subscriber
400 self.recv_timeout = True
401 subscriber.recv_timeout = True
402 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 10)
403 subscriber.recv_timeout = False
404 self.recv_timeout = False
405 log.info('Joining channel %d for subscriber %s' %(chan, subscriber.name))
406 subscriber.channel_join(chan, delay = 0)
A R Karthickb7e80902016-05-17 09:38:31 -0700407 self.test_status = True
408
409 def igmp_jump_verify(self, subscriber):
410 if subscriber.has_service('IGMP'):
411 for i in xrange(subscriber.num):
412 log.info('Subscriber %s jumping channel' %subscriber.name)
413 chan = subscriber.channel_jump(delay=0)
414 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1)
415 log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name))
416 time.sleep(3)
417 log.info('Interface %s Jump RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats))
418 self.test_status = True
419
420 def igmp_next_verify(self, subscriber):
421 if subscriber.has_service('IGMP'):
422 for i in xrange(subscriber.num):
423 if i:
424 chan = subscriber.channel_join_next(delay=0)
425 else:
426 chan = subscriber.channel_join(i, delay=0)
427 log.info('Joined next channel %d for subscriber %s' %(chan, subscriber.name))
428 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count=1)
429 log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name))
430 time.sleep(3)
431 log.info('Interface %s Join Next RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats))
432 self.test_status = True
433
434 def generate_port_list(self, subscribers, channels):
435 return self.port_list[:subscribers]
436
437 def subscriber_load(self, create = True, num = 10, num_channels = 1, channel_start = 0, port_list = []):
438 '''Load the subscriber from the database'''
A R Karthick4b72d4b2016-06-15 11:09:17 -0700439 self.subscriber_db = SubscriberDB(create = create, services = self.test_services)
A R Karthickb7e80902016-05-17 09:38:31 -0700440 if create is True:
441 self.subscriber_db.generate(num)
442 self.subscriber_info = self.subscriber_db.read(num)
443 self.subscriber_list = []
444 if not port_list:
445 port_list = self.generate_port_list(num, num_channels)
446
447 index = 0
448 for info in self.subscriber_info:
A.R Karthick95d044e2016-06-10 18:44:36 -0700449 self.subscriber_list.append(Subscriber(name=info['Name'],
A R Karthickb7e80902016-05-17 09:38:31 -0700450 service=info['Service'],
451 port_map = self.port_map,
452 num=num_channels,
453 channel_start = channel_start,
454 tx_port = port_list[index][0],
455 rx_port = port_list[index][1]))
456 if num_channels > 1:
457 channel_start += num_channels
458 index += 1
459
460 #load the ssm list for all subscriber channels
461 igmpChannel = IgmpChannel()
462 ssm_groups = map(lambda sub: sub.channels, self.subscriber_list)
463 ssm_list = reduce(lambda ssm1, ssm2: ssm1+ssm2, ssm_groups)
464 igmpChannel.igmp_load_ssm_config(ssm_list)
465
A.R Karthick95d044e2016-06-10 18:44:36 -0700466 def subscriber_join_verify( self, num_subscribers = 10, num_channels = 1,
A R Karthickb7e80902016-05-17 09:38:31 -0700467 channel_start = 0, cbs = None, port_list = []):
468 self.test_status = False
469 self.num_subscribers = num_subscribers
470 self.subscriber_load(create = True, num = num_subscribers,
471 num_channels = num_channels, channel_start = channel_start, port_list = port_list)
472 self.onos_aaa_load()
473 self.thread_pool = ThreadPool(min(100, self.num_subscribers), queue_size=1, wait_timeout=1)
A R Karthick338268f2016-06-21 17:12:13 -0700474 chan_leave = False #for single channel, multiple subscribers
A R Karthickb7e80902016-05-17 09:38:31 -0700475 if cbs is None:
476 cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify)
A R Karthick338268f2016-06-21 17:12:13 -0700477 chan_leave = True
A R Karthickb7e80902016-05-17 09:38:31 -0700478 for subscriber in self.subscriber_list:
479 subscriber.start()
480 pool_object = subscriber_pool(subscriber, cbs)
481 self.thread_pool.addTask(pool_object.pool_cb)
482 self.thread_pool.cleanUpThreads()
483 for subscriber in self.subscriber_list:
484 subscriber.stop()
A R Karthick338268f2016-06-21 17:12:13 -0700485 if chan_leave is True:
486 subscriber.channel_leave(0)
487 self.num_subscribers = 0
A R Karthickb7e80902016-05-17 09:38:31 -0700488 return self.test_status
489
490 def test_subscriber_join_recv(self):
491 """Test subscriber join and receive"""
A R Karthick338268f2016-06-21 17:12:13 -0700492 self.num_subscribers = 5
493 self.num_channels = 1
494 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
495 num_channels = self.num_channels,
496 port_list = self.generate_port_list(self.num_subscribers,
497 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700498 assert_equal(test_status, True)
499
500 def test_subscriber_join_jump(self):
A.R Karthick95d044e2016-06-10 18:44:36 -0700501 """Test subscriber join and receive for channel surfing"""
A R Karthick338268f2016-06-21 17:12:13 -0700502 self.num_subscribers = 5
503 self.num_channels = 10
504 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
505 num_channels = self.num_channels,
A R Karthickb7e80902016-05-17 09:38:31 -0700506 cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify),
A R Karthick338268f2016-06-21 17:12:13 -0700507 port_list = self.generate_port_list(self.num_subscribers,
508 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700509 assert_equal(test_status, True)
510
511 def test_subscriber_join_next(self):
512 """Test subscriber join next for channels"""
A R Karthick338268f2016-06-21 17:12:13 -0700513 self.num_subscribers = 5
514 self.num_channels = 10
515 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
516 num_channels = self.num_channels,
A R Karthickb7e80902016-05-17 09:38:31 -0700517 cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify),
A R Karthick338268f2016-06-21 17:12:13 -0700518 port_list = self.generate_port_list(self.num_subscribers,
519 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700520 assert_equal(test_status, True)