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