blob: a6eec2a4ff5ea2d170348a84b00fb0af07805ae6 [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
A R Karthick65c4d722016-07-18 14:20:17 -070012import requests
A R Karthickb7e80902016-05-17 09:38:31 -070013from Stats import Stats
14from OnosCtrl import OnosCtrl
15from DHCP import DHCPTest
16from EapTLS import TLSAuthTest
17from Channels import Channels, IgmpChannel
18from subscriberDb import SubscriberDB
19from threadPool import ThreadPool
A.R Karthick95d044e2016-06-10 18:44:36 -070020from portmaps import g_subscriber_port_map
A R Karthickb7e80902016-05-17 09:38:31 -070021from OltConfig import *
22from OnosFlowCtrl import get_mac
23from CordTestServer import cord_test_onos_restart
24
25log.setLevel('INFO')
26
27class Subscriber(Channels):
28 PORT_TX_DEFAULT = 2
29 PORT_RX_DEFAULT = 1
30 INTF_TX_DEFAULT = 'veth2'
31 INTF_RX_DEFAULT = 'veth0'
32 STATS_RX = 0
33 STATS_TX = 1
34 STATS_JOIN = 2
35 STATS_LEAVE = 3
36 SUBSCRIBER_SERVICES = 'DHCP IGMP TLS'
37 def __init__(self, name = 'sub', service = SUBSCRIBER_SERVICES, port_map = None,
38 num = 1, channel_start = 0,
39 tx_port = PORT_TX_DEFAULT, rx_port = PORT_RX_DEFAULT,
40 iface = INTF_RX_DEFAULT, iface_mcast = INTF_TX_DEFAULT,
41 mcast_cb = None, loginType = 'wireless'):
42 self.tx_port = tx_port
43 self.rx_port = rx_port
44 self.port_map = port_map or g_subscriber_port_map
45 try:
46 self.tx_intf = self.port_map[tx_port]
47 self.rx_intf = self.port_map[rx_port]
48 except:
49 self.tx_intf = self.port_map[self.PORT_TX_DEFAULT]
50 self.rx_intf = self.port_map[self.PORT_RX_DEFAULT]
51
A R Karthick338268f2016-06-21 17:12:13 -070052 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 -070053 Channels.__init__(self, num, channel_start = channel_start,
A R Karthickb7e80902016-05-17 09:38:31 -070054 iface = self.rx_intf, iface_mcast = self.tx_intf, mcast_cb = mcast_cb)
55 self.name = name
56 self.service = service
57 self.service_map = {}
58 services = self.service.strip().split(' ')
59 for s in services:
60 self.service_map[s] = True
61 self.loginType = loginType
62 ##start streaming channels
63 self.join_map = {}
64 ##accumulated join recv stats
65 self.join_rx_stats = Stats()
A R Karthick338268f2016-06-21 17:12:13 -070066 self.recv_timeout = False
A R Karthickb7e80902016-05-17 09:38:31 -070067
68 def has_service(self, service):
69 if self.service_map.has_key(service):
70 return self.service_map[service]
71 if self.service_map.has_key(service.upper()):
72 return self.service_map[service.upper()]
73 return False
74
75 def channel_join_update(self, chan, join_time):
76 self.join_map[chan] = ( Stats(), Stats(), Stats(), Stats() )
77 self.channel_update(chan, self.STATS_JOIN, 1, t = join_time)
78
79 def channel_join(self, chan = 0, delay = 2):
80 '''Join a channel and create a send/recv stats map'''
81 if self.join_map.has_key(chan):
82 del self.join_map[chan]
83 self.delay = delay
84 chan, join_time = self.join(chan)
85 self.channel_join_update(chan, join_time)
86 return chan
87
88 def channel_join_next(self, delay = 2):
89 '''Joins the next channel leaving the last channel'''
90 if self.last_chan:
91 if self.join_map.has_key(self.last_chan):
92 del self.join_map[self.last_chan]
93 self.delay = delay
94 chan, join_time = self.join_next()
95 self.channel_join_update(chan, join_time)
96 return chan
97
98 def channel_jump(self, delay = 2):
99 '''Jumps randomly to the next channel leaving the last channel'''
100 if self.last_chan is not None:
101 if self.join_map.has_key(self.last_chan):
102 del self.join_map[self.last_chan]
103 self.delay = delay
104 chan, join_time = self.jump()
105 self.channel_join_update(chan, join_time)
106 return chan
107
108 def channel_leave(self, chan = 0):
109 if self.join_map.has_key(chan):
110 del self.join_map[chan]
111 self.leave(chan)
112
113 def channel_update(self, chan, stats_type, packets, t=0):
114 if type(chan) == type(0):
115 chan_list = (chan,)
116 else:
117 chan_list = chan
A.R Karthick95d044e2016-06-10 18:44:36 -0700118 for c in chan_list:
A R Karthickb7e80902016-05-17 09:38:31 -0700119 if self.join_map.has_key(c):
120 self.join_map[c][stats_type].update(packets = packets, t = t)
121
A R Karthick338268f2016-06-21 17:12:13 -0700122 def channel_receive(self, chan, cb = None, count = 1, timeout = 5):
123 log.info('Subscriber %s on port %s receiving from group %s, channel %d' %
124 (self.name, self.rx_intf, self.gaddr(chan), chan))
125 r = self.recv(chan, cb = cb, count = count, timeout = timeout)
126 if self.recv_timeout:
127 ##Negative test case is disabled for now
128 assert_equal(len(r), 0)
A R Karthickb7e80902016-05-17 09:38:31 -0700129
130 def recv_channel_cb(self, pkt):
131 ##First verify that we have received the packet for the joined instance
A R Karthick338268f2016-06-21 17:12:13 -0700132 log.info('Packet received for group %s, subscriber %s, port %s' %
133 (pkt[IP].dst, self.name, self.rx_intf))
134 if self.recv_timeout:
135 return
A R Karthickb7e80902016-05-17 09:38:31 -0700136 chan = self.caddr(pkt[IP].dst)
137 assert_equal(chan in self.join_map.keys(), True)
138 recv_time = monotonic.monotonic() * 1000000
139 join_time = self.join_map[chan][self.STATS_JOIN].start
140 delta = recv_time - join_time
141 self.join_rx_stats.update(packets=1, t = delta, usecs = True)
142 self.channel_update(chan, self.STATS_RX, 1, t = delta)
143 log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst))
144
145class subscriber_pool:
146
147 def __init__(self, subscriber, test_cbs):
148 self.subscriber = subscriber
149 self.test_cbs = test_cbs
150
151 def pool_cb(self):
152 for cb in self.test_cbs:
153 if cb:
154 cb(self.subscriber)
A.R Karthick95d044e2016-06-10 18:44:36 -0700155
A R Karthickb7e80902016-05-17 09:38:31 -0700156class subscriber_exchange(unittest.TestCase):
157
A.R Karthick95d044e2016-06-10 18:44:36 -0700158 apps = ('org.opencord.aaa', 'org.onosproject.dhcp')
159 olt_apps = () #'org.opencord.cordmcast')
A R Karthickb7e80902016-05-17 09:38:31 -0700160 table_app = 'org.ciena.cordigmp'
161 dhcp_server_config = {
162 "ip": "10.1.11.50",
163 "mac": "ca:fe:ca:fe:ca:fe",
164 "subnet": "255.255.252.0",
165 "broadcast": "10.1.11.255",
166 "router": "10.1.8.1",
167 "domain": "8.8.8.8",
168 "ttl": "63",
169 "delay": "2",
170 "startip": "10.1.11.51",
171 "endip": "10.1.11.100"
172 }
173
174 aaa_loaded = False
175 test_path = os.path.dirname(os.path.realpath(__file__))
A R Karthick4b72d4b2016-06-15 11:09:17 -0700176 table_app_file = os.path.join(test_path, '..', 'apps/ciena-cordigmp-multitable-2.0-SNAPSHOT.oar')
177 app_file = os.path.join(test_path, '..', 'apps/ciena-cordigmp-2.0-SNAPSHOT.oar')
A R Karthickb7e80902016-05-17 09:38:31 -0700178 onos_config_path = os.path.join(test_path, '..', 'setup/onos-config')
179 olt_conf_file = os.path.join(test_path, '..', 'setup/olt_config_multitable.json')
180 cpqd_path = os.path.join(test_path, '..', 'setup')
181 ovs_path = cpqd_path
182 device_id = 'of:' + get_mac('ovsbr0')
A R Karthick4b72d4b2016-06-15 11:09:17 -0700183 device_dict = { "devices" : {
A R Karthickb7e80902016-05-17 09:38:31 -0700184 "{}".format(device_id) : {
185 "basic" : {
A R Karthick4b72d4b2016-06-15 11:09:17 -0700186 "driver" : "pmc-olt"
A R Karthickb7e80902016-05-17 09:38:31 -0700187 }
188 }
189 },
190 }
A R Karthick65c4d722016-07-18 14:20:17 -0700191 test_services = ('IGMP', 'TRAFFIC')
A R Karthick338268f2016-06-21 17:12:13 -0700192 num_joins = 0
193 num_subscribers = 0
194 num_channels = 0
195 recv_timeout = False
A R Karthickb7e80902016-05-17 09:38:31 -0700196
197 @classmethod
198 def setUpClass(cls):
199 '''Load the OLT config and activate relevant apps'''
A R Karthick4b72d4b2016-06-15 11:09:17 -0700200 network_cfg = { "devices" : {
A R Karthicke0f33fa2016-06-22 13:36:02 -0700201 "{}".format(cls.device_id) : {
A R Karthick4b72d4b2016-06-15 11:09:17 -0700202 "basic" : {
203 "driver" : "pmc-olt"
204 }
205 }
206 },
207 }
A R Karthick4b72d4b2016-06-15 11:09:17 -0700208 ## Restart ONOS with cpqd driver config for OVS
209 cls.start_onos(network_cfg = network_cfg)
A R Karthickb7e80902016-05-17 09:38:31 -0700210 cls.install_app_table()
A R Karthickb7e80902016-05-17 09:38:31 -0700211 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
212 OnosCtrl.cord_olt_config(cls.olt.olt_device_data())
213 cls.port_map, cls.port_list = cls.olt.olt_port_map_multi()
214 cls.activate_apps(cls.apps + cls.olt_apps)
215
216 @classmethod
217 def tearDownClass(cls):
218 '''Deactivate the olt apps and restart OVS back'''
219 apps = cls.olt_apps + ( cls.table_app,)
220 for app in apps:
221 onos_ctrl = OnosCtrl(app)
222 onos_ctrl.deactivate()
223 cls.uninstall_app_table()
A R Karthicke0f33fa2016-06-22 13:36:02 -0700224 cls.start_onos(network_cfg = {})
A R Karthickb7e80902016-05-17 09:38:31 -0700225
226 @classmethod
227 def activate_apps(cls, apps):
228 for app in apps:
229 onos_ctrl = OnosCtrl(app)
230 status, _ = onos_ctrl.activate()
231 assert_equal(status, True)
232 time.sleep(2)
233
234 @classmethod
235 def install_app_table(cls):
236 ##Uninstall the existing app if any
237 OnosCtrl.uninstall_app(cls.table_app)
238 time.sleep(2)
239 log.info('Installing the multi table app %s for subscriber test' %(cls.table_app_file))
240 OnosCtrl.install_app(cls.table_app_file)
241 time.sleep(3)
242
243 @classmethod
244 def uninstall_app_table(cls):
245 ##Uninstall the table app on class exit
246 OnosCtrl.uninstall_app(cls.table_app)
247 time.sleep(2)
248 log.info('Installing back the cord igmp app %s for subscriber test on exit' %(cls.app_file))
249 OnosCtrl.install_app(cls.app_file)
250
251 @classmethod
252 def start_onos(cls, network_cfg = None):
A R Karthick65c4d722016-07-18 14:20:17 -0700253 v = bool(int(os.getenv('ONOS_RESTART_DISABLED', 0)))
254 if v:
255 log.info('ONOS restart is disabled. Skipping ONOS restart')
256 return
A R Karthickb7e80902016-05-17 09:38:31 -0700257 if network_cfg is None:
A R Karthick4b72d4b2016-06-15 11:09:17 -0700258 network_cfg = cls.device_dict
A R Karthickb7e80902016-05-17 09:38:31 -0700259
260 if type(network_cfg) is tuple:
261 res = []
262 for v in network_cfg:
263 res += v.items()
264 config = dict(res)
265 else:
266 config = network_cfg
267 log.info('Restarting ONOS with new network configuration')
A R Karthick338268f2016-06-21 17:12:13 -0700268 return cord_test_onos_restart(config = config)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700269
270 @classmethod
271 def remove_onos_config(cls):
272 try:
273 os.unlink('{}/network-cfg.json'.format(cls.onos_config_path))
274 except: pass
A R Karthickb7e80902016-05-17 09:38:31 -0700275
276 @classmethod
277 def start_cpqd(cls, mac = '00:11:22:33:44:55'):
278 dpid = mac.replace(':', '')
279 cpqd_file = os.sep.join( (cls.cpqd_path, 'cpqd.sh') )
280 cpqd_cmd = '{} {}'.format(cpqd_file, dpid)
281 ret = os.system(cpqd_cmd)
282 assert_equal(ret, 0)
283 time.sleep(10)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700284 device_id = 'of:{}{}'.format('0'*4, dpid)
285 return device_id
A R Karthickb7e80902016-05-17 09:38:31 -0700286
287 @classmethod
288 def start_ovs(cls):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700289 ovs_file = os.sep.join( (cls.ovs_path, 'of-bridge.sh') )
A R Karthickb7e80902016-05-17 09:38:31 -0700290 ret = os.system(ovs_file)
291 assert_equal(ret, 0)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700292 time.sleep(30)
A R Karthickb7e80902016-05-17 09:38:31 -0700293
294 def onos_aaa_load(self):
295 if self.aaa_loaded:
296 return
A.R Karthick95d044e2016-06-10 18:44:36 -0700297 aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password',
A R Karthickb7e80902016-05-17 09:38:31 -0700298 'radiusIp': '172.17.0.2' } } } }
299 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
300 aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip
301 self.onos_load_config('org.onosproject.aaa', aaa_dict)
302 self.aaa_loaded = True
303
304 def onos_dhcp_table_load(self, config = None):
305 dhcp_dict = {'apps' : { 'org.onosproject.dhcp' : { 'dhcp' : copy.copy(self.dhcp_server_config) } } }
306 dhcp_config = dhcp_dict['apps']['org.onosproject.dhcp']['dhcp']
307 if config:
308 for k in config.keys():
309 if dhcp_config.has_key(k):
310 dhcp_config[k] = config[k]
311 self.onos_load_config('org.onosproject.dhcp', dhcp_dict)
312
313 def onos_load_config(self, app, config):
314 status, code = OnosCtrl.config(config)
315 if status is False:
316 log.info('JSON config request for app %s returned status %d' %(app, code))
317 assert_equal(status, True)
318 time.sleep(2)
319
320 def dhcp_sndrcv(self, dhcp, update_seed = False):
321 cip, sip = dhcp.discover(update_seed = update_seed)
322 assert_not_equal(cip, None)
323 assert_not_equal(sip, None)
324 log.info('Got dhcp client IP %s from server %s for mac %s' %
325 (cip, sip, dhcp.get_mac(cip)[0]))
326 return cip,sip
327
328 def dhcp_request(self, subscriber, seed_ip = '10.10.10.1', update_seed = False):
329 config = {'startip':'10.10.10.20', 'endip':'10.10.10.200',
330 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe",
331 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'}
332 self.onos_dhcp_table_load(config)
333 dhcp = DHCPTest(seed_ip = seed_ip, iface = subscriber.iface)
334 cip, sip = self.dhcp_sndrcv(dhcp, update_seed = update_seed)
335 return cip, sip
336
337 def recv_channel_cb(self, pkt):
338 ##First verify that we have received the packet for the joined instance
339 chan = self.subscriber.caddr(pkt[IP].dst)
340 assert_equal(chan in self.subscriber.join_map.keys(), True)
341 recv_time = monotonic.monotonic() * 1000000
342 join_time = self.subscriber.join_map[chan][self.subscriber.STATS_JOIN].start
343 delta = recv_time - join_time
344 self.subscriber.join_rx_stats.update(packets=1, t = delta, usecs = True)
345 self.subscriber.channel_update(chan, self.subscriber.STATS_RX, 1, t = delta)
346 log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst))
347 self.test_status = True
348
A R Karthick65c4d722016-07-18 14:20:17 -0700349 def traffic_verify(self, subscriber):
350 if subscriber.has_service('TRAFFIC'):
351 url = 'http://www.google.com'
352 resp = requests.get(url)
353 self.test_status = resp.ok
354 if resp.ok == False:
355 log.info('Subscriber %s failed get from url %s with status code %d'
356 %(subscriber.name, url, resp.status_code))
357 else:
358 log.info('GET request from %s succeeded for subscriber %s'
359 %(url, subscriber.name))
360
A R Karthickb7e80902016-05-17 09:38:31 -0700361 def tls_verify(self, subscriber):
362 if subscriber.has_service('TLS'):
363 time.sleep(2)
A R Karthick4b72d4b2016-06-15 11:09:17 -0700364 tls = TLSAuthTest(intf = subscriber.rx_intf)
A R Karthickb7e80902016-05-17 09:38:31 -0700365 log.info('Running subscriber %s tls auth test' %subscriber.name)
366 tls.runTest()
367 self.test_status = True
368
369 def dhcp_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700370 if subscriber.has_service('DHCP'):
371 cip, sip = self.dhcp_request(subscriber, update_seed = True)
372 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
373 subscriber.src_list = [cip]
374 self.test_status = True
375 else:
376 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
377 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700378
379 def dhcp_jump_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700380 if subscriber.has_service('DHCP'):
381 cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.200.1')
382 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
383 subscriber.src_list = [cip]
384 self.test_status = True
385 else:
386 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
387 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700388
389 def dhcp_next_verify(self, subscriber):
A R Karthick4b72d4b2016-06-15 11:09:17 -0700390 if subscriber.has_service('DHCP'):
391 cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.150.1')
392 log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
393 subscriber.src_list = [cip]
394 self.test_status = True
395 else:
396 subscriber.src_list = ['10.10.10.{}'.format(subscriber.rx_port)]
397 self.test_status = True
A R Karthickb7e80902016-05-17 09:38:31 -0700398
399 def igmp_verify(self, subscriber):
400 chan = 0
401 if subscriber.has_service('IGMP'):
A R Karthick338268f2016-06-21 17:12:13 -0700402 ##We wait for all the subscribers to join before triggering leaves
403 if subscriber.rx_port > 1:
404 time.sleep(5)
405 subscriber.channel_join(chan, delay = 0)
406 self.num_joins += 1
407 while self.num_joins < self.num_subscribers:
408 time.sleep(5)
409 log.info('All subscribers have joined the channel')
410 for i in range(10):
411 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 10)
A R Karthickb7e80902016-05-17 09:38:31 -0700412 log.info('Leaving channel %d for subscriber %s' %(chan, subscriber.name))
413 subscriber.channel_leave(chan)
A R Karthick338268f2016-06-21 17:12:13 -0700414 time.sleep(5)
A R Karthickb7e80902016-05-17 09:38:31 -0700415 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 -0700416 #Should not receive packets for this subscriber
417 self.recv_timeout = True
418 subscriber.recv_timeout = True
419 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 10)
420 subscriber.recv_timeout = False
421 self.recv_timeout = False
422 log.info('Joining channel %d for subscriber %s' %(chan, subscriber.name))
423 subscriber.channel_join(chan, delay = 0)
A R Karthickb7e80902016-05-17 09:38:31 -0700424 self.test_status = True
425
426 def igmp_jump_verify(self, subscriber):
427 if subscriber.has_service('IGMP'):
428 for i in xrange(subscriber.num):
429 log.info('Subscriber %s jumping channel' %subscriber.name)
430 chan = subscriber.channel_jump(delay=0)
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 Jump RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats))
435 self.test_status = True
436
437 def igmp_next_verify(self, subscriber):
438 if subscriber.has_service('IGMP'):
439 for i in xrange(subscriber.num):
440 if i:
441 chan = subscriber.channel_join_next(delay=0)
442 else:
443 chan = subscriber.channel_join(i, delay=0)
444 log.info('Joined next channel %d for subscriber %s' %(chan, subscriber.name))
445 subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count=1)
446 log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name))
447 time.sleep(3)
448 log.info('Interface %s Join Next RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats))
449 self.test_status = True
450
451 def generate_port_list(self, subscribers, channels):
452 return self.port_list[:subscribers]
453
454 def subscriber_load(self, create = True, num = 10, num_channels = 1, channel_start = 0, port_list = []):
455 '''Load the subscriber from the database'''
A R Karthick4b72d4b2016-06-15 11:09:17 -0700456 self.subscriber_db = SubscriberDB(create = create, services = self.test_services)
A R Karthickb7e80902016-05-17 09:38:31 -0700457 if create is True:
458 self.subscriber_db.generate(num)
459 self.subscriber_info = self.subscriber_db.read(num)
460 self.subscriber_list = []
461 if not port_list:
462 port_list = self.generate_port_list(num, num_channels)
463
464 index = 0
465 for info in self.subscriber_info:
A.R Karthick95d044e2016-06-10 18:44:36 -0700466 self.subscriber_list.append(Subscriber(name=info['Name'],
A R Karthickb7e80902016-05-17 09:38:31 -0700467 service=info['Service'],
468 port_map = self.port_map,
469 num=num_channels,
470 channel_start = channel_start,
471 tx_port = port_list[index][0],
472 rx_port = port_list[index][1]))
473 if num_channels > 1:
474 channel_start += num_channels
475 index += 1
476
477 #load the ssm list for all subscriber channels
478 igmpChannel = IgmpChannel()
479 ssm_groups = map(lambda sub: sub.channels, self.subscriber_list)
480 ssm_list = reduce(lambda ssm1, ssm2: ssm1+ssm2, ssm_groups)
481 igmpChannel.igmp_load_ssm_config(ssm_list)
482
A.R Karthick95d044e2016-06-10 18:44:36 -0700483 def subscriber_join_verify( self, num_subscribers = 10, num_channels = 1,
A R Karthickb7e80902016-05-17 09:38:31 -0700484 channel_start = 0, cbs = None, port_list = []):
485 self.test_status = False
486 self.num_subscribers = num_subscribers
487 self.subscriber_load(create = True, num = num_subscribers,
488 num_channels = num_channels, channel_start = channel_start, port_list = port_list)
489 self.onos_aaa_load()
490 self.thread_pool = ThreadPool(min(100, self.num_subscribers), queue_size=1, wait_timeout=1)
A R Karthick338268f2016-06-21 17:12:13 -0700491 chan_leave = False #for single channel, multiple subscribers
A R Karthickb7e80902016-05-17 09:38:31 -0700492 if cbs is None:
A R Karthick65c4d722016-07-18 14:20:17 -0700493 cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify, self.traffic_verify)
A R Karthick338268f2016-06-21 17:12:13 -0700494 chan_leave = True
A R Karthickb7e80902016-05-17 09:38:31 -0700495 for subscriber in self.subscriber_list:
496 subscriber.start()
497 pool_object = subscriber_pool(subscriber, cbs)
498 self.thread_pool.addTask(pool_object.pool_cb)
499 self.thread_pool.cleanUpThreads()
500 for subscriber in self.subscriber_list:
501 subscriber.stop()
A R Karthick338268f2016-06-21 17:12:13 -0700502 if chan_leave is True:
503 subscriber.channel_leave(0)
504 self.num_subscribers = 0
A R Karthickb7e80902016-05-17 09:38:31 -0700505 return self.test_status
506
507 def test_subscriber_join_recv(self):
ChetanGaonkerf9c2f8b2016-07-19 15:49:41 -0700508 """Test subscriber join and receive for channel surfing"""
A R Karthick338268f2016-06-21 17:12:13 -0700509 self.num_subscribers = 5
510 self.num_channels = 1
511 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
512 num_channels = self.num_channels,
513 port_list = self.generate_port_list(self.num_subscribers,
514 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700515 assert_equal(test_status, True)
516
517 def test_subscriber_join_jump(self):
A.R Karthick95d044e2016-06-10 18:44:36 -0700518 """Test subscriber join and receive for channel surfing"""
A R Karthick338268f2016-06-21 17:12:13 -0700519 self.num_subscribers = 5
520 self.num_channels = 10
521 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
522 num_channels = self.num_channels,
A R Karthick65c4d722016-07-18 14:20:17 -0700523 cbs = (self.tls_verify, self.dhcp_jump_verify,
524 self.igmp_jump_verify, self.traffic_verify),
A R Karthick338268f2016-06-21 17:12:13 -0700525 port_list = self.generate_port_list(self.num_subscribers,
526 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700527 assert_equal(test_status, True)
528
529 def test_subscriber_join_next(self):
ChetanGaonkerf9c2f8b2016-07-19 15:49:41 -0700530 """Test subscriber join next for channel surfing"""
A R Karthick338268f2016-06-21 17:12:13 -0700531 self.num_subscribers = 5
532 self.num_channels = 10
533 test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
534 num_channels = self.num_channels,
A R Karthick65c4d722016-07-18 14:20:17 -0700535 cbs = (self.tls_verify, self.dhcp_next_verify,
536 self.igmp_next_verify, self.traffic_verify),
A R Karthick338268f2016-06-21 17:12:13 -0700537 port_list = self.generate_port_list(self.num_subscribers,
538 self.num_channels))
A R Karthickb7e80902016-05-17 09:38:31 -0700539 assert_equal(test_status, True)