Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 1 | import unittest |
| 2 | from nose.tools import * |
| 3 | from nose.twistedtools import reactor, deferred |
| 4 | from twisted.internet import defer |
| 5 | from scapy.all import * |
| 6 | import time, monotonic |
| 7 | import os, sys |
| 8 | import tempfile |
| 9 | import random |
| 10 | import threading |
| 11 | from Stats import Stats |
| 12 | from OnosCtrl import OnosCtrl |
| 13 | from DHCP import DHCPTest |
| 14 | from EapTLS import TLSAuthTest |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 15 | from Channels import Channels, IgmpChannel |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 16 | from subscriberDb import SubscriberDB |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 17 | from threadPool import ThreadPool |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 18 | from portmaps import g_subscriber_port_map |
| 19 | from portmaps import g_subscriber_reverse_port_map |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 20 | log.setLevel('INFO') |
| 21 | |
| 22 | class Subscriber(Channels): |
| 23 | |
| 24 | STATS_RX = 0 |
| 25 | STATS_TX = 1 |
| 26 | STATS_JOIN = 2 |
| 27 | STATS_LEAVE = 3 |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 28 | SUBSCRIBER_SERVICES = 'DHCP IGMP TLS' |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 29 | def __init__(self, name = 'sub', service = SUBSCRIBER_SERVICES, num = 1, channel_start = 0, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 30 | tx_port = 2, rx_port = 1, |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 31 | iface = 'veth0', iface_mcast = 'veth2', |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 32 | mcast_cb = None, loginType = 'wireless'): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 33 | self.tx_port = tx_port |
| 34 | self.rx_port = rx_port |
| 35 | self.tx_intf = g_subscriber_port_map[tx_port] |
| 36 | self.rx_intf = g_subscriber_port_map[rx_port] |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 37 | Channels.__init__(self, num, channel_start = channel_start, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 38 | iface = self.rx_intf, iface_mcast = self.tx_intf, mcast_cb = mcast_cb) |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 39 | self.name = name |
| 40 | self.service = service |
| 41 | self.service_map = {} |
| 42 | services = self.service.strip().split(' ') |
| 43 | for s in services: |
| 44 | self.service_map[s] = True |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 45 | self.loginType = loginType |
| 46 | ##start streaming channels |
| 47 | self.join_map = {} |
| 48 | ##accumulated join recv stats |
| 49 | self.join_rx_stats = Stats() |
| 50 | |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 51 | def has_service(self, service): |
| 52 | if self.service_map.has_key(service): |
| 53 | return self.service_map[service] |
| 54 | if self.service_map.has_key(service.upper()): |
| 55 | return self.service_map[service.upper()] |
| 56 | return False |
| 57 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 58 | def channel_join_update(self, chan, join_time): |
| 59 | self.join_map[chan] = ( Stats(), Stats(), Stats(), Stats() ) |
| 60 | self.channel_update(chan, self.STATS_JOIN, 1, t = join_time) |
| 61 | |
| 62 | def channel_join(self, chan = 0, delay = 2): |
| 63 | '''Join a channel and create a send/recv stats map''' |
| 64 | if self.join_map.has_key(chan): |
| 65 | del self.join_map[chan] |
| 66 | self.delay = delay |
| 67 | chan, join_time = self.join(chan) |
| 68 | self.channel_join_update(chan, join_time) |
| 69 | return chan |
| 70 | |
| 71 | def channel_join_next(self, delay = 2): |
| 72 | '''Joins the next channel leaving the last channel''' |
| 73 | if self.last_chan: |
| 74 | if self.join_map.has_key(self.last_chan): |
| 75 | del self.join_map[self.last_chan] |
| 76 | self.delay = delay |
| 77 | chan, join_time = self.join_next() |
| 78 | self.channel_join_update(chan, join_time) |
| 79 | return chan |
| 80 | |
| 81 | def channel_jump(self, delay = 2): |
| 82 | '''Jumps randomly to the next channel leaving the last channel''' |
| 83 | if self.last_chan is not None: |
| 84 | if self.join_map.has_key(self.last_chan): |
| 85 | del self.join_map[self.last_chan] |
| 86 | self.delay = delay |
| 87 | chan, join_time = self.jump() |
| 88 | self.channel_join_update(chan, join_time) |
| 89 | return chan |
| 90 | |
| 91 | def channel_leave(self, chan = 0): |
| 92 | if self.join_map.has_key(chan): |
| 93 | del self.join_map[chan] |
| 94 | self.leave(chan) |
| 95 | |
| 96 | def channel_update(self, chan, stats_type, packets, t=0): |
| 97 | if type(chan) == type(0): |
| 98 | chan_list = (chan,) |
| 99 | else: |
| 100 | chan_list = chan |
| 101 | for c in chan_list: |
| 102 | if self.join_map.has_key(c): |
| 103 | self.join_map[c][stats_type].update(packets = packets, t = t) |
| 104 | |
| 105 | def channel_receive(self, chan, cb = None, count = 1): |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 106 | log.info('Subscriber %s receiving from group %s, channel %d' %(self.name, self.gaddr(chan), chan)) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 107 | self.recv(chan, cb = cb, count = count) |
| 108 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 109 | def recv_channel_cb(self, pkt): |
| 110 | ##First verify that we have received the packet for the joined instance |
| 111 | log.debug('Packet received for group %s, subscriber %s' %(pkt[IP].dst, self.name)) |
| 112 | chan = self.caddr(pkt[IP].dst) |
| 113 | assert_equal(chan in self.join_map.keys(), True) |
| 114 | recv_time = monotonic.monotonic() * 1000000 |
| 115 | join_time = self.join_map[chan][self.STATS_JOIN].start |
| 116 | delta = recv_time - join_time |
| 117 | self.join_rx_stats.update(packets=1, t = delta, usecs = True) |
| 118 | self.channel_update(chan, self.STATS_RX, 1, t = delta) |
| 119 | log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst)) |
| 120 | |
| 121 | class subscriber_pool: |
| 122 | |
| 123 | def __init__(self, subscriber, test_cbs): |
| 124 | self.subscriber = subscriber |
| 125 | self.test_cbs = test_cbs |
| 126 | |
| 127 | def pool_cb(self): |
| 128 | for cb in self.test_cbs: |
| 129 | if cb: |
| 130 | cb(self.subscriber) |
| 131 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 132 | class subscriber_exchange(unittest.TestCase): |
| 133 | |
| 134 | apps = [ 'org.onosproject.aaa', 'org.onosproject.dhcp' ] |
| 135 | |
| 136 | dhcp_server_config = { |
| 137 | "ip": "10.1.11.50", |
| 138 | "mac": "ca:fe:ca:fe:ca:fe", |
| 139 | "subnet": "255.255.252.0", |
| 140 | "broadcast": "10.1.11.255", |
| 141 | "router": "10.1.8.1", |
| 142 | "domain": "8.8.8.8", |
| 143 | "ttl": "63", |
| 144 | "delay": "2", |
| 145 | "startip": "10.1.11.51", |
| 146 | "endip": "10.1.11.100" |
| 147 | } |
| 148 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 149 | aaa_loaded = False |
| 150 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 151 | def setUp(self): |
| 152 | ''' Activate the dhcp and igmp apps''' |
| 153 | for app in self.apps: |
| 154 | onos_ctrl = OnosCtrl(app) |
| 155 | status, _ = onos_ctrl.activate() |
| 156 | assert_equal(status, True) |
| 157 | time.sleep(2) |
| 158 | |
| 159 | def teardown(self): |
| 160 | '''Deactivate the dhcp app''' |
| 161 | for app in self.apps: |
| 162 | onos_ctrl = OnosCtrl(app) |
| 163 | onos_ctrl.deactivate() |
| 164 | |
| 165 | def onos_aaa_load(self): |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 166 | if self.aaa_loaded: |
| 167 | return |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 168 | aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password', |
| 169 | 'radiusIp': '172.17.0.2' } } } } |
| 170 | radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2' |
| 171 | aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip |
| 172 | self.onos_load_config('org.onosproject.aaa', aaa_dict) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 173 | self.aaa_loaded = True |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 174 | |
| 175 | def onos_dhcp_table_load(self, config = None): |
| 176 | dhcp_dict = {'apps' : { 'org.onosproject.dhcp' : { 'dhcp' : copy.copy(self.dhcp_server_config) } } } |
| 177 | dhcp_config = dhcp_dict['apps']['org.onosproject.dhcp']['dhcp'] |
| 178 | if config: |
| 179 | for k in config.keys(): |
| 180 | if dhcp_config.has_key(k): |
| 181 | dhcp_config[k] = config[k] |
| 182 | self.onos_load_config('org.onosproject.dhcp', dhcp_dict) |
| 183 | |
| 184 | def onos_load_config(self, app, config): |
| 185 | onos_ctrl = OnosCtrl(app) |
| 186 | status, code = onos_ctrl.config(config) |
| 187 | if status is False: |
| 188 | log.info('JSON config request for app %s returned status %d' %(app, code)) |
| 189 | assert_equal(status, True) |
| 190 | time.sleep(2) |
| 191 | |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 192 | def dhcp_sndrcv(self, dhcp, update_seed = False): |
| 193 | cip, sip = dhcp.discover(update_seed = update_seed) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 194 | assert_not_equal(cip, None) |
| 195 | assert_not_equal(sip, None) |
| 196 | log.info('Got dhcp client IP %s from server %s for mac %s' % |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 197 | (cip, sip, dhcp.get_mac(cip)[0])) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 198 | return cip,sip |
| 199 | |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 200 | def dhcp_request(self, subscriber, seed_ip = '10.10.10.1', update_seed = False): |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 201 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
| 202 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 203 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 204 | self.onos_dhcp_table_load(config) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 205 | dhcp = DHCPTest(seed_ip = seed_ip, iface = subscriber.iface) |
| 206 | cip, sip = self.dhcp_sndrcv(dhcp, update_seed = update_seed) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 207 | return cip, sip |
| 208 | |
| 209 | def recv_channel_cb(self, pkt): |
| 210 | ##First verify that we have received the packet for the joined instance |
| 211 | chan = self.subscriber.caddr(pkt[IP].dst) |
| 212 | assert_equal(chan in self.subscriber.join_map.keys(), True) |
| 213 | recv_time = monotonic.monotonic() * 1000000 |
| 214 | join_time = self.subscriber.join_map[chan][self.subscriber.STATS_JOIN].start |
| 215 | delta = recv_time - join_time |
| 216 | self.subscriber.join_rx_stats.update(packets=1, t = delta, usecs = True) |
| 217 | self.subscriber.channel_update(chan, self.subscriber.STATS_RX, 1, t = delta) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 218 | log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst)) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 219 | self.test_status = True |
| 220 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 221 | def tls_verify(self, subscriber): |
| 222 | if subscriber.has_service('TLS'): |
| 223 | time.sleep(2) |
| 224 | tls = TLSAuthTest() |
| 225 | log.info('Running subscriber %s tls auth test' %subscriber.name) |
| 226 | tls.runTest() |
| 227 | self.test_status = True |
| 228 | |
| 229 | def dhcp_verify(self, subscriber): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 230 | cip, sip = self.dhcp_request(subscriber, update_seed = True) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 231 | log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip)) |
| 232 | subscriber.src_list = [cip] |
| 233 | self.test_status = True |
| 234 | |
| 235 | def dhcp_jump_verify(self, subscriber): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 236 | cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.200.1') |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 237 | log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip)) |
| 238 | subscriber.src_list = [cip] |
| 239 | self.test_status = True |
| 240 | |
| 241 | def dhcp_next_verify(self, subscriber): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 242 | cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.150.1') |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 243 | log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip)) |
| 244 | subscriber.src_list = [cip] |
| 245 | self.test_status = True |
| 246 | |
| 247 | def igmp_verify(self, subscriber): |
| 248 | chan = 0 |
| 249 | if subscriber.has_service('IGMP'): |
| 250 | for i in range(5): |
| 251 | log.info('Joining channel %d for subscriber %s' %(chan, subscriber.name)) |
| 252 | subscriber.channel_join(chan, delay = 0) |
| 253 | subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1) |
| 254 | log.info('Leaving channel %d for subscriber %s' %(chan, subscriber.name)) |
| 255 | subscriber.channel_leave(chan) |
| 256 | time.sleep(3) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 257 | log.info('Interface %s Join RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name,subscriber.join_rx_stats)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 258 | self.test_status = True |
| 259 | |
| 260 | def igmp_jump_verify(self, subscriber): |
| 261 | if subscriber.has_service('IGMP'): |
| 262 | for i in xrange(subscriber.num): |
| 263 | log.info('Subscriber %s jumping channel' %subscriber.name) |
| 264 | chan = subscriber.channel_jump(delay=0) |
| 265 | subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1) |
| 266 | log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name)) |
| 267 | time.sleep(3) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 268 | log.info('Interface %s Jump RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 269 | self.test_status = True |
| 270 | |
| 271 | def igmp_next_verify(self, subscriber): |
| 272 | if subscriber.has_service('IGMP'): |
| 273 | for i in xrange(subscriber.num): |
| 274 | if i: |
| 275 | chan = subscriber.channel_join_next(delay=0) |
| 276 | else: |
| 277 | chan = subscriber.channel_join(i, delay=0) |
| 278 | log.info('Joined next channel %d for subscriber %s' %(chan, subscriber.name)) |
| 279 | subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count=1) |
| 280 | log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name)) |
| 281 | time.sleep(3) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 282 | log.info('Interface %s Join Next RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 283 | self.test_status = True |
| 284 | |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 285 | def generate_port_list(self, num): |
| 286 | port_list = [] |
| 287 | for i in xrange(num): |
| 288 | rx_port = 2*i+1 |
| 289 | tx_port = 2*i+2 |
| 290 | port_list.append((tx_port, rx_port)) |
| 291 | return port_list |
| 292 | |
| 293 | def subscriber_load(self, create = True, num = 10, num_channels = 1, channel_start = 0, port_list = []): |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 294 | '''Load the subscriber from the database''' |
| 295 | self.subscriber_db = SubscriberDB(create = create) |
| 296 | if create is True: |
| 297 | self.subscriber_db.generate(num) |
| 298 | self.subscriber_info = self.subscriber_db.read(num) |
| 299 | self.subscriber_list = [] |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 300 | if not port_list: |
| 301 | port_list = self.generate_port_list(num) |
| 302 | |
| 303 | index = 0 |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 304 | for info in self.subscriber_info: |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 305 | self.subscriber_list.append(Subscriber(name=info['Name'], |
| 306 | service=info['Service'], |
| 307 | num=num_channels, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 308 | channel_start = channel_start, |
| 309 | tx_port = port_list[index][0], |
| 310 | rx_port = port_list[index][1])) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 311 | channel_start += num_channels |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 312 | index += 1 |
| 313 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 314 | #load the ssm list for all subscriber channels |
| 315 | igmpChannel = IgmpChannel() |
| 316 | ssm_groups = map(lambda sub: sub.channels, self.subscriber_list) |
| 317 | ssm_list = reduce(lambda ssm1, ssm2: ssm1+ssm2, ssm_groups) |
| 318 | igmpChannel.igmp_load_ssm_config(ssm_list) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 319 | #load the subscriber to mcast port map for cord |
| 320 | cord_port_map = {} |
| 321 | for sub in self.subscriber_list: |
| 322 | for chan in sub.channels: |
| 323 | cord_port_map[chan] = (sub.tx_port, sub.rx_port) |
| 324 | |
| 325 | igmpChannel.cord_port_table_load(cord_port_map) |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 326 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 327 | def subscriber_join_verify( self, num_subscribers = 10, num_channels = 1, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 328 | channel_start = 0, cbs = None, port_list = []): |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 329 | self.test_status = False |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 330 | self.num_subscribers = num_subscribers |
| 331 | self.subscriber_load(create = True, num = self.num_subscribers, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 332 | num_channels = num_channels, channel_start = channel_start, port_list = port_list) |
Chetan Gaonker | 55fc788 | 2016-03-15 17:46:47 -0700 | [diff] [blame] | 333 | self.onos_aaa_load() |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 334 | self.thread_pool = ThreadPool(min(100, self.num_subscribers), queue_size=1, wait_timeout=1) |
| 335 | if cbs is None: |
| 336 | cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify) |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 337 | for subscriber in self.subscriber_list: |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 338 | subscriber.start() |
| 339 | pool_object = subscriber_pool(subscriber, cbs) |
| 340 | self.thread_pool.addTask(pool_object.pool_cb) |
| 341 | self.thread_pool.cleanUpThreads() |
| 342 | for subscriber in self.subscriber_list: |
| 343 | subscriber.stop() |
| 344 | return self.test_status |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 345 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 346 | def test_subscriber_join_recv(self): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 347 | """Test subscriber join and receive""" |
| 348 | num_subscribers = 50 |
| 349 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 350 | num_channels = 1, port_list = self.generate_port_list(num_subscribers)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 351 | assert_equal(test_status, True) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 352 | |
| 353 | def test_subscriber_join_jump(self): |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 354 | """Test subscriber join and receive for channel surfing""" |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 355 | num_subscribers = 5 |
| 356 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 357 | num_channels = 50, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 358 | cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify), |
| 359 | port_list = self.generate_port_list(num_subscribers)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 360 | assert_equal(test_status, True) |
Chetan Gaonker | 4b959fc | 2016-03-09 19:20:16 -0800 | [diff] [blame] | 361 | |
| 362 | def test_subscriber_join_next(self): |
| 363 | """Test subscriber join next for channels""" |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 364 | num_subscribers = 5 |
| 365 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 366 | num_channels = 50, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 367 | cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify), |
| 368 | port_list = self.generate_port_list(num_subscribers)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 369 | assert_equal(test_status, True) |