ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 1 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 2 | # Copyright 2016-present Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 7 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 9 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 16 | import unittest |
| 17 | from nose.tools import * |
| 18 | from nose.twistedtools import reactor, deferred |
| 19 | from twisted.internet import defer |
| 20 | from scapy.all import * |
| 21 | import time, monotonic |
| 22 | import os, sys |
| 23 | import tempfile |
| 24 | import random |
| 25 | import threading |
| 26 | from Stats import Stats |
| 27 | from OnosCtrl import OnosCtrl |
| 28 | from DHCP import DHCPTest |
| 29 | from EapTLS import TLSAuthTest |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 30 | from Channels import Channels, IgmpChannel |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 31 | from subscriberDb import SubscriberDB |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 32 | from threadPool import ThreadPool |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 33 | from portmaps import g_subscriber_port_map |
Chetan Gaonker | 7997bb4 | 2016-03-28 09:46:15 -0700 | [diff] [blame] | 34 | from OltConfig import * |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 35 | from CordContainer import * |
| 36 | import copy |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 37 | log.setLevel('INFO') |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 38 | DEFAULT_NO_CHANNELS = 1 |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 39 | |
| 40 | class Subscriber(Channels): |
Chetan Gaonker | 7997bb4 | 2016-03-28 09:46:15 -0700 | [diff] [blame] | 41 | PORT_TX_DEFAULT = 2 |
| 42 | PORT_RX_DEFAULT = 1 |
| 43 | INTF_TX_DEFAULT = 'veth2' |
| 44 | INTF_RX_DEFAULT = 'veth0' |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 45 | STATS_RX = 0 |
| 46 | STATS_TX = 1 |
| 47 | STATS_JOIN = 2 |
| 48 | STATS_LEAVE = 3 |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 49 | SUBSCRIBER_SERVICES = 'DHCP IGMP TLS' |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 50 | |
| 51 | |
Chetan Gaonker | 7997bb4 | 2016-03-28 09:46:15 -0700 | [diff] [blame] | 52 | def __init__(self, name = 'sub', service = SUBSCRIBER_SERVICES, port_map = None, |
| 53 | num = 1, channel_start = 0, |
| 54 | tx_port = PORT_TX_DEFAULT, rx_port = PORT_RX_DEFAULT, |
| 55 | iface = INTF_RX_DEFAULT, iface_mcast = INTF_TX_DEFAULT, |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 56 | mcast_cb = None, loginType = 'wireless'): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 57 | self.tx_port = tx_port |
| 58 | self.rx_port = rx_port |
Chetan Gaonker | 7997bb4 | 2016-03-28 09:46:15 -0700 | [diff] [blame] | 59 | self.port_map = port_map or g_subscriber_port_map |
| 60 | try: |
| 61 | self.tx_intf = self.port_map[tx_port] |
| 62 | self.rx_intf = self.port_map[rx_port] |
| 63 | except: |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 64 | self.tx_intf = self.port_map[self.PORT_TX_DEFAULT] |
| 65 | self.rx_intf = self.port_map[self.PORT_RX_DEFAULT] |
Chetan Gaonker | 7997bb4 | 2016-03-28 09:46:15 -0700 | [diff] [blame] | 66 | |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 67 | Channels.__init__(self, num, channel_start = channel_start, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 68 | 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] | 69 | self.name = name |
| 70 | self.service = service |
| 71 | self.service_map = {} |
| 72 | services = self.service.strip().split(' ') |
| 73 | for s in services: |
| 74 | self.service_map[s] = True |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 75 | self.loginType = loginType |
| 76 | ##start streaming channels |
| 77 | self.join_map = {} |
| 78 | ##accumulated join recv stats |
| 79 | self.join_rx_stats = Stats() |
| 80 | |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 81 | def has_service(self, service): |
| 82 | if self.service_map.has_key(service): |
| 83 | return self.service_map[service] |
| 84 | if self.service_map.has_key(service.upper()): |
| 85 | return self.service_map[service.upper()] |
| 86 | return False |
| 87 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 88 | def channel_join_update(self, chan, join_time): |
| 89 | self.join_map[chan] = ( Stats(), Stats(), Stats(), Stats() ) |
| 90 | self.channel_update(chan, self.STATS_JOIN, 1, t = join_time) |
| 91 | |
| 92 | def channel_join(self, chan = 0, delay = 2): |
| 93 | '''Join a channel and create a send/recv stats map''' |
| 94 | if self.join_map.has_key(chan): |
| 95 | del self.join_map[chan] |
| 96 | self.delay = delay |
| 97 | chan, join_time = self.join(chan) |
| 98 | self.channel_join_update(chan, join_time) |
| 99 | return chan |
| 100 | |
| 101 | def channel_join_next(self, delay = 2): |
| 102 | '''Joins the next channel leaving the last channel''' |
| 103 | if self.last_chan: |
| 104 | if self.join_map.has_key(self.last_chan): |
| 105 | del self.join_map[self.last_chan] |
| 106 | self.delay = delay |
| 107 | chan, join_time = self.join_next() |
| 108 | self.channel_join_update(chan, join_time) |
| 109 | return chan |
| 110 | |
| 111 | def channel_jump(self, delay = 2): |
| 112 | '''Jumps randomly to the next channel leaving the last channel''' |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 113 | log.info("Jumps randomly to the next channel leaving the last channel") |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 114 | if self.last_chan is not None: |
| 115 | if self.join_map.has_key(self.last_chan): |
| 116 | del self.join_map[self.last_chan] |
| 117 | self.delay = delay |
| 118 | chan, join_time = self.jump() |
| 119 | self.channel_join_update(chan, join_time) |
| 120 | return chan |
| 121 | |
| 122 | def channel_leave(self, chan = 0): |
| 123 | if self.join_map.has_key(chan): |
| 124 | del self.join_map[chan] |
| 125 | self.leave(chan) |
| 126 | |
| 127 | def channel_update(self, chan, stats_type, packets, t=0): |
| 128 | if type(chan) == type(0): |
| 129 | chan_list = (chan,) |
| 130 | else: |
| 131 | chan_list = chan |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 132 | for c in chan_list: |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 133 | if self.join_map.has_key(c): |
| 134 | self.join_map[c][stats_type].update(packets = packets, t = t) |
| 135 | |
| 136 | def channel_receive(self, chan, cb = None, count = 1): |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 137 | 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] | 138 | self.recv(chan, cb = cb, count = count) |
| 139 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 140 | def recv_channel_cb(self, pkt): |
| 141 | ##First verify that we have received the packet for the joined instance |
| 142 | log.debug('Packet received for group %s, subscriber %s' %(pkt[IP].dst, self.name)) |
| 143 | chan = self.caddr(pkt[IP].dst) |
| 144 | assert_equal(chan in self.join_map.keys(), True) |
| 145 | recv_time = monotonic.monotonic() * 1000000 |
| 146 | join_time = self.join_map[chan][self.STATS_JOIN].start |
| 147 | delta = recv_time - join_time |
| 148 | self.join_rx_stats.update(packets=1, t = delta, usecs = True) |
| 149 | self.channel_update(chan, self.STATS_RX, 1, t = delta) |
| 150 | log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst)) |
| 151 | |
| 152 | class subscriber_pool: |
| 153 | |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 154 | def __init__(self, subscriber, test_cbs, test_status): |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 155 | self.subscriber = subscriber |
| 156 | self.test_cbs = test_cbs |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 157 | self.test_status = test_status |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 158 | |
| 159 | def pool_cb(self): |
| 160 | for cb in self.test_cbs: |
| 161 | if cb: |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 162 | self.test_status = cb(self.subscriber) |
| 163 | # cb(self.subscriber) |
| 164 | if self.test_status is not True: |
| 165 | log.info('This service is failed and other services will not run for this subscriber') |
| 166 | break |
| 167 | log.info('This Subscriber is tested for multiple service elgibility ') |
| 168 | self.test_status = True |
| 169 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 170 | class subscriber_exchange(unittest.TestCase): |
| 171 | |
| 172 | apps = [ 'org.onosproject.aaa', 'org.onosproject.dhcp' ] |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 173 | |
| 174 | dhcp_app = 'org.onosproject.dhcp' |
| 175 | |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 176 | olt_apps = [ 'org.onosproject.igmp', 'org.onosproject.cordmcast' ] |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 177 | dhcp_server_config = { |
| 178 | "ip": "10.1.11.50", |
| 179 | "mac": "ca:fe:ca:fe:ca:fe", |
| 180 | "subnet": "255.255.252.0", |
| 181 | "broadcast": "10.1.11.255", |
| 182 | "router": "10.1.8.1", |
| 183 | "domain": "8.8.8.8", |
| 184 | "ttl": "63", |
| 185 | "delay": "2", |
| 186 | "startip": "10.1.11.51", |
| 187 | "endip": "10.1.11.100" |
| 188 | } |
| 189 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 190 | aaa_loaded = False |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 191 | INTF_TX_DEFAULT = 'veth2' |
| 192 | INTF_RX_DEFAULT = 'veth0' |
| 193 | SUBSCRIBER_TIMEOUT = 20 |
| 194 | |
| 195 | CLIENT_CERT = """-----BEGIN CERTIFICATE----- |
| 196 | MIICuDCCAiGgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx |
| 197 | CzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5h |
| 198 | IEluYy4xHjAcBgkqhkiG9w0BCQEWD2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMd |
| 199 | RXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwNjA2MjExMjI3WhcN |
| 200 | MTcwNjAxMjExMjI3WjBnMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNV |
| 201 | BAoTCkNpZW5hIEluYy4xFzAVBgNVBAMUDnVzZXJAY2llbmEuY29tMR0wGwYJKoZI |
| 202 | hvcNAQkBFg51c2VyQGNpZW5hLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC |
| 203 | gYEAwvXiSzb9LZ6c7uNziUfKvoHO7wu/uiFC5YUpXbmVGuGZizbVrny0xnR85Dfe |
| 204 | +9R4diansfDhIhzOUl1XjN3YDeSS9OeF5YWNNE8XDhlz2d3rVzaN6hIhdotBkUjg |
| 205 | rUewjTg5OFR31QEyG3v8xR3CLgiE9xQELjZbSA07pD79zuUCAwEAAaNPME0wEwYD |
| 206 | VR0lBAwwCgYIKwYBBQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5l |
| 207 | eGFtcGxlLmNvbS9leGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOBgQDAjkrY |
| 208 | 6tDChmKbvr8w6Du/t8vHjTCoCIocHTN0qzWOeb1YsAGX89+TrWIuO1dFyYd+Z0KC |
| 209 | PDKB5j/ygml9Na+AklSYAVJIjvlzXKZrOaPmhZqDufi+rXWti/utVqY4VMW2+HKC |
| 210 | nXp37qWeuFLGyR1519Y1d6F/5XzqmvbwURuEug== |
| 211 | -----END CERTIFICATE-----""" |
| 212 | |
| 213 | CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE----- |
| 214 | MIIDvTCCAqWgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx |
| 215 | CzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5h |
| 216 | IEluYy4xHjAcBgkqhkiG9w0BCQEWD2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMd |
| 217 | RXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwMzExMTg1MzM2WhcN |
| 218 | MTcwMzA2MTg1MzM2WjBnMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNV |
| 219 | BAoTCkNpZW5hIEluYy4xFzAVBgNVBAMUDnVzZXJAY2llbmEuY29tMR0wGwYJKoZI |
| 220 | hvcNAQkBFg51c2VyQGNpZW5hLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC |
| 221 | AQoCggEBAOxemcBsPn9tZsCa5o2JA6sQDC7A6JgCNXXl2VFzKLNNvB9PS6D7ZBsQ |
| 222 | 5An0zEDMNzi51q7lnrYg1XyiE4S8FzMGAFr94RlGMQJUbRD9V/oqszMX4k++iAOK |
| 223 | tIA1gr3x7Zi+0tkjVSVzXTmgNnhChAamdMsjYUG5+CY9WAicXyy+VEV3zTphZZDR |
| 224 | OjcjEp4m/TSXVPYPgYDXI40YZKX5BdvqykWtT/tIgZb48RS1NPyN/XkCYzl3bv21 |
| 225 | qx7Mc0fcEbsJBIIRYTUkfxnsilcnmLxSYO+p+DZ9uBLBzcQt+4Rd5pLSfi21WM39 |
| 226 | 2Z2oOi3vs/OYAPAqgmi2JWOv3mePa/8CAwEAAaNPME0wEwYDVR0lBAwwCgYIKwYB |
| 227 | BQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5leGFtcGxlLmNvbS9l |
| 228 | eGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOCAQEALBzMPDTIB6sLyPl0T6JV |
| 229 | MjOkyldAVhXWiQsTjaGQGJUUe1cmUJyZbUZEc13MygXMPOM4x7z6VpXGuq1c/Vxn |
| 230 | VzQ2fNnbJcIAHi/7G8W5/SQfPesIVDsHTEc4ZspPi5jlS/MVX3HOC+BDbOjdbwqP |
| 231 | RX0JEr+uOyhjO+lRxG8ilMRACoBUbw1eDuVDoEBgErSUC44pq5ioDw2xelc+Y6hQ |
| 232 | dmtYwfY0DbvwxHtA495frLyPcastDiT/zre7NL51MyUDPjjYjghNQEwvu66IKbQ3 |
| 233 | T1tJBrgI7/WI+dqhKBFolKGKTDWIHsZXQvZ1snGu/FRYzg1l+R/jT8cRB9BDwhUt |
| 234 | yg== |
| 235 | -----END CERTIFICATE-----''' |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 236 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 237 | def setUp(self): |
Chetan Gaonker | 7997bb4 | 2016-03-28 09:46:15 -0700 | [diff] [blame] | 238 | '''Load the OLT config and activate relevant apps''' |
| 239 | self.olt = OltConfig() |
| 240 | self.port_map = self.olt.olt_port_map() |
| 241 | ##if no olt config, fall back to ovs port map |
| 242 | if not self.port_map: |
| 243 | self.port_map = g_subscriber_port_map |
| 244 | else: |
| 245 | log.info('Using OLT Port configuration for test setup') |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 246 | log.info('Configuring CORD OLT access device information') |
| 247 | OnosCtrl.cord_olt_config(self.olt.olt_device_data()) |
| 248 | self.activate_apps(self.olt_apps) |
| 249 | |
| 250 | self.activate_apps(self.apps) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 251 | |
| 252 | def teardown(self): |
| 253 | '''Deactivate the dhcp app''' |
| 254 | for app in self.apps: |
| 255 | onos_ctrl = OnosCtrl(app) |
| 256 | onos_ctrl.deactivate() |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 257 | log.info('Restarting the Radius container in the setup after running every subscriber test cases by default') |
| 258 | rest = Container('cord-radius', 'cord-test/radius',) |
| 259 | rest.restart('cord-radius','10') |
| 260 | radius = Radius() |
| 261 | radius_ip = radius.ip() |
| 262 | print('Radius server is running with IP %s' %radius_ip) |
| 263 | #os.system('ifconfig '+INTF_RX_DEFAULT+' up') |
| 264 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 265 | |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 266 | def activate_apps(self, apps): |
Chetan Gaonker | 735495f | 2016-05-10 14:51:16 -0700 | [diff] [blame] | 267 | for app in apps: |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 268 | onos_ctrl = OnosCtrl(app) |
| 269 | status, _ = onos_ctrl.activate() |
| 270 | assert_equal(status, True) |
| 271 | time.sleep(2) |
| 272 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 273 | def onos_aaa_load(self): |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 274 | if self.aaa_loaded: |
| 275 | return |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 276 | aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password', |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 277 | 'radiusIp': '172.17.0.2' } } } } |
| 278 | radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2' |
| 279 | aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip |
| 280 | self.onos_load_config('org.onosproject.aaa', aaa_dict) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 281 | self.aaa_loaded = True |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 282 | |
| 283 | def onos_dhcp_table_load(self, config = None): |
| 284 | dhcp_dict = {'apps' : { 'org.onosproject.dhcp' : { 'dhcp' : copy.copy(self.dhcp_server_config) } } } |
| 285 | dhcp_config = dhcp_dict['apps']['org.onosproject.dhcp']['dhcp'] |
| 286 | if config: |
| 287 | for k in config.keys(): |
| 288 | if dhcp_config.has_key(k): |
| 289 | dhcp_config[k] = config[k] |
| 290 | self.onos_load_config('org.onosproject.dhcp', dhcp_dict) |
| 291 | |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 292 | def send_recv(self, mac = None, update_seed = False, validate = True): |
| 293 | cip, sip = self.dhcp.discover(mac = mac, update_seed = update_seed) |
| 294 | if validate: |
| 295 | assert_not_equal(cip, None) |
| 296 | assert_not_equal(sip, None) |
| 297 | log.info('Got dhcp client IP %s from server %s for mac %s' % |
| 298 | (cip, sip, self.dhcp.get_mac(cip)[0])) |
| 299 | return cip,sip |
| 300 | |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 301 | def onos_load_config(self, app, config): |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 302 | status, code = OnosCtrl.config(config) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 303 | if status is False: |
| 304 | log.info('JSON config request for app %s returned status %d' %(app, code)) |
| 305 | assert_equal(status, True) |
| 306 | time.sleep(2) |
| 307 | |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 308 | def dhcp_sndrcv(self, dhcp, update_seed = False): |
| 309 | cip, sip = dhcp.discover(update_seed = update_seed) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 310 | assert_not_equal(cip, None) |
| 311 | assert_not_equal(sip, None) |
| 312 | 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] | 313 | (cip, sip, dhcp.get_mac(cip)[0])) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 314 | return cip,sip |
| 315 | |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 316 | def dhcp_request(self, subscriber, seed_ip = '10.10.10.1', update_seed = False): |
Chetan Gaonker | 0097120 | 2016-03-23 15:11:12 -0700 | [diff] [blame] | 317 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.200', |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 318 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 319 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 320 | self.onos_dhcp_table_load(config) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 321 | dhcp = DHCPTest(seed_ip = seed_ip, iface = subscriber.iface) |
| 322 | cip, sip = self.dhcp_sndrcv(dhcp, update_seed = update_seed) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 323 | return cip, sip |
| 324 | |
| 325 | def recv_channel_cb(self, pkt): |
| 326 | ##First verify that we have received the packet for the joined instance |
| 327 | chan = self.subscriber.caddr(pkt[IP].dst) |
| 328 | assert_equal(chan in self.subscriber.join_map.keys(), True) |
| 329 | recv_time = monotonic.monotonic() * 1000000 |
| 330 | join_time = self.subscriber.join_map[chan][self.subscriber.STATS_JOIN].start |
| 331 | delta = recv_time - join_time |
| 332 | self.subscriber.join_rx_stats.update(packets=1, t = delta, usecs = True) |
| 333 | self.subscriber.channel_update(chan, self.subscriber.STATS_RX, 1, t = delta) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 334 | 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] | 335 | self.test_status = True |
| 336 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 337 | def tls_verify(self, subscriber): |
| 338 | if subscriber.has_service('TLS'): |
| 339 | time.sleep(2) |
| 340 | tls = TLSAuthTest() |
| 341 | log.info('Running subscriber %s tls auth test' %subscriber.name) |
| 342 | tls.runTest() |
| 343 | self.test_status = True |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 344 | return self.test_status |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 345 | |
| 346 | def dhcp_verify(self, subscriber): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 347 | cip, sip = self.dhcp_request(subscriber, update_seed = True) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 348 | log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip)) |
| 349 | subscriber.src_list = [cip] |
| 350 | self.test_status = True |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 351 | return self.test_status |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 352 | |
| 353 | def dhcp_jump_verify(self, subscriber): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 354 | cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.200.1') |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 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 |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 358 | return self.test_status |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 359 | |
| 360 | def dhcp_next_verify(self, subscriber): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 361 | cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.150.1') |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 362 | log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip)) |
| 363 | subscriber.src_list = [cip] |
| 364 | self.test_status = True |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 365 | return self.test_status |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 366 | |
| 367 | def igmp_verify(self, subscriber): |
| 368 | chan = 0 |
| 369 | if subscriber.has_service('IGMP'): |
| 370 | for i in range(5): |
| 371 | log.info('Joining channel %d for subscriber %s' %(chan, subscriber.name)) |
| 372 | subscriber.channel_join(chan, delay = 0) |
| 373 | subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1) |
| 374 | log.info('Leaving channel %d for subscriber %s' %(chan, subscriber.name)) |
| 375 | subscriber.channel_leave(chan) |
| 376 | time.sleep(3) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 377 | 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] | 378 | self.test_status = True |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 379 | return self.test_status |
| 380 | |
| 381 | def igmp_verify_multiChannel(self, subscriber): |
| 382 | if subscriber.has_service('IGMP'): |
| 383 | for chan in range(DEFAULT_NO_CHANNELS): |
| 384 | log.info('Joining channel %d for subscriber %s' %(chan, subscriber.name)) |
| 385 | subscriber.channel_join(chan, delay = 0) |
| 386 | subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1) |
| 387 | log.info('Leaving channel %d for subscriber %s' %(chan, subscriber.name)) |
| 388 | subscriber.channel_leave(chan) |
| 389 | time.sleep(3) |
| 390 | log.info('Interface %s Join RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name,subscriber.join_rx_stats)) |
| 391 | self.test_status = True |
| 392 | return self.test_status |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 393 | |
| 394 | def igmp_jump_verify(self, subscriber): |
| 395 | if subscriber.has_service('IGMP'): |
| 396 | for i in xrange(subscriber.num): |
| 397 | log.info('Subscriber %s jumping channel' %subscriber.name) |
| 398 | chan = subscriber.channel_jump(delay=0) |
| 399 | subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1) |
| 400 | log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name)) |
| 401 | time.sleep(3) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 402 | 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] | 403 | self.test_status = True |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 404 | return self.test_status |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 405 | |
| 406 | def igmp_next_verify(self, subscriber): |
| 407 | if subscriber.has_service('IGMP'): |
| 408 | for i in xrange(subscriber.num): |
| 409 | if i: |
| 410 | chan = subscriber.channel_join_next(delay=0) |
| 411 | else: |
| 412 | chan = subscriber.channel_join(i, delay=0) |
| 413 | log.info('Joined next channel %d for subscriber %s' %(chan, subscriber.name)) |
| 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) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 417 | 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] | 418 | self.test_status = True |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 419 | return self.test_status |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 420 | |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 421 | def generate_port_list(self, subscribers, channels): |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 422 | port_list = [] |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 423 | for i in xrange(subscribers): |
| 424 | if channels > 1: |
| 425 | rx_port = 2*i+1 |
| 426 | tx_port = 2*i+2 |
| 427 | else: |
| 428 | rx_port = Subscriber.PORT_RX_DEFAULT |
| 429 | tx_port = Subscriber.PORT_TX_DEFAULT |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 430 | port_list.append((tx_port, rx_port)) |
| 431 | return port_list |
| 432 | |
| 433 | 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] | 434 | '''Load the subscriber from the database''' |
| 435 | self.subscriber_db = SubscriberDB(create = create) |
| 436 | if create is True: |
| 437 | self.subscriber_db.generate(num) |
| 438 | self.subscriber_info = self.subscriber_db.read(num) |
| 439 | self.subscriber_list = [] |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 440 | if not port_list: |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 441 | port_list = self.generate_port_list(num, num_channels) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 442 | |
| 443 | index = 0 |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 444 | for info in self.subscriber_info: |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 445 | self.subscriber_list.append(Subscriber(name=info['Name'], |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 446 | service=info['Service'], |
Chetan Gaonker | 7997bb4 | 2016-03-28 09:46:15 -0700 | [diff] [blame] | 447 | port_map = self.port_map, |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 448 | num=num_channels, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 449 | channel_start = channel_start, |
| 450 | tx_port = port_list[index][0], |
| 451 | rx_port = port_list[index][1])) |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 452 | if num_channels > 1: |
| 453 | channel_start += num_channels |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 454 | index += 1 |
| 455 | |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 456 | #load the ssm list for all subscriber channels |
| 457 | igmpChannel = IgmpChannel() |
| 458 | ssm_groups = map(lambda sub: sub.channels, self.subscriber_list) |
| 459 | ssm_list = reduce(lambda ssm1, ssm2: ssm1+ssm2, ssm_groups) |
| 460 | igmpChannel.igmp_load_ssm_config(ssm_list) |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 461 | #load the subscriber to mcast port map for cord |
| 462 | cord_port_map = {} |
| 463 | for sub in self.subscriber_list: |
| 464 | for chan in sub.channels: |
| 465 | cord_port_map[chan] = (sub.tx_port, sub.rx_port) |
| 466 | |
| 467 | igmpChannel.cord_port_table_load(cord_port_map) |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 468 | |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 469 | def subscriber_join_verify( self, num_subscribers = 10, num_channels = 1, |
| 470 | channel_start = 0, cbs = None, port_list = [], negative_subscriber_auth = None): |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 471 | self.test_status = False |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 472 | self.num_subscribers = num_subscribers |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 473 | self.sub_loop_count = num_subscribers |
Chetan Gaonker | 7997bb4 | 2016-03-28 09:46:15 -0700 | [diff] [blame] | 474 | self.subscriber_load(create = True, num = num_subscribers, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 475 | num_channels = num_channels, channel_start = channel_start, port_list = port_list) |
Chetan Gaonker | 55fc788 | 2016-03-15 17:46:47 -0700 | [diff] [blame] | 476 | self.onos_aaa_load() |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 477 | self.thread_pool = ThreadPool(min(100, self.num_subscribers), queue_size=1, wait_timeout=1) |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 478 | |
| 479 | if cbs and negative_subscriber_auth is None: |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 480 | cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify) |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 481 | cbs_negative = cbs |
Chetan Gaonker | 41d2e07 | 2016-03-15 16:41:31 -0700 | [diff] [blame] | 482 | for subscriber in self.subscriber_list: |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 483 | subscriber.start() |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 484 | if negative_subscriber_auth is 'half' and self.sub_loop_count%2 is not 0: |
| 485 | cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify) |
| 486 | elif negative_subscriber_auth is 'onethird' and self.sub_loop_count%3 is not 0: |
| 487 | cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify) |
| 488 | else: |
| 489 | cbs = cbs_negative |
| 490 | self.sub_loop_count = self.sub_loop_count - 1 |
| 491 | pool_object = subscriber_pool(subscriber, cbs, self.test_status) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 492 | self.thread_pool.addTask(pool_object.pool_cb) |
| 493 | self.thread_pool.cleanUpThreads() |
| 494 | for subscriber in self.subscriber_list: |
| 495 | subscriber.stop() |
| 496 | return self.test_status |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 497 | |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 498 | def tls_invalid_cert(self, subscriber): |
| 499 | if subscriber.has_service('TLS'): |
| 500 | time.sleep(2) |
| 501 | log.info('Running subscriber %s tls auth test' %subscriber.name) |
| 502 | tls = TLSAuthTest(client_cert = self.CLIENT_CERT_INVALID) |
| 503 | tls.runTest() |
| 504 | if tls.failTest == True: |
| 505 | self.test_status = False |
| 506 | return self.test_status |
| 507 | |
| 508 | def tls_no_cert(self, subscriber): |
| 509 | if subscriber.has_service('TLS'): |
| 510 | time.sleep(2) |
| 511 | log.info('Running subscriber %s tls auth test' %subscriber.name) |
| 512 | tls = TLSAuthTest(client_cert = '') |
| 513 | tls.runTest() |
| 514 | if tls.failTest == True: |
| 515 | self.test_status = False |
| 516 | return self.test_status |
| 517 | |
| 518 | def tls_self_signed_cert(self, subscriber): |
| 519 | if subscriber.has_service('TLS'): |
| 520 | time.sleep(2) |
| 521 | log.info('Running subscriber %s tls auth test' %subscriber.name) |
| 522 | tls = TLSAuthTest(client_cert = self.CLIENT_CERT) |
| 523 | tls.runTest() |
| 524 | if tls.failTest == False: |
| 525 | self.test_status = True |
| 526 | return self.test_status |
| 527 | |
| 528 | def tls_Nsubscribers_use_same_valid_cert(self, subscriber): |
| 529 | if subscriber.has_service('TLS'): |
| 530 | time.sleep(2) |
| 531 | log.info('Running subscriber %s tls auth test' %subscriber.name) |
| 532 | num_users = 3 |
| 533 | for i in xrange(num_users): |
| 534 | tls = TLSAuthTest(intf = 'veth{}'.format(i*2)) |
| 535 | tls.runTest() |
| 536 | if tls.failTest == False: |
| 537 | self.test_status = True |
| 538 | return self.test_status |
| 539 | |
| 540 | def dhcp_discover_scenario(self, subscriber): |
| 541 | if subscriber.has_service('DHCP'): |
| 542 | time.sleep(2) |
| 543 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 544 | t1 = self.subscriber_dhcp_1release() |
| 545 | self.test_status = True |
| 546 | return self.test_status |
| 547 | |
| 548 | def subscriber_dhcp_1release(self, iface = INTF_RX_DEFAULT): |
| 549 | config = {'startip':'10.10.100.20', 'endip':'10.10.100.21', |
| 550 | 'ip':'10.10.100.2', 'mac': "ca:fe:ca:fe:8a:fe", |
| 551 | 'subnet': '255.255.255.0', 'broadcast':'10.10.100.255', 'router':'10.10.100.1'} |
| 552 | self.onos_dhcp_table_load(config) |
| 553 | self.dhcp = DHCPTest(seed_ip = '10.10.100.10', iface = iface) |
| 554 | cip, sip = self.send_recv() |
| 555 | log.info('Releasing ip %s to server %s' %(cip, sip)) |
| 556 | assert_equal(self.dhcp.release(cip), True) |
| 557 | log.info('Triggering DHCP discover again after release') |
| 558 | cip2, sip2 = self.send_recv(update_seed = True) |
| 559 | log.info('Verifying released IP was given back on rediscover') |
| 560 | assert_equal(cip, cip2) |
| 561 | log.info('Test done. Releasing ip %s to server %s' %(cip2, sip2)) |
| 562 | assert_equal(self.dhcp.release(cip2), True) |
| 563 | |
| 564 | |
| 565 | def dhcp_client_reboot_scenario(self, subscriber): |
| 566 | if subscriber.has_service('DHCP'): |
| 567 | time.sleep(2) |
| 568 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 569 | tl = self.subscriber_dhcp_client_request_after_reboot() |
| 570 | self.test_status = True |
| 571 | return self.test_status |
| 572 | |
| 573 | def subscriber_dhcp_client_request_after_reboot(self, iface = INTF_RX_DEFAULT): |
| 574 | #''' Client sends DHCP Request after reboot.''' |
| 575 | |
| 576 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
| 577 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 578 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 579 | self.onos_dhcp_table_load(config) |
| 580 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 581 | cip, sip, mac, lval = self.dhcp.only_discover() |
| 582 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 583 | (cip, sip, mac) ) |
| 584 | |
| 585 | log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.") |
| 586 | |
| 587 | if (cip == None and mac != None): |
| 588 | log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.") |
| 589 | assert_not_equal(cip, None) |
| 590 | |
| 591 | else: |
| 592 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 593 | if new_cip == None: |
| 594 | log.info("Got DHCP server NAK.") |
| 595 | os.system('ifconfig '+iface+' down') |
| 596 | log.info('Client goes down.') |
| 597 | log.info('Delay for 5 seconds.') |
| 598 | |
| 599 | time.sleep(5) |
| 600 | |
| 601 | os.system('ifconfig '+iface+' up') |
| 602 | log.info('Client is up now.') |
| 603 | |
| 604 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 605 | if new_cip == None: |
| 606 | log.info("Got DHCP server NAK.") |
| 607 | assert_not_equal(new_cip, None) |
| 608 | elif new_cip != None: |
| 609 | log.info("Got DHCP ACK.") |
| 610 | |
| 611 | |
| 612 | def dhcp_client_renew_scenario(self, subscriber): |
| 613 | if subscriber.has_service('DHCP'): |
| 614 | time.sleep(2) |
| 615 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 616 | tl = self.subscriber_dhcp_client_renew_time() |
| 617 | self.test_status = True |
| 618 | return self.test_status |
| 619 | |
| 620 | def subscriber_dhcp_client_renew_time(self, iface = INTF_RX_DEFAULT): |
| 621 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
| 622 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 623 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 624 | self.onos_dhcp_table_load(config) |
| 625 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 626 | cip, sip, mac , lval = self.dhcp.only_discover() |
| 627 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 628 | (cip, sip, mac) ) |
| 629 | |
| 630 | log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.") |
| 631 | if (cip == None and mac != None): |
| 632 | log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.") |
| 633 | assert_not_equal(cip, None) |
| 634 | elif cip and sip and mac: |
| 635 | log.info("Triggering DHCP Request.") |
| 636 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, renew_time = True) |
| 637 | if new_cip and new_sip and lval: |
| 638 | log.info("Client 's Renewal time is :%s",lval) |
| 639 | log.info("Generating delay till renewal time.") |
| 640 | time.sleep(lval) |
| 641 | log.info("Client Sending Unicast DHCP request.") |
| 642 | latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac, unicast = True) |
| 643 | if latest_cip and latest_sip: |
| 644 | log.info("Got DHCP Ack. Lease Renewed for ip %s and mac %s from server %s." % |
| 645 | (latest_cip, mac, latest_sip) ) |
| 646 | |
| 647 | elif latest_cip == None: |
| 648 | log.info("Got DHCP NAK. Lease not renewed.") |
| 649 | elif new_cip == None or new_sip == None or lval == None: |
| 650 | log.info("Got DHCP NAK.") |
| 651 | |
| 652 | |
| 653 | def dhcp_server_reboot_scenario(self, subscriber): |
| 654 | if subscriber.has_service('DHCP'): |
| 655 | time.sleep(2) |
| 656 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 657 | tl = self.subscriber_dhcp_server_after_reboot() |
| 658 | self.test_status = True |
| 659 | return self.test_status |
| 660 | |
| 661 | def subscriber_dhcp_server_after_reboot(self, iface = INTF_RX_DEFAULT): |
| 662 | ''' DHCP server goes down.''' |
| 663 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
| 664 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 665 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 666 | self.onos_dhcp_table_load(config) |
| 667 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 668 | cip, sip, mac, lval = self.dhcp.only_discover() |
| 669 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 670 | (cip, sip, mac) ) |
| 671 | log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.") |
| 672 | if (cip == None and mac != None): |
| 673 | log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.") |
| 674 | assert_not_equal(cip, None) |
| 675 | else: |
| 676 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 677 | if new_cip == None: |
| 678 | log.info("Got DHCP server NAK.") |
| 679 | assert_not_equal(new_cip, None) |
| 680 | log.info('Getting DHCP server Down.') |
| 681 | onos_ctrl = OnosCtrl(self.dhcp_app) |
| 682 | onos_ctrl.deactivate() |
| 683 | for i in range(0,4): |
| 684 | log.info("Sending DHCP Request.") |
| 685 | log.info('') |
| 686 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 687 | if new_cip == None and new_sip == None: |
| 688 | log.info('') |
| 689 | log.info("DHCP Request timed out.") |
| 690 | elif new_cip and new_sip: |
| 691 | log.info("Got Reply from DHCP server.") |
| 692 | assert_equal(new_cip,None) #Neagtive Test Case |
| 693 | log.info('Getting DHCP server Up.') |
| 694 | # self.activate_apps(self.dhcp_app) |
| 695 | onos_ctrl = OnosCtrl(self.dhcp_app) |
| 696 | status, _ = onos_ctrl.activate() |
| 697 | assert_equal(status, True) |
| 698 | time.sleep(3) |
| 699 | for i in range(0,4): |
| 700 | log.info("Sending DHCP Request after DHCP server is up.") |
| 701 | log.info('') |
| 702 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 703 | if new_cip == None and new_sip == None: |
| 704 | log.info('') |
| 705 | log.info("DHCP Request timed out.") |
| 706 | elif new_cip and new_sip: |
| 707 | log.info("Got Reply from DHCP server.") |
| 708 | assert_equal(new_cip,None) #Neagtive Test Case |
| 709 | |
| 710 | def dhcp_client_rebind_scenario(self, subscriber): |
| 711 | if subscriber.has_service('DHCP'): |
| 712 | time.sleep(2) |
| 713 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 714 | tl = self.subscriber_dhcp_client_rebind_time() |
| 715 | self.test_status = True |
| 716 | return self.test_status |
| 717 | |
| 718 | def subscriber_dhcp_client_rebind_time(self, iface = INTF_RX_DEFAULT): |
| 719 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
| 720 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 721 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 722 | self.onos_dhcp_table_load(config) |
| 723 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 724 | cip, sip, mac, lval = self.dhcp.only_discover() |
| 725 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 726 | (cip, sip, mac) ) |
| 727 | log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.") |
| 728 | if (cip == None and mac != None): |
| 729 | log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.") |
| 730 | assert_not_equal(cip, None) |
| 731 | elif cip and sip and mac: |
| 732 | log.info("Triggering DHCP Request.") |
| 733 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, rebind_time = True) |
| 734 | if new_cip and new_sip and lval: |
| 735 | log.info("Client 's Rebind time is :%s",lval) |
| 736 | log.info("Generating delay till rebind time.") |
| 737 | time.sleep(lval) |
| 738 | log.info("Client Sending broadcast DHCP requests for renewing lease or for getting new ip.") |
| 739 | self.dhcp.after_T2 = True |
| 740 | for i in range(0,4): |
| 741 | latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac) |
| 742 | if latest_cip and latest_sip: |
| 743 | log.info("Got DHCP Ack. Lease Renewed for ip %s and mac %s from server %s." % |
| 744 | (latest_cip, mac, latest_sip) ) |
| 745 | break |
| 746 | elif latest_cip == None: |
| 747 | log.info("Got DHCP NAK. Lease not renewed.") |
| 748 | assert_not_equal(latest_cip, None) |
| 749 | elif new_cip == None or new_sip == None or lval == None: |
| 750 | log.info("Got DHCP NAK.Lease not Renewed.") |
| 751 | |
| 752 | def dhcp_starvation_scenario(self, subscriber): |
| 753 | if subscriber.has_service('DHCP'): |
| 754 | time.sleep(2) |
| 755 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 756 | tl = self.subscriber_dhcp_starvation() |
| 757 | self.test_status = True |
| 758 | return self.test_status |
| 759 | |
| 760 | |
| 761 | def subscriber_dhcp_starvation(self, iface = INTF_RX_DEFAULT): |
| 762 | '''DHCP starve''' |
| 763 | config = {'startip':'182.17.0.20', 'endip':'182.17.0.69', |
| 764 | 'ip':'182.17.0.2', 'mac': "ca:fe:c3:fe:ca:fe", |
| 765 | 'subnet': '255.255.255.0', 'broadcast':'182.17.0.255', 'router':'182.17.0.1'} |
| 766 | self.onos_dhcp_table_load(config) |
| 767 | self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = iface) |
| 768 | log.info('Verifying 1 ') |
| 769 | for x in xrange(50): |
| 770 | mac = RandMAC()._fix() |
| 771 | self.send_recv(mac = mac) |
| 772 | log.info('Verifying 2 ') |
| 773 | cip, sip = self.send_recv(update_seed = True, validate = False) |
| 774 | assert_equal(cip, None) |
| 775 | assert_equal(sip, None) |
| 776 | |
| 777 | def dhcp_same_client_multi_discovers_scenario(self, subscriber): |
| 778 | if subscriber.has_service('DHCP'): |
| 779 | time.sleep(2) |
| 780 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 781 | tl = self.subscriber_dhcp_same_client_multiple_discover() |
| 782 | self.test_status = True |
| 783 | return self.test_status |
| 784 | |
| 785 | |
| 786 | def subscriber_dhcp_same_client_multiple_discover(self, iface = INTF_RX_DEFAULT): |
| 787 | ''' DHCP Client sending multiple discover . ''' |
| 788 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
| 789 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 790 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 791 | self.onos_dhcp_table_load(config) |
| 792 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 793 | cip, sip, mac, lval = self.dhcp.only_discover() |
| 794 | log.info('Got dhcp client IP %s from server %s for mac %s . Not going to send DHCPREQUEST.' % |
| 795 | (cip, sip, mac) ) |
| 796 | log.info('Triggering DHCP discover again.') |
| 797 | new_cip, new_sip, new_mac , lval = self.dhcp.only_discover() |
| 798 | if cip == new_cip: |
| 799 | log.info('Got same ip for 2nd DHCP discover for client IP %s from server %s for mac %s. Triggering DHCP Request. ' |
| 800 | % (new_cip, new_sip, new_mac) ) |
| 801 | elif cip != new_cip: |
| 802 | log.info('Ip after 1st discover %s' %cip) |
| 803 | log.info('Map after 2nd discover %s' %new_cip) |
| 804 | assert_equal(cip, new_cip) |
| 805 | |
| 806 | def dhcp_same_client_multi_request_scenario(self, subscriber): |
| 807 | if subscriber.has_service('DHCP'): |
| 808 | time.sleep(2) |
| 809 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 810 | tl = self.subscriber_dhcp_same_client_multiple_request() |
| 811 | self.test_status = True |
| 812 | return self.test_status |
| 813 | |
| 814 | def subscriber_dhcp_same_client_multiple_request(self, iface = INTF_RX_DEFAULT): |
| 815 | ''' DHCP Client sending multiple repeat DHCP requests. ''' |
| 816 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
| 817 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 818 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 819 | self.onos_dhcp_table_load(config) |
| 820 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 821 | log.info('Sending DHCP discover and DHCP request.') |
| 822 | cip, sip = self.send_recv() |
| 823 | mac = self.dhcp.get_mac(cip)[0] |
| 824 | log.info("Sending DHCP request again.") |
| 825 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 826 | if (new_cip,new_sip) == (cip,sip): |
| 827 | log.info('Got same ip for 2nd DHCP Request for client IP %s from server %s for mac %s.' |
| 828 | % (new_cip, new_sip, mac) ) |
| 829 | elif (new_cip,new_sip): |
| 830 | log.info('No DHCP ACK') |
| 831 | assert_equal(new_cip, None) |
| 832 | assert_equal(new_sip, None) |
| 833 | else: |
| 834 | print "Something went wrong." |
| 835 | |
| 836 | |
| 837 | def dhcp_client_desired_ip_scenario(self, subscriber): |
| 838 | if subscriber.has_service('DHCP'): |
| 839 | time.sleep(2) |
| 840 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 841 | tl = self.subscriber_dhcp_client_desired_address() |
| 842 | self.test_status = True |
| 843 | return self.test_status |
| 844 | |
| 845 | def subscriber_dhcp_client_desired_address(self, iface = INTF_RX_DEFAULT): |
| 846 | '''DHCP Client asking for desired IP address.''' |
| 847 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
| 848 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 849 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 850 | self.onos_dhcp_table_load(config) |
| 851 | self.dhcp = DHCPTest(seed_ip = '20.20.20.31', iface = iface) |
| 852 | cip, sip, mac , lval = self.dhcp.only_discover(desired = True) |
| 853 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 854 | (cip, sip, mac) ) |
| 855 | if cip == self.dhcp.seed_ip: |
| 856 | log.info('Got dhcp client IP %s from server %s for mac %s as desired .' % |
| 857 | (cip, sip, mac) ) |
| 858 | elif cip != self.dhcp.seed_ip: |
| 859 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 860 | (cip, sip, mac) ) |
| 861 | log.info('The desired ip was: %s .' % self.dhcp.seed_ip) |
| 862 | assert_equal(cip, self.dhcp.seed_ip) |
| 863 | |
| 864 | def dhcp_client_request_pkt_with_non_offered_ip_scenario(self, subscriber): |
| 865 | if subscriber.has_service('DHCP'): |
| 866 | time.sleep(2) |
| 867 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 868 | tl = self.subscriber_dhcp_server_nak_packet() |
| 869 | self.test_status = True |
| 870 | return self.test_status |
| 871 | |
| 872 | def subscriber_dhcp_server_nak_packet(self, iface = INTF_RX_DEFAULT): |
| 873 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
| 874 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 875 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 876 | self.onos_dhcp_table_load(config) |
| 877 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 878 | cip, sip, mac, lval = self.dhcp.only_discover() |
| 879 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 880 | (cip, sip, mac) ) |
| 881 | log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.") |
| 882 | if (cip == None and mac != None): |
| 883 | log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.") |
| 884 | assert_not_equal(cip, None) |
| 885 | else: |
| 886 | new_cip, new_sip = self.dhcp.only_request('20.20.20.31', mac) |
| 887 | if new_cip == None: |
| 888 | log.info("Got DHCP server NAK.") |
| 889 | assert_equal(new_cip, None) #Negative Test Case |
| 890 | |
| 891 | def dhcp_client_requested_out_pool_ip_scenario(self, subscriber): |
| 892 | if subscriber.has_service('DHCP'): |
| 893 | time.sleep(2) |
| 894 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 895 | tl = self.subscriber_dhcp_client_desired_address_out_of_pool() |
| 896 | self.test_status = True |
| 897 | return self.test_status |
| 898 | |
| 899 | |
| 900 | def subscriber_dhcp_client_desired_address_out_of_pool(self, iface = INTF_RX_DEFAULT): |
| 901 | '''DHCP Client asking for desired IP address from out of pool.''' |
| 902 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
| 903 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 904 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 905 | self.onos_dhcp_table_load(config) |
| 906 | self.dhcp = DHCPTest(seed_ip = '20.20.20.35', iface = iface) |
| 907 | cip, sip, mac, lval = self.dhcp.only_discover(desired = True) |
| 908 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 909 | (cip, sip, mac) ) |
| 910 | if cip == self.dhcp.seed_ip: |
| 911 | log.info('Got dhcp client IP %s from server %s for mac %s as desired .' % |
| 912 | (cip, sip, mac) ) |
| 913 | assert_equal(cip, self.dhcp.seed_ip) #Negative Test Case |
| 914 | |
| 915 | elif cip != self.dhcp.seed_ip: |
| 916 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 917 | (cip, sip, mac) ) |
| 918 | log.info('The desired ip was: %s .' % self.dhcp.seed_ip) |
| 919 | assert_not_equal(cip, self.dhcp.seed_ip) |
| 920 | |
| 921 | elif cip == None: |
| 922 | log.info('Got DHCP NAK') |
| 923 | |
| 924 | |
| 925 | def dhcp_client_specific_lease_scenario(self, subscriber): |
| 926 | if subscriber.has_service('DHCP'): |
| 927 | time.sleep(2) |
| 928 | log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name) |
| 929 | tl = self.subscriber_dhcp_specific_lease_packet() |
| 930 | self.test_status = True |
| 931 | return self.test_status |
| 932 | |
| 933 | def subscriber_dhcp_specific_lease_packet(self, iface = INTF_RX_DEFAULT): |
| 934 | ''' Client sends DHCP Discover packet for particular lease time.''' |
| 935 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
| 936 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 937 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 938 | self.onos_dhcp_table_load(config) |
| 939 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 940 | log.info('Sending DHCP discover with lease time of 700') |
| 941 | cip, sip, mac, lval = self.dhcp.only_discover(lease_time = True) |
| 942 | |
| 943 | log.info("Verifying Client 's IP and mac in DHCP Offer packet.") |
| 944 | if (cip == None and mac != None): |
| 945 | log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.") |
| 946 | assert_not_equal(cip, None) |
| 947 | elif lval != 700: |
| 948 | log.info('Getting dhcp client IP %s from server %s for mac %s with lease time %s. That is not 700.' % |
| 949 | (cip, sip, mac, lval) ) |
| 950 | assert_not_equal(lval, 700) |
| 951 | |
| 952 | def test_subscriber_join_recv_channel(self): |
| 953 | ###"""Test subscriber join and receive""" |
| 954 | num_subscribers = 1 |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 955 | num_channels = 1 |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 956 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 957 | num_channels = num_channels, |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 958 | cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify), |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 959 | port_list = self.generate_port_list(num_subscribers, num_channels)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 960 | assert_equal(test_status, True) |
Chetan Gaonker | cbe7964 | 2016-03-09 17:45:58 -0800 | [diff] [blame] | 961 | |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 962 | def test_subscriber_join_jump_channel(self): |
| 963 | ###"""Test subscriber join and receive for channel surfing""" |
| 964 | num_subscribers = 1 |
| 965 | num_channels = 1 |
| 966 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 967 | num_channels = num_channels, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 968 | cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify), |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 969 | port_list = self.generate_port_list(num_subscribers, num_channels)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 970 | assert_equal(test_status, True) |
Chetan Gaonker | 4b959fc | 2016-03-09 19:20:16 -0800 | [diff] [blame] | 971 | |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 972 | def test_subscriber_join_next_channel(self): |
| 973 | ###"""Test subscriber join next for channels""" |
| 974 | num_subscribers = 1 |
| 975 | num_channels = 1 |
| 976 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 977 | num_channels = num_channels, |
Chetan Gaonker | a58ab6e | 2016-03-23 15:04:20 -0700 | [diff] [blame] | 978 | cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify), |
Chetan Gaonker | 3d16385 | 2016-03-28 12:20:25 -0700 | [diff] [blame] | 979 | port_list = self.generate_port_list(num_subscribers, num_channels)) |
Chetan Gaonker | cd86bdd | 2016-03-17 00:08:12 -0700 | [diff] [blame] | 980 | assert_equal(test_status, True) |
ChetanGaonker | eff07bc | 2016-06-09 16:39:23 -0700 | [diff] [blame] | 981 | |
| 982 | #@deferred(SUBSCRIBER_TIMEOUT) |
| 983 | def test_subscriber_authentication_with_invalid_certificate_and_channel_surfing(self): |
| 984 | ### """Test subscriber to auth with invalidCertification and join channel""" |
| 985 | num_subscribers = 1 |
| 986 | num_channels = 1 |
| 987 | df = defer.Deferred() |
| 988 | def sub_auth_invalid_cert(df): |
| 989 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 990 | num_channels = num_channels, |
| 991 | cbs = (self.tls_invalid_cert, self.dhcp_verify, self.igmp_verify), |
| 992 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 993 | assert_equal(test_status, False) |
| 994 | df.callback(0) |
| 995 | reactor.callLater(0, sub_auth_invalid_cert, df) |
| 996 | return df |
| 997 | |
| 998 | |
| 999 | #@deferred(SUBSCRIBER_TIMEOUT) |
| 1000 | def test_subscriber_authentication_with_no_certificate_and_channel_surfing(self): |
| 1001 | ### """Test subscriber to auth with No Certification and join channel""" |
| 1002 | num_subscribers = 1 |
| 1003 | num_channels = 1 |
| 1004 | df = defer.Deferred() |
| 1005 | def sub_auth_no_cert(df): |
| 1006 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1007 | num_channels = num_channels, |
| 1008 | cbs = (self.tls_no_cert, self.dhcp_verify, self.igmp_verify), |
| 1009 | port_list = self.generate_port_list(num_subscribers, num_channels), |
| 1010 | negative_subscriber_auth = 'all') |
| 1011 | assert_equal(test_status, False) |
| 1012 | df.callback(0) |
| 1013 | reactor.callLater(0, sub_auth_no_cert, df) |
| 1014 | return df |
| 1015 | |
| 1016 | def test_subscriber_authentication_with_self_signed_certificate_and_channel_surfing(self): |
| 1017 | ### """Test subscriber to auth with Self Signed Certification and join channel""" |
| 1018 | num_subscribers = 1 |
| 1019 | num_channels = 1 |
| 1020 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1021 | num_channels = num_channels, |
| 1022 | cbs = (self.tls_self_signed_cert, self.dhcp_verify, self.igmp_verify), |
| 1023 | port_list = self.generate_port_list(num_subscribers, num_channels), |
| 1024 | negative_subscriber_auth = 'all') |
| 1025 | assert_equal(test_status, True) |
| 1026 | |
| 1027 | def test_subscriber_authentication_with_dhcp_discover_and_channel_surfing(self): |
| 1028 | ### """Test subscriber auth success, DHCP re-discover with DHCP server and join channel""" |
| 1029 | num_subscribers = 1 |
| 1030 | num_channels = 1 |
| 1031 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1032 | num_channels = num_channels, |
| 1033 | cbs = (self.tls_verify, self.dhcp_discover_scenario, self.igmp_verify), |
| 1034 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1035 | assert_equal(test_status, True) |
| 1036 | |
| 1037 | def test_subscriber_authentication_with_dhcp_client_reboot_scenario_and_channel_surfing(self): |
| 1038 | ### """Test subscriber auth success, DHCP client got re-booted and join channel""" |
| 1039 | num_subscribers = 1 |
| 1040 | num_channels = 1 |
| 1041 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1042 | num_channels = num_channels, |
| 1043 | cbs = (self.tls_verify, self.dhcp_client_reboot_scenario, self.igmp_verify), |
| 1044 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1045 | assert_equal(test_status, True) |
| 1046 | |
| 1047 | def test_subscriber_authentication_with_dhcp_server_reboot_scenario_and_channel_surfing(self): |
| 1048 | ### """Test subscriber auth , DHCP server re-boot during DHCP process and join channel""" |
| 1049 | num_subscribers = 1 |
| 1050 | num_channels = 1 |
| 1051 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1052 | num_channels = num_channels, |
| 1053 | cbs = (self.tls_verify, self.dhcp_server_reboot_scenario, self.igmp_verify), |
| 1054 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1055 | assert_equal(test_status, True) |
| 1056 | |
| 1057 | def test_subscriber_authentication_with_dhcp_client_rebind_and_channel_surfing(self): |
| 1058 | ### """Test subscriber auth , DHCP client rebind IP and join channel""" |
| 1059 | num_subscribers = 1 |
| 1060 | num_channels = 1 |
| 1061 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1062 | num_channels = num_channels, |
| 1063 | cbs = (self.tls_verify, self.dhcp_client_rebind_scenario, self.igmp_verify), |
| 1064 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1065 | assert_equal(test_status, True) |
| 1066 | |
| 1067 | |
| 1068 | def test_subscriber_authentication_with_dhcp_starvation_scenario_and_channel_surfing(self): |
| 1069 | ### """Test subscriber auth , DHCP starvation and join channel""" |
| 1070 | num_subscribers = 1 |
| 1071 | num_channels = 1 |
| 1072 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1073 | num_channels = num_channels, |
| 1074 | cbs = (self.tls_verify, self.dhcp_starvation_scenario, self.igmp_verify), |
| 1075 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1076 | assert_equal(test_status, True) |
| 1077 | |
| 1078 | def test_subscriber_authentication_with_multiple_dhcp_discover_for_same_subscriber_and_channel_surfing(self): |
| 1079 | ### """Test subscriber auth , sending same DHCP client discover multiple times and join channel""" |
| 1080 | num_subscribers = 1 |
| 1081 | num_channels = 1 |
| 1082 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1083 | num_channels = num_channels, |
| 1084 | cbs = (self.tls_verify, self.dhcp_same_client_multi_discovers_scenario, self.igmp_verify), |
| 1085 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1086 | assert_equal(test_status, True) |
| 1087 | |
| 1088 | def test_subscriber_authentication_with_multiple_dhcp_request_for_same_subscriber_and_channel_surfing(self): |
| 1089 | ### """Test subscriber auth , same DHCP client multiple requerts times and join channel""" |
| 1090 | num_subscribers = 1 |
| 1091 | num_channels = 1 |
| 1092 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1093 | num_channels = num_channels, |
| 1094 | cbs = (self.tls_verify, self.dhcp_same_client_multi_request_scenario, self.igmp_verify), |
| 1095 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1096 | assert_equal(test_status, True) |
| 1097 | |
| 1098 | def test_subscriber_authentication_with_dhcp_client_requested_ip_and_channel_surfing(self): |
| 1099 | ### """Test subscriber auth with DHCP client requesting ip and join channel""" |
| 1100 | num_subscribers = 1 |
| 1101 | num_channels = 1 |
| 1102 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1103 | num_channels = num_channels, |
| 1104 | cbs = (self.tls_verify, self.dhcp_client_desired_ip_scenario, self.igmp_verify), |
| 1105 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1106 | assert_equal(test_status, True) |
| 1107 | |
| 1108 | def test_subscriber_authentication_with_dhcp_non_offered_ip_and_channel_surfing(self): |
| 1109 | ### """Test subscriber auth with DHCP client request for non-offered ip and join channel""" |
| 1110 | num_subscribers = 1 |
| 1111 | num_channels = 1 |
| 1112 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1113 | num_channels = num_channels, |
| 1114 | cbs = (self.tls_verify, self.dhcp_client_request_pkt_with_non_offered_ip_scenario, self.igmp_verify), |
| 1115 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1116 | assert_equal(test_status, True) |
| 1117 | |
| 1118 | def test_subscriber_authentication_with_dhcp_request_out_of_pool_ip_by_client_and_channel_surfing(self): |
| 1119 | ### """Test subscriber auth with DHCP client requesting out of pool ip and join channel""" |
| 1120 | num_subscribers = 1 |
| 1121 | num_channels = 1 |
| 1122 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1123 | num_channels = num_channels, |
| 1124 | cbs = (self.tls_verify, self.dhcp_client_requested_out_pool_ip_scenario, self.igmp_verify), |
| 1125 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1126 | assert_equal(test_status, True) |
| 1127 | |
| 1128 | def test_subscriber_authentication_with_dhcp_specified_lease_time_functionality_and_channel_surfing(self): |
| 1129 | ### """Test subscriber auth with DHCP client specifying lease time and join channel""" |
| 1130 | num_subscribers = 1 |
| 1131 | num_channels = 1 |
| 1132 | test_status = self.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1133 | num_channels = num_channels, |
| 1134 | cbs = (self.tls_verify, self.dhcp_client_specific_lease_scenario, self.igmp_verify), |
| 1135 | port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all') |
| 1136 | assert_equal(test_status, True) |