Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 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 |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 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 | |
| 16 | |
| 17 | # |
| 18 | # Copyright 2016-present Ciena Corporation |
| 19 | # |
| 20 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 21 | # you may not use this file except in compliance with the License. |
| 22 | # You may obtain a copy of the License at |
| 23 | # |
| 24 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 25 | # |
| 26 | # Unless required by applicable law or agreed to in writing, software |
| 27 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 28 | # WITHOUT WARRANTIES OR CONDITIONS OF AeY KIND, either express or implied. |
| 29 | # See the License for the specific language governing permissions and |
| 30 | # limitations under the License. |
| 31 | # |
| 32 | import unittest |
| 33 | from nose.tools import * |
| 34 | from nose.twistedtools import reactor, deferred |
| 35 | from twisted.internet import defer |
| 36 | import time |
| 37 | import os, sys |
| 38 | from DHCP import DHCPTest |
| 39 | from CordTestUtils import get_mac, log_test |
| 40 | from OnosCtrl import OnosCtrl |
| 41 | from OltConfig import OltConfig |
| 42 | from CordTestServer import cord_test_onos_restart |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 43 | from CordTestConfig import setup_module, teardown_module |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 44 | from CordLogger import CordLogger |
| 45 | from portmaps import g_subscriber_port_map |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 46 | from CordContainer import Onos |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 47 | import threading, random |
| 48 | from threading import current_thread |
| 49 | log_test.setLevel('INFO') |
| 50 | |
| 51 | class dhcpl2relay_exchange(CordLogger): |
| 52 | |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 53 | VOLTHA_HOST = None |
| 54 | VOLTHA_REST_PORT = 8881 |
| 55 | VOLTHA_ENABLED = bool(int(os.getenv('VOLTHA_ENABLED', 0))) |
| 56 | VOLTHA_OLT_TYPE = 'simulated_olt' |
| 57 | VOLTHA_OLT_MAC = '00:0c:e2:31:12:00' |
| 58 | VOLTHA_UPLINK_VLAN_MAP = { 'of:0000000000000001' : '222' } |
| 59 | |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 60 | app = 'org.opencord.dhcpl2relay' |
| 61 | sadis_app = 'org.opencord.sadis' |
| 62 | app_dhcp = 'org.onosproject.dhcp' |
| 63 | relay_interfaces_last = () |
| 64 | interface_to_mac_map = {} |
| 65 | host_ip_map = {} |
| 66 | test_path = os.path.dirname(os.path.realpath(__file__)) |
| 67 | dhcp_data_dir = os.path.join(test_path, '..', 'setup') |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 68 | dhcpl2_app_file = os.path.join(test_path, '..', 'apps/dhcpl2relay-1.0.0.oar') |
| 69 | sadis_app_file = os.path.join(test_path, '..', 'apps/sadis-app-1.0.0-SNAPSHOT.oar') |
| 70 | olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config_voltha_local.json')) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 71 | default_config = { 'default-lease-time' : 600, 'max-lease-time' : 7200, } |
| 72 | default_options = [ ('subnet-mask', '255.255.255.0'), |
| 73 | ('broadcast-address', '192.168.1.255'), |
| 74 | ('domain-name-servers', '192.168.1.1'), |
| 75 | ('domain-name', '"mydomain.cord-tester"'), |
| 76 | ] |
| 77 | default_subnet_config = [ ('192.168.1.2', |
| 78 | ''' |
| 79 | subnet 192.168.1.0 netmask 255.255.255.0 { |
| 80 | range 192.168.1.10 192.168.1.100; |
| 81 | } |
| 82 | '''), ] |
| 83 | |
| 84 | lock = threading.Condition() |
| 85 | ip_count = 0 |
| 86 | failure_count = 0 |
| 87 | start_time = 0 |
| 88 | diff = 0 |
| 89 | |
| 90 | transaction_count = 0 |
| 91 | transactions = 0 |
| 92 | running_time = 0 |
| 93 | total_success = 0 |
| 94 | total_failure = 0 |
| 95 | #just in case we want to reset ONOS to default network cfg after relay tests |
| 96 | onos_restartable = bool(int(os.getenv('ONOS_RESTART', 0))) |
| 97 | configs = {} |
| 98 | |
| 99 | @classmethod |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 100 | def update_apps_version(cls): |
| 101 | version = Onos.getVersion() |
| 102 | major = int(version.split('.')[0]) |
| 103 | minor = int(version.split('.')[1]) |
| 104 | dhcpl2_app_version = '1.0.0' |
| 105 | sadis_app_version = '1.0.0-SNAPSHOT' |
| 106 | # sadis-app-1.0.0-SNAPSHOT.oar |
| 107 | # if major > 1: |
| 108 | # cordigmp_app_version = '3.0-SNAPSHOT' |
| 109 | # olt_app_version = '2.0-SNAPSHOT' |
| 110 | # elif major == 1: |
| 111 | # if minor > 10: |
| 112 | # cordigmp_app_version = '3.0-SNAPSHOT' |
| 113 | # olt_app_version = '2.0-SNAPSHOT' |
| 114 | # elif minor <= 8: |
| 115 | # olt_app_version = '1.1-SNAPSHOT' |
| 116 | cls.dhcpl2_app_file = os.path.join(cls.test_path, '..', 'apps/dhcpl2relay-{}.oar'.format(dhcpl2_app_version)) |
| 117 | cls.sadis_app_file = os.path.join(cls.test_path, '..', 'apps/sadis-app-{}.oar'.format(sadis_app_version)) |
| 118 | |
| 119 | |
| 120 | @classmethod |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 121 | def setUpClass(cls): |
| 122 | ''' Activate the cord dhcpl2relay app''' |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 123 | cls.update_apps_version() |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 124 | OnosCtrl(cls.app_dhcp).deactivate() |
| 125 | time.sleep(3) |
| 126 | cls.onos_ctrl = OnosCtrl(cls.app) |
| 127 | status, _ = cls.onos_ctrl.activate() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 128 | #assert_equal(status, True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 129 | time.sleep(3) |
| 130 | cls.onos_ctrl = OnosCtrl(cls.sadis_app) |
| 131 | status, _ = cls.onos_ctrl.activate() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 132 | #assert_equal(status, True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 133 | time.sleep(3) |
| 134 | cls.dhcp_l2_relay_setup() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 135 | cls.cord_sadis_load() |
| 136 | cls.cord_l2_relay_load() |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 137 | ##start dhcpd initially with default config |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 138 | #cls.dhcpd_start() |
| 139 | |
| 140 | def setUp(self): |
| 141 | super(dhcpl2relay_exchange, self).setUp() |
| 142 | |
| 143 | def tearDown(self): |
| 144 | super(dhcpl2relay_exchange, self).tearDown() |
Thangavelu K S | af3a151 | 2017-09-06 06:34:14 -0700 | [diff] [blame^] | 145 | OnosCtrl.uninstall_app(self.dhcpl2_app_file) |
| 146 | OnosCtrl.uninstall_app(self.sadis_app_file) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 147 | |
| 148 | @classmethod |
| 149 | def tearDownClass(cls): |
| 150 | '''Deactivate the cord dhcpl2relay app''' |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 151 | #try: |
| 152 | # os.unlink('{}/dhcpd.conf'.format(cls.dhcp_data_dir)) |
| 153 | # os.unlink('{}/dhcpd.leases'.format(cls.dhcp_data_dir)) |
| 154 | #except: pass |
| 155 | OnosCtrl.uninstall_app(cls.dhcpl2_app_file) |
| 156 | OnosCtrl.uninstall_app(cls.sadis_app_file) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 157 | cls.onos_ctrl.deactivate() |
Thangavelu K S | af3a151 | 2017-09-06 06:34:14 -0700 | [diff] [blame^] | 158 | OnosCtrl(cls.app).deactivate() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 159 | #cls.dhcpd_stop() |
Thangavelu K S | af3a151 | 2017-09-06 06:34:14 -0700 | [diff] [blame^] | 160 | #cls.dhcp_l2_relay_cleanup() |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 161 | |
| 162 | @classmethod |
| 163 | def dhcp_l2_relay_setup(cls): |
| 164 | did = OnosCtrl.get_device_id() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 165 | #cls.relay_device_id = did |
| 166 | ### Have to change hard coded value in relay device variable on later merges |
| 167 | cls.relay_device_id = 'of:000012b722fd4948' |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 168 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 169 | cls.port_map, _ = cls.olt.olt_port_map() |
| 170 | if cls.port_map: |
| 171 | ##Per subscriber, we use 1 relay port |
| 172 | try: |
| 173 | relay_port = cls.port_map[cls.port_map['relay_ports'][0]] |
| 174 | except: |
| 175 | relay_port = cls.port_map['uplink'] |
| 176 | cls.relay_interface_port = relay_port |
| 177 | cls.relay_interfaces = (cls.port_map[cls.relay_interface_port],) |
| 178 | else: |
| 179 | cls.relay_interface_port = 100 |
| 180 | cls.relay_interfaces = (g_subscriber_port_map[cls.relay_interface_port],) |
| 181 | cls.relay_interfaces_last = cls.relay_interfaces |
| 182 | if cls.port_map: |
| 183 | ##generate a ip/mac client virtual interface config for onos |
| 184 | interface_list = [] |
| 185 | for port in cls.port_map['ports']: |
| 186 | port_num = cls.port_map[port] |
| 187 | if port_num == cls.port_map['uplink']: |
| 188 | continue |
| 189 | ip = cls.get_host_ip(port_num) |
| 190 | mac = cls.get_mac(port) |
| 191 | interface_list.append((port_num, ip, mac)) |
| 192 | |
| 193 | #configure dhcp server virtual interface on the same subnet as first client interface |
| 194 | relay_ip = cls.get_host_ip(interface_list[0][0]) |
| 195 | relay_mac = cls.get_mac(cls.port_map[cls.relay_interface_port]) |
| 196 | interface_list.append((cls.relay_interface_port, relay_ip, relay_mac)) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 197 | #cls.onos_interface_load(interface_list) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 198 | |
| 199 | @classmethod |
| 200 | def dhcp_l2_relay_cleanup(cls): |
| 201 | ##reset the ONOS port configuration back to default |
| 202 | for config in cls.configs.items(): |
| 203 | OnosCtrl.delete(config) |
| 204 | # if cls.onos_restartable is True: |
| 205 | # log_test.info('Cleaning up dhcp relay config by restarting ONOS with default network cfg') |
| 206 | # return cord_test_onos_restart(config = {}) |
| 207 | |
| 208 | @classmethod |
| 209 | def onos_load_config(cls, config): |
| 210 | status, code = OnosCtrl.config(config) |
| 211 | if status is False: |
| 212 | log_test.info('JSON request returned status %d' %code) |
| 213 | assert_equal(status, True) |
| 214 | time.sleep(3) |
| 215 | |
| 216 | @classmethod |
| 217 | def onos_interface_load(cls, interface_list): |
| 218 | interface_dict = { 'ports': {} } |
| 219 | for port_num, ip, mac in interface_list: |
| 220 | port_map = interface_dict['ports'] |
| 221 | port = '{}/{}'.format(cls.relay_device_id, port_num) |
| 222 | port_map[port] = { 'interfaces': [] } |
| 223 | interface_list = port_map[port]['interfaces'] |
| 224 | interface_map = { 'ips' : [ '{}/{}'.format(ip, 24) ], |
| 225 | 'mac' : mac, |
| 226 | 'name': 'vir-{}'.format(port_num) |
| 227 | } |
| 228 | interface_list.append(interface_map) |
| 229 | |
| 230 | cls.onos_load_config(interface_dict) |
| 231 | cls.configs['interface_config'] = interface_dict |
| 232 | |
| 233 | @classmethod |
| 234 | def cord_l2_relay_load(cls): |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 235 | OnosCtrl.uninstall_app(cls.dhcpl2_app_file) |
| 236 | #relay_device_map = '{}/{}'.format(cls.relay_device_id, cls.relay_interface_port) |
Thangavelu K S | af3a151 | 2017-09-06 06:34:14 -0700 | [diff] [blame^] | 237 | relay_device_map = "{}/12".format(cls.relay_device_id) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 238 | print relay_device_map |
| 239 | dhcp_dict = { "apps" : { "org.opencord.dhcpl2relay" : {"dhcpl2relay" : |
| 240 | {"dhcpserverConnectPoint":[relay_device_map]} |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | } |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 244 | print "---------------------------------------------" |
| 245 | print dhcp_dict |
| 246 | print "---------------------------------------------" |
| 247 | OnosCtrl.uninstall_app(cls.dhcpl2_app_file) |
| 248 | OnosCtrl.install_app(cls.dhcpl2_app_file) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 249 | cls.onos_load_config(dhcp_dict) |
| 250 | cls.configs['relay_config'] = dhcp_dict |
| 251 | |
| 252 | @classmethod |
| 253 | def cord_sadis_load(cls): |
| 254 | relay_device_id = '{}'.format(cls.relay_device_id) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 255 | sadis_dict = { "apps": { |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 256 | "org.opencord.sadis": { |
| 257 | "sadis": { |
| 258 | "integration": { |
| 259 | "cache": { |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 260 | "enabled": "true", |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 261 | "maxsize": 50, |
| 262 | "ttl": "PT1m" |
| 263 | } |
| 264 | }, |
| 265 | "entries": [{ |
| 266 | "id": "uni-254", |
| 267 | "cTag": 202, |
| 268 | "sTag": 222, |
| 269 | "nasPortId": "uni-254" |
| 270 | }, |
| 271 | { |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 272 | "id": "67cc7ae085204e3091493db645e8ae63", |
| 273 | "hardwareIdentifier": "00:0c:e2:31:05:00", |
| 274 | "ipAddress": "172.17.0.1", |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 275 | "nasId": "B100-NASID" |
| 276 | } |
| 277 | ] |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 278 | } |
| 279 | } |
| 280 | } |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 281 | } |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 282 | OnosCtrl.uninstall_app(cls.sadis_app_file) |
| 283 | OnosCtrl.install_app(cls.sadis_app_file) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 284 | cls.onos_load_config(sadis_dict) |
| 285 | cls.configs['relay_config'] = sadis_dict |
| 286 | |
| 287 | @classmethod |
| 288 | def get_host_ip(cls, port): |
| 289 | if cls.host_ip_map.has_key(port): |
| 290 | return cls.host_ip_map[port] |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 291 | cls.host_ip_map[port] = '192.168.100.{}'.format(port) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 292 | return cls.host_ip_map[port] |
| 293 | |
| 294 | @classmethod |
| 295 | def host_load(cls, iface): |
| 296 | '''Have ONOS discover the hosts for dhcp-relay responses''' |
| 297 | port = g_subscriber_port_map[iface] |
| 298 | host = '173.17.1.{}'.format(port) |
| 299 | cmds = ( 'ifconfig {} 0'.format(iface), |
| 300 | 'ifconfig {0} {1}'.format(iface, host), |
| 301 | 'arping -I {0} {1} -c 2'.format(iface, host), |
| 302 | 'ifconfig {} 0'.format(iface), ) |
| 303 | for c in cmds: |
| 304 | os.system(c) |
| 305 | |
| 306 | @classmethod |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 307 | def get_mac(cls, iface): |
| 308 | if cls.interface_to_mac_map.has_key(iface): |
| 309 | return cls.interface_to_mac_map[iface] |
| 310 | mac = get_mac(iface, pad = 0) |
| 311 | cls.interface_to_mac_map[iface] = mac |
| 312 | return mac |
| 313 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 314 | def dhcpl2relay_stats_calc(self, success_rate = False, only_discover = False, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 315 | |
| 316 | self.ip_count = 0 |
| 317 | self.failure_count = 0 |
| 318 | self.start_time = 0 |
| 319 | self.diff = 0 |
| 320 | self.transaction_count = 0 |
| 321 | |
| 322 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 323 | self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = iface) |
| 324 | self.start_time = time.time() |
| 325 | |
| 326 | while self.diff <= 60: |
| 327 | |
| 328 | if only_discover: |
| 329 | cip, sip, mac, _ = self.dhcp.only_discover(multiple = True) |
| 330 | log_test.info('Got dhcp client IP %s from server %s for mac %s' % |
| 331 | (cip, sip, mac)) |
| 332 | else: |
| 333 | cip, sip = self.send_recv(mac=mac, update_seed = True, validate = False) |
| 334 | |
| 335 | if cip: |
| 336 | self.ip_count +=1 |
| 337 | elif cip == None: |
| 338 | self.failure_count += 1 |
| 339 | log_test.info('Failed to get ip') |
| 340 | if success_rate and self.ip_count > 0: |
| 341 | break |
| 342 | |
| 343 | self.diff = round(time.time() - self.start_time, 0) |
| 344 | |
| 345 | self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2) |
| 346 | self.transactions += (self.ip_count+self.failure_count) |
| 347 | self.running_time += self.diff |
| 348 | self.total_success += self.ip_count |
| 349 | self.total_failure += self.failure_count |
| 350 | |
| 351 | def send_recv(self, mac=None, update_seed = False, validate = True): |
| 352 | cip, sip = self.dhcp.discover(mac = mac, update_seed = update_seed) |
| 353 | if validate: |
| 354 | assert_not_equal(cip, None) |
| 355 | assert_not_equal(sip, None) |
| 356 | log_test.info('Got dhcp client IP %s from server %s for mac %s' % |
| 357 | (cip, sip, self.dhcp.get_mac(cip)[0])) |
| 358 | return cip,sip |
| 359 | |
| 360 | def test_dhcpl2relay_with_one_request(self, iface = 'veth0'): |
| 361 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 362 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 363 | self.send_recv(mac=mac) |
| 364 | |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 365 | def test_dhcpl2relay_app_install(self): |
| 366 | pass |
| 367 | |
| 368 | def test_dhcpl2relay_netcfg(self): |
| 369 | pass |
| 370 | |
| 371 | def test_dhcpl2relay_with_array_of_connect_points_for_dhcp_server(self): |
| 372 | pass |
| 373 | |
| 374 | def test_dhcpl2relay_with_subscriber_configured_with_ctag_stag_as_per_sadis(self): |
| 375 | pass |
| 376 | |
| 377 | def test_dhcpl2relay_app_activation_and_deactivation_multiple_times(self): |
| 378 | pass |
| 379 | |
| 380 | def test_dhcpl2relay_without_sadis_app(self): |
| 381 | pass |
| 382 | |
| 383 | def test_dhcpl2relay_with_sadis_app(self): |
| 384 | pass |
| 385 | |
| 386 | def test_dhcpl2relay_with_option_82(self): |
| 387 | pass |
| 388 | |
| 389 | def test_dhcpl2relay_without_option_82(self): |
| 390 | pass |
| 391 | |
| 392 | def test_dhcl2relay_for_option82_without_configuring_dhcpserver_to_accept_option82(self): |
| 393 | pass |
| 394 | |
| 395 | def test_dhcpl2relay_with_uni_port_entry_sadis_config(self): |
| 396 | pass |
| 397 | |
| 398 | def test_dhcpl2relay_with_wrong_ctag_options(self): |
| 399 | pass |
| 400 | |
| 401 | def test_dhcpl2relay_with_wrong_stag_options(self): |
| 402 | pass |
| 403 | |
| 404 | def test_dhcpl2relay_with_nasportid_option_in_sadis(self): |
| 405 | pass |
| 406 | |
| 407 | def test_dhcpl2relay_with_nasportid_different_from_id(self): |
| 408 | pass |
| 409 | |
| 410 | def test_dhcpl2relay_with_serial_id_of_olt(self): |
| 411 | pass |
| 412 | |
| 413 | def test_dhcpl2relay_with_wrong_serial_id_of_olt(self): |
| 414 | pass |
| 415 | |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 416 | def test_dhcpl2relay_for_one_request_with_invalid_source_mac_broadcast(self, iface = 'veth0'): |
| 417 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 418 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 419 | cip, sip, mac, _ = self.dhcp.only_discover(mac='ff:ff:ff:ff:ff:ff') |
| 420 | assert_equal(cip,None) |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 421 | log_test.info('Dhcp server rejected client discover with invalid source mac, as expected') |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 422 | |
| 423 | def test_dhcpl2relay_for_one_request_with_invalid_source_mac_multicast(self, iface = 'veth0'): |
| 424 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 425 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 426 | cip, sip, mac, _ = self.dhcp.only_discover(mac='01:80:c2:01:98:05') |
| 427 | assert_equal(cip,None) |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 428 | log_test.info('Dhcp server rejected client discover with invalid source mac, as expected') |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 429 | |
| 430 | def test_dhcpl2relay_for_one_request_with_invalid_source_mac_zero(self, iface = 'veth0'): |
| 431 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 432 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 433 | cip, sip, mac, _ = self.dhcp.only_discover(mac='00:00:00:00:00:00') |
| 434 | assert_equal(cip,None) |
| 435 | log_test.info('dhcp server rejected client discover with invalid source mac, as expected') |
| 436 | |
| 437 | def test_dhcpl2relay_with_N_requests(self, iface = 'veth0',requests=10): |
| 438 | mac = self.get_mac(iface) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 439 | self.dhcp = DHCPTest(seed_ip = '192.169.100.1', iface = iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 440 | ip_map = {} |
| 441 | for i in range(requests): |
| 442 | #mac = RandMAC()._fix() |
| 443 | #log_test.info('mac is %s'%mac) |
| 444 | cip, sip = self.send_recv(update_seed = True) |
| 445 | if ip_map.has_key(cip): |
| 446 | log_test.info('IP %s given out multiple times' %cip) |
| 447 | assert_equal(False, ip_map.has_key(cip)) |
| 448 | ip_map[cip] = sip |
| 449 | time.sleep(1) |
| 450 | |
| 451 | def test_dhcpl2relay_with_one_release(self, iface = 'veth0'): |
| 452 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 453 | self.dhcp = DHCPTest(seed_ip = '10.10.100.10', iface = iface) |
| 454 | cip, sip = self.send_recv(mac=mac) |
| 455 | log_test.info('Releasing ip %s to server %s' %(cip, sip)) |
| 456 | assert_equal(self.dhcp.release(cip), True) |
| 457 | log_test.info('Triggering DHCP discover again after release') |
| 458 | cip2, sip2 = self.send_recv(mac=mac) |
| 459 | log_test.info('Verifying released IP was given back on rediscover') |
| 460 | assert_equal(cip, cip2) |
| 461 | log_test.info('Test done. Releasing ip %s to server %s' %(cip2, sip2)) |
| 462 | assert_equal(self.dhcp.release(cip2), True) |
| 463 | |
| 464 | def test_dhcpl2relay_with_Nreleases(self, iface = 'veth0'): |
| 465 | mac = None |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 466 | self.dhcp = DHCPTest(seed_ip = '192.170.1.10', iface = iface) |
| 467 | ip_map = {} |
| 468 | for i in range(10): |
| 469 | cip, sip = self.send_recv(mac=mac, update_seed = True) |
| 470 | if ip_map.has_key(cip): |
| 471 | log_test.info('IP %s given out multiple times' %cip) |
| 472 | assert_equal(False, ip_map.has_key(cip)) |
| 473 | ip_map[cip] = sip |
| 474 | |
| 475 | for ip in ip_map.keys(): |
| 476 | log_test.info('Releasing IP %s' %ip) |
| 477 | assert_equal(self.dhcp.release(ip), True) |
| 478 | |
| 479 | ip_map2 = {} |
| 480 | log_test.info('Triggering DHCP discover again after release') |
| 481 | self.dhcp = DHCPTest(seed_ip = '192.170.1.10', iface = iface) |
| 482 | for i in range(len(ip_map.keys())): |
| 483 | cip, sip = self.send_recv(mac=mac, update_seed = True) |
| 484 | ip_map2[cip] = sip |
| 485 | |
| 486 | log_test.info('Verifying released IPs were given back on rediscover') |
| 487 | if ip_map != ip_map2: |
| 488 | log_test.info('Map before release %s' %ip_map) |
| 489 | log_test.info('Map after release %s' %ip_map2) |
| 490 | assert_equal(ip_map, ip_map2) |
| 491 | |
| 492 | def test_dhcpl2relay_starvation(self, iface = 'veth0'): |
| 493 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 494 | self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = iface) |
| 495 | log_test.info('Verifying 1 ') |
| 496 | count = 0 |
| 497 | while True: |
| 498 | #mac = RandMAC()._fix() |
| 499 | cip, sip = self.send_recv(update_seed = True,validate = False) |
| 500 | if cip is None: |
| 501 | break |
| 502 | else: |
| 503 | count += 1 |
| 504 | assert_equal(count,91) |
| 505 | log_test.info('Verifying 2 ') |
| 506 | cip, sip = self.send_recv(mac=mac, update_seed = True, validate = False) |
| 507 | assert_equal(cip, None) |
| 508 | assert_equal(sip, None) |
| 509 | |
| 510 | def test_dhcpl2relay_with_same_client_and_multiple_discovers(self, iface = 'veth0'): |
| 511 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 512 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 513 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 514 | log_test.info('Got dhcp client IP %s from server %s for mac %s . Not going to send DHCPREQUEST.' % |
| 515 | (cip, sip, mac) ) |
| 516 | assert_not_equal(cip, None) |
| 517 | log_test.info('Triggering DHCP discover again.') |
| 518 | new_cip, new_sip, new_mac, _ = self.dhcp.only_discover() |
| 519 | assert_equal(new_cip, cip) |
| 520 | log_test.info('got same ip to smae the client when sent discover again, as expected') |
| 521 | |
| 522 | def test_dhcpl2relay_with_same_client_and_multiple_requests(self, iface = 'veth0'): |
| 523 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 524 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 525 | log_test.info('Sending DHCP discover and DHCP request.') |
| 526 | cip, sip = self.send_recv(mac=mac) |
| 527 | mac = self.dhcp.get_mac(cip)[0] |
| 528 | log_test.info("Sending DHCP request again.") |
| 529 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 530 | assert_equal(new_cip, cip) |
| 531 | log_test.info('got same ip to smae the client when sent request again, as expected') |
| 532 | |
| 533 | def test_dhcpl2relay_with_clients_desired_address(self, iface = 'veth0'): |
| 534 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 535 | self.dhcp = DHCPTest(seed_ip = '192.168.1.31', iface = iface) |
| 536 | cip, sip, mac, _ = self.dhcp.only_discover(desired = True) |
| 537 | assert_equal(cip,self.dhcp.seed_ip) |
| 538 | log_test.info('Got dhcp client desired IP %s from server %s for mac %s as expected' % |
| 539 | (cip, sip, mac) ) |
| 540 | |
| 541 | def test_dhcpl2relay_with_clients_desired_address_in_out_of_pool(self, iface = 'veth0'): |
| 542 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 543 | self.dhcp = DHCPTest(seed_ip = '20.20.20.35', iface = iface) |
| 544 | cip, sip, mac, _ = self.dhcp.only_discover(desired = True) |
| 545 | assert_not_equal(cip,None) |
| 546 | assert_not_equal(cip,self.dhcp.seed_ip) |
| 547 | log_test.info('server offered IP from its pool when requested out of pool IP, as expected') |
| 548 | |
| 549 | def test_dhcpl2relay_nak_packet(self, iface = 'veth0'): |
| 550 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 551 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 552 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 553 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 554 | (cip, sip, mac) ) |
| 555 | assert_not_equal(cip, None) |
| 556 | new_cip, new_sip = self.dhcp.only_request('20.20.20.31', mac) |
| 557 | assert_equal(new_cip, None) |
| 558 | log_test.info('server sent NAK packet when requested other IP than that server offered') |
| 559 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 560 | def test_dhcpl2relay_with_client_requests_with_specific_lease_time_in_discover_message(self, iface = 'veth0',lease_time=700): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 561 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 562 | self.dhcp = DHCPTest(seed_ip = '10.10.10.70', iface = iface) |
| 563 | self.dhcp.return_option = 'lease' |
| 564 | cip, sip, mac, lval = self.dhcp.only_discover(lease_time=True,lease_value=lease_time) |
| 565 | assert_equal(lval, lease_time) |
| 566 | log_test.info('dhcp server offered IP address with client requested lease time') |
| 567 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 568 | def test_dhcpl2relay_with_client_request_after_reboot(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 569 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 570 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 571 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 572 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 573 | (cip, sip, mac) ) |
| 574 | assert_not_equal(cip, None) |
| 575 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 576 | log_test.info('client rebooting...') |
| 577 | os.system('ifconfig '+iface+' down') |
| 578 | time.sleep(5) |
| 579 | os.system('ifconfig '+iface+' up') |
| 580 | new_cip2, new_sip = self.dhcp.only_request(cip, mac, cl_reboot = True) |
| 581 | assert_equal(new_cip2, cip) |
| 582 | log_test.info('client got same IP after reboot, as expected') |
| 583 | |
| 584 | |
| 585 | def test_dhcpl2relay_after_server_reboot(self, iface = 'veth0'): |
| 586 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 587 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 588 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 589 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 590 | (cip, sip, mac) ) |
| 591 | assert_not_equal(cip, None) |
| 592 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 593 | log_test.info('server rebooting...') |
| 594 | self.tearDownClass() |
| 595 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 596 | assert_equal(new_cip,None) |
| 597 | self.setUpClass() |
| 598 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 599 | assert_equal(new_cip, cip) |
| 600 | log_test.info('client got same IP after server rebooted, as expected') |
| 601 | |
| 602 | def test_dhcpl2relay_specific_lease_time_only_in_discover_but_not_in_request_packet(self, iface = 'veth0',lease_time=700): |
| 603 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 604 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 605 | self.dhcp.return_option = 'lease' |
| 606 | log_test.info('Sending DHCP discover with lease time of 700') |
| 607 | cip, sip, mac, lval = self.dhcp.only_discover(lease_time = True, lease_value=lease_time) |
| 608 | assert_equal(lval,lease_time) |
| 609 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, lease_time = True) |
| 610 | assert_equal(new_cip,cip) |
| 611 | assert_not_equal(lval, lease_time) #Negative Test Case |
| 612 | log_test.info('client requested lease time in discover packer is not seen in server ACK packet as expected') |
| 613 | |
| 614 | def test_dhcpl2relay_specific_lease_time_only_in_request_but_not_in_discover_packet(self, iface = 'veth0',lease_time=800): |
| 615 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 616 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 617 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 618 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, lease_time = True,lease_value=lease_time) |
| 619 | assert_equal(new_cip,cip) |
| 620 | assert_equal(lval, lease_time) |
| 621 | log_test.info('client requested lease time in request packet seen in servre replied ACK packet as expected') |
| 622 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 623 | def test_dhcpl2relay_with_client_renew_time(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 624 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 625 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 626 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 627 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 628 | (cip, sip, mac) ) |
| 629 | assert_not_equal(cip,None) |
| 630 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, renew_time = True) |
| 631 | log_test.info('waiting for renew time..') |
| 632 | time.sleep(lval) |
| 633 | latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac, unicast = True) |
| 634 | assert_equal(latest_cip, cip) |
| 635 | log_test.info('server renewed client IP when client sends request after renew time, as expected') |
| 636 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 637 | def test_dhcpl2relay_with_client_rebind_time(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 638 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 639 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 640 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 641 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 642 | (cip, sip, mac) ) |
| 643 | assert_not_equal(cip,None) |
| 644 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, rebind_time = True) |
| 645 | log_test.info('waiting for rebind time..') |
| 646 | time.sleep(lval) |
| 647 | latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac) |
| 648 | assert_equal(latest_cip, cip) |
| 649 | log_test.info('server renewed client IP when client sends request after rebind time, as expected') |
| 650 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 651 | def test_dhcpl2relay_with_client_expected_subnet_mask(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 652 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 653 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 654 | expected_subnet = '255.255.255.0' |
| 655 | self.dhcp.return_option = 'subnet' |
| 656 | |
| 657 | cip, sip, mac, subnet_mask = self.dhcp.only_discover() |
| 658 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 659 | (cip, sip, mac) ) |
| 660 | assert_equal(subnet_mask,expected_subnet) |
| 661 | log_test.info('subnet mask in server offer packet is same as configured subnet mask in dhcp server') |
| 662 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 663 | def test_dhcpl2relay_with_client_sending_dhcp_request_with_wrong_subnet_mask(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 664 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 665 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 666 | |
| 667 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 668 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 669 | (cip, sip, mac) ) |
| 670 | assert_not_equal(cip,None) |
| 671 | self.dhcp.send_different_option = 'subnet' |
| 672 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 673 | assert_equal(new_cip, cip) |
| 674 | log_test.info("Got DHCP Ack despite of specifying wrong Subnet Mask in DHCP Request.") |
| 675 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 676 | def test_dhcpl2relay_with_client_expected_router_address(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 677 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 678 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 679 | expected_router_address = '20.20.20.1' |
| 680 | self.dhcp.return_option = 'router' |
| 681 | |
| 682 | cip, sip, mac, router_address_value = self.dhcp.only_discover() |
| 683 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 684 | (cip, sip, mac) ) |
| 685 | assert_equal(expected_router_address, router_address_value) |
| 686 | log_test.info('router address in server offer packet is same as configured router address in dhcp server') |
| 687 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 688 | def test_dhcpl2relay_with_client_sends_dhcp_request_with_wrong_router_address(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 689 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 690 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 691 | |
| 692 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 693 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 694 | (cip, sip, mac) ) |
| 695 | assert_not_equal(cip,None) |
| 696 | self.dhcp.send_different_option = 'router' |
| 697 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 698 | assert_equal(new_cip, cip) |
| 699 | log_test.info("Got DHCP Ack despite of specifying wrong Router Address in DHCP Request.") |
| 700 | |
| 701 | def test_dhcpl2relay_with_client_expecting_broadcast_address(self, iface = 'veth0'): |
| 702 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 703 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 704 | expected_broadcast_address = '192.168.1.255' |
| 705 | self.dhcp.return_option = 'broadcast_address' |
| 706 | |
| 707 | cip, sip, mac, broadcast_address_value = self.dhcp.only_discover() |
| 708 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 709 | (cip, sip, mac) ) |
| 710 | assert_equal(expected_broadcast_address, broadcast_address_value) |
| 711 | log_test.info('broadcast address in server offer packet is same as configured broadcast address in dhcp server') |
| 712 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 713 | def test_dhcpl2relay_with_client_sends_dhcp_request_with_wrong_broadcast_address(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 714 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 715 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 716 | |
| 717 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 718 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 719 | (cip, sip, mac) ) |
| 720 | assert_not_equal(cip,None) |
| 721 | self.dhcp.send_different_option = 'broadcast_address' |
| 722 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 723 | assert_equal(new_cip, cip) |
| 724 | log_test.info("Got DHCP Ack despite of specifying wrong Broadcast Address in DHCP Request.") |
| 725 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 726 | def test_dhcpl2relay_with_client_expecting_dns_address(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 727 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 728 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 729 | expected_dns_address = '192.168.1.1' |
| 730 | self.dhcp.return_option = 'dns' |
| 731 | |
| 732 | cip, sip, mac, dns_address_value = self.dhcp.only_discover() |
| 733 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 734 | (cip, sip, mac) ) |
| 735 | assert_equal(expected_dns_address, dns_address_value) |
| 736 | log_test.info('dns address in server offer packet is same as configured dns address in dhcp server') |
| 737 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 738 | def test_dhcpl2relay_with_client_sends_request_with_wrong_dns_address(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 739 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 740 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 741 | |
| 742 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 743 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 744 | (cip, sip, mac) ) |
| 745 | assert_not_equal(cip,None) |
| 746 | self.dhcp.send_different_option = 'dns' |
| 747 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 748 | assert_equal(new_cip, cip) |
| 749 | log_test.info("Got DHCP Ack despite of specifying wrong DNS Address in DHCP Request.") |
| 750 | |
| 751 | |
| 752 | def test_dhcpl2relay_transactions_per_second(self, iface = 'veth0'): |
| 753 | |
| 754 | for i in range(1,4): |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 755 | self.dhcpl2relay_stats_calc() |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 756 | log_test.info("Statistics for run %d",i) |
| 757 | log_test.info("----------------------------------------------------------------------------------") |
| 758 | log_test.info("No. of transactions No. of successes No. of failures Running Time ") |
| 759 | log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff)) |
| 760 | log_test.info("----------------------------------------------------------------------------------") |
| 761 | log_test.info("No. of transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 762 | |
| 763 | log_test.info("Final Statistics for total transactions") |
| 764 | log_test.info("----------------------------------------------------------------------------------") |
| 765 | log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 766 | log_test.info(" %d %d %d %d" %(self.transactions, |
| 767 | self.total_success, self.total_failure, self.running_time)) |
| 768 | log_test.info("----------------------------------------------------------------------------------") |
| 769 | log_test.info("Average no. of transactions per second: %d", round(self.transactions/self.running_time,0)) |
| 770 | |
| 771 | def test_dhcpl2relay_consecutive_successes_per_second(self, iface = 'veth0'): |
| 772 | |
| 773 | for i in range(1,4): |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 774 | self.dhcpl2relay_stats_calc(success_rate = True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 775 | log_test.info("Statistics for run %d",i) |
| 776 | log_test.info("----------------------------------------------------------------------------------") |
| 777 | log_test.info("No. of consecutive successful transactions Running Time ") |
| 778 | log_test.info(" %d %d " %(self.ip_count, self.diff)) |
| 779 | log_test.info("----------------------------------------------------------------------------------") |
| 780 | log_test.info("No. of successful transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 781 | log_test.info("----------------------------------------------------------------------------------") |
| 782 | |
| 783 | log_test.info("Final Statistics for total successful transactions") |
| 784 | log_test.info("----------------------------------------------------------------------------------") |
| 785 | log_test.info("Total transactions Total No. of consecutive successes Running Time ") |
| 786 | log_test.info(" %d %d %d " %(self.transactions, |
| 787 | self.total_success, self.running_time)) |
| 788 | log_test.info("----------------------------------------------------------------------------------") |
| 789 | log_test.info("Average no. of consecutive successful transactions per second: %d", round(self.total_success/self.running_time,0)) |
| 790 | log_test.info("----------------------------------------------------------------------------------") |
| 791 | |
| 792 | def test_dhcpl2relay_with_max_clients_per_second(self, iface = 'veth0'): |
| 793 | |
| 794 | for i in range(1,4): |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 795 | self.dhcpl2relay_stats_calc(only_discover = True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 796 | log_test.info("----------------------------------------------------------------------------------") |
| 797 | log_test.info("Statistics for run %d of sending only DHCP Discover",i) |
| 798 | log_test.info("----------------------------------------------------------------------------------") |
| 799 | log_test.info("No. of transactions No. of successes No. of failures Running Time ") |
| 800 | log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff)) |
| 801 | log_test.info("----------------------------------------------------------------------------------") |
| 802 | log_test.info("No. of clients per second in run %d:%f " |
| 803 | %(i, self.transaction_count)) |
| 804 | log_test.info("----------------------------------------------------------------------------------") |
| 805 | log_test.info("Final Statistics for total transactions of sending only DHCP Discover") |
| 806 | log_test.info("----------------------------------------------------------------------------------") |
| 807 | log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 808 | log_test.info(" %d %d %d %d" %(self.transactions, |
| 809 | self.total_success, self.total_failure, self.running_time)) |
| 810 | log_test.info("----------------------------------------------------------------------------------") |
| 811 | log_test.info("Average no. of clients per second: %d ", |
| 812 | round(self.transactions/self.running_time,0)) |
| 813 | log_test.info("----------------------------------------------------------------------------------") |
| 814 | |
| 815 | def test_dhcpl2relay_consecutive_successful_clients_per_second(self, iface = 'veth0'): |
| 816 | |
| 817 | for i in range(1,4): |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 818 | self.dhcpl2relay_stats_calc(success_rate = True, only_discover = True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 819 | log_test.info("----------------------------------------------------------------------------------") |
| 820 | log_test.info("Statistics for run %d for sending only DHCP Discover",i) |
| 821 | log_test.info("----------------------------------------------------------------------------------") |
| 822 | log_test.info("No. of consecutive successful transactions Running Time ") |
| 823 | log_test.info(" %d %d " %(self.ip_count, self.diff)) |
| 824 | log_test.info("----------------------------------------------------------------------------------") |
| 825 | log_test.info("No. of consecutive successful clients per second in run %d:%f" %(i, self.transaction_count)) |
| 826 | log_test.info("----------------------------------------------------------------------------------") |
| 827 | |
| 828 | log_test.info("Final Statistics for total successful transactions") |
| 829 | log_test.info("----------------------------------------------------------------------------------") |
| 830 | log_test.info("Total transactions Total No. of consecutive successes Running Time ") |
| 831 | log_test.info(" %d %d %d " %(self.transactions, |
| 832 | self.total_success, self.running_time)) |
| 833 | log_test.info("----------------------------------------------------------------------------------") |
| 834 | log_test.info("Average no. of consecutive successful clients per second: %d", round(self.total_success/self.running_time,0)) |
| 835 | log_test.info("----------------------------------------------------------------------------------") |
| 836 | |
| 837 | def test_dhcpl2relay_concurrent_transactions_per_second(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 838 | for key in (key for key in g_subscriber_port_map if key < 100): |
| 839 | self.host_load(g_subscriber_port_map[key]) |
| 840 | |
| 841 | def thread_fun(i): |
| 842 | mac = self.get_mac('veth{}'.format(i)) |
| 843 | cip, sip = DHCPTest(iface = 'veth{}'.format(i)).discover(mac = mac) |
| 844 | log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac)) |
| 845 | self.lock.acquire() |
| 846 | |
| 847 | if cip: |
| 848 | self.ip_count += 1 |
| 849 | |
| 850 | elif cip is None: |
| 851 | self.failure_count += 1 |
| 852 | |
| 853 | self.lock.notify_all() |
| 854 | self.lock.release() |
| 855 | |
| 856 | for i in range (1,4): |
| 857 | self.ip_count = 0 |
| 858 | self.failure_count = 0 |
| 859 | self.start_time = 0 |
| 860 | self.diff = 0 |
| 861 | self.transaction_count = 0 |
| 862 | self.start_time = time.time() |
| 863 | |
| 864 | while self.diff <= 60: |
| 865 | t = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(0, random.randrange(1,40,1), 1)}) |
| 866 | t1 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(42, random.randrange(43,80,1), 1)}) |
| 867 | t2 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(82, random.randrange(83,120,1), 1)}) |
| 868 | t3 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(122, random.randrange(123,160,1), 1)}) |
| 869 | t4 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(162, random.randrange(163,180,1), 1)}) |
| 870 | t5 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(182, random.randrange(183,196,1), 1)}) |
| 871 | |
| 872 | t.start() |
| 873 | t1.start() |
| 874 | t2.start() |
| 875 | t3.start() |
| 876 | t4.start() |
| 877 | t5.start() |
| 878 | |
| 879 | t.join() |
| 880 | t1.join() |
| 881 | t2.join() |
| 882 | t3.join() |
| 883 | t4.join() |
| 884 | t5.join() |
| 885 | |
| 886 | self.diff = round(time.time() - self.start_time, 0) |
| 887 | |
| 888 | self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2) |
| 889 | |
| 890 | self.transactions += (self.ip_count+self.failure_count) |
| 891 | self.running_time += self.diff |
| 892 | self.total_success += self.ip_count |
| 893 | self.total_failure += self.failure_count |
| 894 | |
| 895 | |
| 896 | log_test.info("----------------------------------------------------------------------------------") |
| 897 | log_test.info("Statistics for run %d",i) |
| 898 | log_test.info("----------------------------------------------------------------------------------") |
| 899 | log_test.info("No. of transactions No. of successes No. of failures Running Time ") |
| 900 | log_test.info(" %d %d %d %d" |
| 901 | %(self.ip_count+self.failure_count,self.ip_count, self.failure_count, self.diff)) |
| 902 | log_test.info("----------------------------------------------------------------------------------") |
| 903 | log_test.info("No. of transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 904 | log_test.info("----------------------------------------------------------------------------------") |
| 905 | |
| 906 | log_test.info("----------------------------------------------------------------------------------") |
| 907 | log_test.info("Final Statistics for total transactions") |
| 908 | log_test.info("----------------------------------------------------------------------------------") |
| 909 | log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 910 | log_test.info(" %d %d %d %d" %(self.transactions, |
| 911 | self.total_success, self.total_failure, self.running_time)) |
| 912 | |
| 913 | log_test.info("----------------------------------------------------------------------------------") |
| 914 | log_test.info("Average no. of transactions per second: %d", round(self.transactions/self.running_time,0)) |
| 915 | log_test.info("----------------------------------------------------------------------------------") |
| 916 | |
| 917 | def test_dhcpl2relay_concurrent_consecutive_successes_per_second(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 918 | failure_dir = {} |
| 919 | |
| 920 | for key in (key for key in g_subscriber_port_map if key != 100): |
| 921 | self.host_load(g_subscriber_port_map[key]) |
| 922 | |
| 923 | def thread_fun(i, j): |
| 924 | # log_test.info("Thread Name:%s",current_thread().name) |
| 925 | # failure_dir[current_thread().name] = True |
| 926 | while failure_dir.has_key(current_thread().name) is False: |
| 927 | mac = RandMAC()._fix() |
| 928 | cip, sip = DHCPTest(iface = 'veth{}'.format(i)).discover(mac = mac) |
| 929 | i += 2 |
| 930 | log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac)) |
| 931 | self.lock.acquire() |
| 932 | |
| 933 | if cip: |
| 934 | self.ip_count += 1 |
| 935 | self.lock.notify_all() |
| 936 | self.lock.release() |
| 937 | elif cip is None: |
| 938 | self.failure_count += 1 |
| 939 | failure_dir[current_thread().name] = True |
| 940 | self.lock.notify_all() |
| 941 | self.lock.release() |
| 942 | break |
| 943 | # self.lock.notify_all() |
| 944 | # self.lock.release() |
| 945 | |
| 946 | for i in range (1,4): |
| 947 | failure_dir = {} |
| 948 | self.ip_count = 0 |
| 949 | self.failure_count = 0 |
| 950 | self.start_time = 0 |
| 951 | self.diff = 0 |
| 952 | self.transaction_count = 0 |
| 953 | self.start_time = time.time() |
| 954 | |
| 955 | while len(failure_dir) != 6: |
| 956 | t = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 957 | t1 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 958 | t2 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 959 | t3 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 960 | t4 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 961 | t5 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 962 | |
| 963 | t.start() |
| 964 | t1.start() |
| 965 | t2.start() |
| 966 | t3.start() |
| 967 | t4.start() |
| 968 | t5.start() |
| 969 | |
| 970 | t.join() |
| 971 | t1.join() |
| 972 | t2.join() |
| 973 | t3.join() |
| 974 | t4.join() |
| 975 | t5.join() |
| 976 | |
| 977 | self.diff = round(time.time() - self.start_time, 0) |
| 978 | self.transaction_count = round((self.ip_count)/self.diff, 2) |
| 979 | |
| 980 | self.transactions += (self.ip_count+self.failure_count) |
| 981 | self.running_time += self.diff |
| 982 | self.total_success += self.ip_count |
| 983 | self.total_failure += self.failure_count |
| 984 | |
| 985 | |
| 986 | log_test.info("Statistics for run %d",i) |
| 987 | log_test.info("----------------------------------------------------------------------------------") |
| 988 | log_test.info("No. of consecutive successful transactions Running Time ") |
| 989 | log_test.info(" %d %d " %(self.ip_count, self.diff)) |
| 990 | log_test.info("----------------------------------------------------------------------------------") |
| 991 | log_test.info("No. of successful transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 992 | log_test.info("----------------------------------------------------------------------------------") |
| 993 | |
| 994 | log_test.info("Final Statistics for total successful transactions") |
| 995 | log_test.info("----------------------------------------------------------------------------------") |
| 996 | log_test.info("Total transactions Total No. of consecutive successes Running Time ") |
| 997 | log_test.info(" %d %d %d " %(self.transactions, |
| 998 | self.total_success, self.running_time)) |
| 999 | log_test.info("----------------------------------------------------------------------------------") |
| 1000 | log_test.info("Average no. of consecutive successful transactions per second: %d", round(self.total_success/self.running_time,2)) |
| 1001 | log_test.info("----------------------------------------------------------------------------------") |
| 1002 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1003 | def test_dhcpl2relay_for_concurrent_clients_per_second(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1004 | for key in (key for key in g_subscriber_port_map if key < 100): |
| 1005 | self.host_load(g_subscriber_port_map[key]) |
| 1006 | |
| 1007 | def thread_fun(i): |
| 1008 | # mac = self.get_mac('veth{}'.format(i)) |
| 1009 | cip, sip, mac, _ = DHCPTest(iface = 'veth{}'.format(i)).only_discover(mac = RandMAC()._fix()) |
| 1010 | log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac)) |
| 1011 | self.lock.acquire() |
| 1012 | |
| 1013 | if cip: |
| 1014 | self.ip_count += 1 |
| 1015 | elif cip is None: |
| 1016 | self.failure_count += 1 |
| 1017 | |
| 1018 | self.lock.notify_all() |
| 1019 | self.lock.release() |
| 1020 | |
| 1021 | for i in range (1,4): |
| 1022 | self.ip_count = 0 |
| 1023 | self.failure_count = 0 |
| 1024 | self.start_time = 0 |
| 1025 | self.diff = 0 |
| 1026 | self.transaction_count = 0 |
| 1027 | self.start_time = time.time() |
| 1028 | |
| 1029 | while self.diff <= 60: |
| 1030 | t = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(0, random.randrange(1,40,1), 1)}) |
| 1031 | t1 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(42, random.randrange(43,80,1), 1)}) |
| 1032 | t2 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(82, random.randrange(83,120,1), 1)}) |
| 1033 | t3 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(122, random.randrange(123,160,1), 1)}) |
| 1034 | t4 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(162, random.randrange(163,180,1), 1)}) |
| 1035 | t5 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(182, random.randrange(183,196,1), 1)}) |
| 1036 | |
| 1037 | t.start() |
| 1038 | t1.start() |
| 1039 | t2.start() |
| 1040 | t3.start() |
| 1041 | t4.start() |
| 1042 | t5.start() |
| 1043 | |
| 1044 | t.join() |
| 1045 | t1.join() |
| 1046 | t2.join() |
| 1047 | t3.join() |
| 1048 | t4.join() |
| 1049 | t5.join() |
| 1050 | |
| 1051 | self.diff = round(time.time() - self.start_time, 0) |
| 1052 | self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2) |
| 1053 | self.transactions += (self.ip_count+self.failure_count) |
| 1054 | self.running_time += self.diff |
| 1055 | self.total_success += self.ip_count |
| 1056 | self.total_failure += self.failure_count |
| 1057 | |
| 1058 | log_test.info("----------------------------------------------------------------------------------") |
| 1059 | log_test.info("Statistics for run %d of sending only DHCP Discover",i) |
| 1060 | log_test.info("----------------------------------------------------------------------------------") |
| 1061 | log_test.info("No. of transactions No. of successes No. of failures Running Time ") |
| 1062 | log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff)) |
| 1063 | log_test.info("----------------------------------------------------------------------------------") |
| 1064 | log_test.info("No. of clients per second in run %d:%f " |
| 1065 | %(i, self.transaction_count)) |
| 1066 | log_test.info("----------------------------------------------------------------------------------") |
| 1067 | |
| 1068 | log_test.info("Final Statistics for total transactions of sending only DHCP Discover") |
| 1069 | log_test.info("----------------------------------------------------------------------------------") |
| 1070 | log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 1071 | log_test.info(" %d %d %d %d" %(self.transactions, |
| 1072 | self.total_success, self.total_failure, self.running_time)) |
| 1073 | log_test.info("----------------------------------------------------------------------------------") |
| 1074 | log_test.info("Average no. of clients per second: %d ", |
| 1075 | round(self.transactions/self.running_time,0)) |
| 1076 | log_test.info("----------------------------------------------------------------------------------") |
| 1077 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1078 | def test_dhcpl2relay_with_client_conflict(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1079 | mac = self.get_mac(iface) |
| 1080 | self.host_load(iface) |
| 1081 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 1082 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1083 | log_test.info('Got dhcp client IP %s from server %s for mac %s.' % |
| 1084 | (cip, sip, mac) ) |
| 1085 | self.dhcp1 = DHCPTest(seed_ip = cip, iface = iface) |
| 1086 | new_cip, new_sip, new_mac, _ = self.dhcp1.only_discover(desired = True) |
| 1087 | new_cip, new_sip = self.dhcp1.only_request(new_cip, new_mac) |
| 1088 | log_test.info('Got dhcp client IP %s from server %s for mac %s.' % |
| 1089 | (new_cip, new_sip, new_mac) ) |
| 1090 | log_test.info("IP %s alredy consumed by mac %s." % (new_cip, new_mac)) |
| 1091 | log_test.info("Now sending DHCP Request for old DHCP discover.") |
| 1092 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1093 | if new_cip is None: |
| 1094 | log_test.info('Got dhcp client IP %s from server %s for mac %s.Which is expected behavior.' |
| 1095 | %(new_cip, new_sip, new_mac) ) |
| 1096 | elif new_cip: |
| 1097 | log_test.info('Got dhcp client IP %s from server %s for mac %s.Which is not expected behavior as IP %s is already consumed.' |
| 1098 | %(new_cip, new_sip, new_mac, new_cip) ) |
| 1099 | assert_equal(new_cip, None) |