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 |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 39 | from CordTestUtils import get_mac, log_test, getstatusoutput, get_controller |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 40 | from OnosCtrl import OnosCtrl |
| 41 | from OltConfig import OltConfig |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 42 | from CordTestServer import cord_test_onos_restart, cord_test_ovs_flow_add |
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 |
A R Karthick | e723209 | 2017-09-07 18:01:33 -0700 | [diff] [blame] | 47 | from VolthaCtrl import VolthaCtrl |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 48 | import threading, random |
| 49 | from threading import current_thread |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 50 | import requests |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 51 | log_test.setLevel('INFO') |
| 52 | |
| 53 | class dhcpl2relay_exchange(CordLogger): |
| 54 | |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 55 | VOLTHA_HOST = None |
A R Karthick | e723209 | 2017-09-07 18:01:33 -0700 | [diff] [blame] | 56 | VOLTHA_REST_PORT = VolthaCtrl.REST_PORT |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 57 | VOLTHA_ENABLED = bool(int(os.getenv('VOLTHA_ENABLED', 0))) |
| 58 | VOLTHA_OLT_TYPE = 'simulated_olt' |
| 59 | VOLTHA_OLT_MAC = '00:0c:e2:31:12:00' |
| 60 | VOLTHA_UPLINK_VLAN_MAP = { 'of:0000000000000001' : '222' } |
A R Karthick | ce96dde | 2017-10-05 16:41:52 -0700 | [diff] [blame^] | 61 | TAGGED_TRAFFIC = false |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 62 | app = 'org.opencord.dhcpl2relay' |
| 63 | sadis_app = 'org.opencord.sadis' |
| 64 | app_dhcp = 'org.onosproject.dhcp' |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 65 | app_olt = 'org.onosproject.olt' |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 66 | relay_interfaces = () |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 67 | relay_interfaces_last = () |
| 68 | interface_to_mac_map = {} |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 69 | relay_vlan_map = {} |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 70 | host_ip_map = {} |
| 71 | test_path = os.path.dirname(os.path.realpath(__file__)) |
| 72 | dhcp_data_dir = os.path.join(test_path, '..', 'setup') |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 73 | dhcpl2_app_file = os.path.join(test_path, '..', 'apps/dhcpl2relay-1.0.0.oar') |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 74 | olt_app_file = os.path.join(test_path, '..', 'apps/olt-app-3.0-SNAPSHOT.oar') |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 75 | sadis_app_file = os.path.join(test_path, '..', 'apps/sadis-app-1.0.0-SNAPSHOT.oar') |
| 76 | 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] | 77 | default_config = { 'default-lease-time' : 600, 'max-lease-time' : 7200, } |
| 78 | default_options = [ ('subnet-mask', '255.255.255.0'), |
| 79 | ('broadcast-address', '192.168.1.255'), |
| 80 | ('domain-name-servers', '192.168.1.1'), |
| 81 | ('domain-name', '"mydomain.cord-tester"'), |
| 82 | ] |
| 83 | default_subnet_config = [ ('192.168.1.2', |
| 84 | ''' |
| 85 | subnet 192.168.1.0 netmask 255.255.255.0 { |
| 86 | range 192.168.1.10 192.168.1.100; |
| 87 | } |
| 88 | '''), ] |
| 89 | |
| 90 | lock = threading.Condition() |
| 91 | ip_count = 0 |
| 92 | failure_count = 0 |
| 93 | start_time = 0 |
| 94 | diff = 0 |
| 95 | |
| 96 | transaction_count = 0 |
| 97 | transactions = 0 |
| 98 | running_time = 0 |
| 99 | total_success = 0 |
| 100 | total_failure = 0 |
| 101 | #just in case we want to reset ONOS to default network cfg after relay tests |
| 102 | onos_restartable = bool(int(os.getenv('ONOS_RESTART', 0))) |
| 103 | configs = {} |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 104 | sadis_configs = {} |
| 105 | default_onos_netcfg = {} |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 106 | voltha_switch_map = None |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 107 | |
| 108 | @classmethod |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 109 | def update_apps_version(cls): |
| 110 | version = Onos.getVersion() |
| 111 | major = int(version.split('.')[0]) |
| 112 | minor = int(version.split('.')[1]) |
| 113 | dhcpl2_app_version = '1.0.0' |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 114 | sadis_app_version = '3.0-SNAPSHOT' |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 115 | cls.dhcpl2_app_file = os.path.join(cls.test_path, '..', 'apps/dhcpl2relay-{}.oar'.format(dhcpl2_app_version)) |
| 116 | cls.sadis_app_file = os.path.join(cls.test_path, '..', 'apps/sadis-app-{}.oar'.format(sadis_app_version)) |
| 117 | |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 118 | @classmethod |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 119 | def setUpClass(cls): |
| 120 | ''' Activate the cord dhcpl2relay app''' |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 121 | cls.update_apps_version() |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 122 | OnosCtrl(cls.app_dhcp).deactivate() |
| 123 | time.sleep(3) |
| 124 | cls.onos_ctrl = OnosCtrl(cls.app) |
| 125 | status, _ = cls.onos_ctrl.activate() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 126 | #assert_equal(status, True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 127 | time.sleep(3) |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 128 | status, _ = OnosCtrl(cls.sadis_app).activate() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 129 | #assert_equal(status, True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 130 | time.sleep(3) |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 131 | cls.setup_dhcpd() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 132 | |
| 133 | def setUp(self): |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 134 | self.default_onos_netcfg = OnosCtrl.get_config() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 135 | super(dhcpl2relay_exchange, self).setUp() |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 136 | #self.dhcp_l2_relay_setup() |
| 137 | #self.cord_sadis_load() |
| 138 | #self.cord_l2_relay_load() |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 139 | |
| 140 | def tearDown(self): |
| 141 | super(dhcpl2relay_exchange, self).tearDown() |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 142 | #OnosCtrl.uninstall_app(self.dhcpl2_app_file) |
| 143 | #OnosCtrl.uninstall_app(self.sadis_app_file) |
| 144 | #OnosCtrl.uninstall_app(self.olt_app_file) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 145 | |
| 146 | @classmethod |
| 147 | def tearDownClass(cls): |
| 148 | '''Deactivate the cord dhcpl2relay app''' |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 149 | #cls.onos_ctrl.deactivate() |
| 150 | #OnosCtrl(cls.sadis_app).deactivate() |
| 151 | #OnosCtrl(cls.app_olt).deactivate() |
| 152 | |
| 153 | @classmethod |
| 154 | def setup_dhcpd(cls, boot_delay = 5): |
| 155 | if cls.service_running("/usr/sbin/dhcpd"): |
| 156 | print('DHCPD already running in container') |
| 157 | return True |
| 158 | setup_for_relay = cls.dhcp_l2_relay_setup() |
| 159 | cls.cord_l2_relay_load() |
| 160 | cls.voltha_setup() |
A R Karthick | 760d138 | 2017-10-05 13:48:40 -0700 | [diff] [blame] | 161 | return True |
| 162 | |
| 163 | # dhcp_start_status = cls.dhcpd_start() |
| 164 | # if setup_for_relay and dhcp_start_status: |
| 165 | # return True |
| 166 | # return False |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 167 | |
| 168 | @classmethod |
| 169 | def config_olt(cls, switch_map): |
| 170 | controller = get_controller() |
| 171 | auth = ('karaf', 'karaf') |
| 172 | #configure subscriber for every port on all the voltha devices |
| 173 | for device, device_map in switch_map.iteritems(): |
| 174 | uni_ports = device_map['ports'] |
| 175 | uplink_vlan = device_map['uplink_vlan'] |
| 176 | for port in uni_ports: |
| 177 | vlan = port |
| 178 | rest_url = 'http://{}:8181/onos/olt/oltapp/{}/{}/{}'.format(controller, |
| 179 | device, |
| 180 | port, |
| 181 | vlan) |
| 182 | requests.post(rest_url, auth = auth) |
| 183 | |
| 184 | @classmethod |
| 185 | def voltha_setup(cls): |
| 186 | s_tag_map = {} |
| 187 | #configure olt app to provision dhcp flows |
| 188 | cls.config_olt(cls.voltha_switch_map) |
| 189 | for switch, switch_map in cls.voltha_switch_map.iteritems(): |
| 190 | s_tag_map[int(switch_map['uplink_vlan'])] = map(lambda p: int(p), switch_map['ports']) |
| 191 | |
| 192 | cmd_list = [] |
| 193 | relay_interface = cls.relay_interfaces[0] |
| 194 | cls.relay_vlan_map[relay_interface] = [] |
| 195 | for s_tag, ports in s_tag_map.iteritems(): |
| 196 | vlan_stag_intf = '{}.{}'.format(relay_interface, s_tag) |
| 197 | cmd = 'ip link add link %s name %s type vlan id %d' %(relay_interface, vlan_stag_intf, s_tag) |
| 198 | cmd_list.append(cmd) |
| 199 | cmd = 'ip link set %s up' %(vlan_stag_intf) |
| 200 | cmd_list.append(cmd) |
| 201 | for port in ports: |
| 202 | vlan_ctag_intf = '{}.{}.{}'.format(relay_interface, s_tag, port) |
| 203 | cmd = 'ip link add link %s name %s type vlan id %d' %(vlan_stag_intf, vlan_ctag_intf, port) |
| 204 | cmd_list.append(cmd) |
| 205 | cmd = 'ip link set %s up' %(vlan_ctag_intf) |
| 206 | cmd_list.append(cmd) |
| 207 | cls.relay_vlan_map[relay_interface].append(vlan_ctag_intf) |
| 208 | cls.relay_vlan_map[relay_interface].append(vlan_stag_intf) |
| 209 | |
| 210 | for cmd in cmd_list: |
| 211 | log_test.info('Running command: %s' %cmd) |
| 212 | os.system(cmd) |
| 213 | |
| 214 | cord_test_ovs_flow_add(cls.relay_interface_port) |
| 215 | for s_tag in s_tag_map.keys(): |
| 216 | log_test.info('Configuring OVS flow for port %d, s_tag %d' %(cls.relay_interface_port, s_tag)) |
| 217 | cord_test_ovs_flow_add(cls.relay_interface_port, s_tag) |
| 218 | |
| 219 | @classmethod |
| 220 | def service_running(cls, pattern): |
| 221 | st, _ = getstatusoutput('pgrep -f "{}"'.format(pattern)) |
| 222 | return True if st == 0 else False |
| 223 | |
| 224 | @classmethod |
| 225 | def dhcpd_conf_generate(cls, config = default_config, options = default_options, |
| 226 | subnet = default_subnet_config): |
| 227 | conf = '' |
| 228 | for k, v in config.items(): |
| 229 | conf += '{} {};\n'.format(k, v) |
| 230 | |
| 231 | opts = '' |
| 232 | for k, v in options: |
| 233 | opts += 'option {} {};\n'.format(k, v) |
| 234 | |
| 235 | subnet_config = '' |
| 236 | for _, v in subnet: |
| 237 | subnet_config += '{}\n'.format(v) |
| 238 | |
| 239 | return '{}{}{}'.format(conf, opts, subnet_config) |
| 240 | |
| 241 | @classmethod |
| 242 | def dhcpd_start(cls, intf_list = None, |
| 243 | config = default_config, options = default_options, |
| 244 | subnet = default_subnet_config): |
| 245 | '''Start the dhcpd server by generating the conf file''' |
| 246 | if intf_list is None: |
| 247 | intf_list = cls.relay_interfaces |
| 248 | intf_list = list(intf_list) |
| 249 | ##stop dhcpd if already running |
| 250 | #cls.dhcpd_stop() |
| 251 | dhcp_conf = cls.dhcpd_conf_generate(config = config, options = options, |
| 252 | subnet = subnet) |
| 253 | ##first touch dhcpd.leases if it doesn't exist |
| 254 | lease_file = '{}/dhcpd.leases'.format(cls.dhcp_data_dir) |
| 255 | if os.access(lease_file, os.F_OK) is False: |
| 256 | with open(lease_file, 'w') as fd: pass |
| 257 | |
A R Karthick | ce96dde | 2017-10-05 16:41:52 -0700 | [diff] [blame^] | 258 | lease_file_tagged = '{}/dhcpd-tagged.leases'.format(cls.dhcp_data_dir) |
| 259 | if os.access(lease_file_tagged, os.F_OK) is False: |
| 260 | with open(lease_file_tagged, 'w') as fd: pass |
| 261 | |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 262 | conf_file = '{}/dhcpd.conf'.format(cls.dhcp_data_dir) |
| 263 | with open(conf_file, 'w') as fd: |
| 264 | fd.write(dhcp_conf) |
| 265 | |
A R Karthick | ce96dde | 2017-10-05 16:41:52 -0700 | [diff] [blame^] | 266 | conf_file_tagged = '{}/dhcpd-tagged.conf'.format(cls.dhcp_data_dir) |
| 267 | with open(conf_file_tagged, 'w') as fd: |
| 268 | fd.write(dhcp_conf) |
| 269 | |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 270 | #now configure the dhcpd interfaces for various subnets |
| 271 | index = 0 |
| 272 | intf_info = [] |
| 273 | vlan_intf_list = [] |
| 274 | for ip,_ in subnet: |
| 275 | vlan_intf = None |
| 276 | intf = intf_list[index] |
| 277 | if intf in cls.relay_vlan_map: |
| 278 | vlan_intf = cls.relay_vlan_map[intf][0] |
| 279 | vlan_intf_list.append(vlan_intf) |
| 280 | mac = cls.get_mac(intf) |
| 281 | intf_info.append((ip, mac)) |
| 282 | index += 1 |
| 283 | cmd = 'ifconfig {} {}'.format(intf, ip) |
| 284 | status = os.system(cmd) |
| 285 | if vlan_intf: |
| 286 | cmd = 'ifconfig {} {}'.format(vlan_intf, ip) |
| 287 | os.system(cmd) |
| 288 | |
| 289 | intf_str = ','.join(intf_list) |
| 290 | dhcpd_cmd = '/usr/sbin/dhcpd -4 --no-pid -cf {0} -lf {1} {2}'.format('/root/test/src/test/setup/dhcpd.conf','/root/test/src/test/setup/dhcpd.leases', intf_str) |
| 291 | print('Starting DHCPD server with command: %s' %dhcpd_cmd) |
| 292 | status = os.system(dhcpd_cmd) |
| 293 | vlan_intf_str = ','.join(vlan_intf_list) |
A R Karthick | ce96dde | 2017-10-05 16:41:52 -0700 | [diff] [blame^] | 294 | dhcpd_cmd = '/usr/sbin/dhcpd -4 --no-pid -cf {0} -lf {1} {2}'.format('/root/test/src/test/setup/dhcpd-tagged.conf','/root/test/src/test/setup/dhcpd-tagged.leases', vlan_intf_str) |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 295 | print('Starting DHCPD server with command: %s' %dhcpd_cmd) |
| 296 | status = os.system(dhcpd_cmd) |
| 297 | if status > 255: |
| 298 | status = 1 |
| 299 | else: |
| 300 | return False |
| 301 | time.sleep(3) |
| 302 | cls.relay_interfaces_last = cls.relay_interfaces |
| 303 | cls.relay_interfaces = intf_list |
| 304 | return True |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 305 | |
| 306 | @classmethod |
| 307 | def dhcp_l2_relay_setup(cls): |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 308 | device_details = OnosCtrl.get_devices(mfr = 'Nicira') |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 309 | if device_details is not None: |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 310 | did_ovs = device_details[0]['id'] |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 311 | else: |
| 312 | log_test.info('On this DHCPl2relay setup, onos does not have ovs device where external DHCP server is have connect point, so return with false status') |
| 313 | return False |
| 314 | cls.relay_device_id = did_ovs |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 315 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 316 | cls.port_map, _ = cls.olt.olt_port_map() |
| 317 | if cls.port_map: |
| 318 | ##Per subscriber, we use 1 relay port |
| 319 | try: |
| 320 | relay_port = cls.port_map[cls.port_map['relay_ports'][0]] |
| 321 | except: |
| 322 | relay_port = cls.port_map['uplink'] |
| 323 | cls.relay_interface_port = relay_port |
| 324 | cls.relay_interfaces = (cls.port_map[cls.relay_interface_port],) |
| 325 | else: |
| 326 | cls.relay_interface_port = 100 |
| 327 | cls.relay_interfaces = (g_subscriber_port_map[cls.relay_interface_port],) |
| 328 | cls.relay_interfaces_last = cls.relay_interfaces |
| 329 | if cls.port_map: |
| 330 | ##generate a ip/mac client virtual interface config for onos |
| 331 | interface_list = [] |
| 332 | for port in cls.port_map['ports']: |
| 333 | port_num = cls.port_map[port] |
| 334 | if port_num == cls.port_map['uplink']: |
| 335 | continue |
| 336 | ip = cls.get_host_ip(port_num) |
| 337 | mac = cls.get_mac(port) |
| 338 | interface_list.append((port_num, ip, mac)) |
| 339 | |
| 340 | #configure dhcp server virtual interface on the same subnet as first client interface |
| 341 | relay_ip = cls.get_host_ip(interface_list[0][0]) |
| 342 | relay_mac = cls.get_mac(cls.port_map[cls.relay_interface_port]) |
| 343 | interface_list.append((cls.relay_interface_port, relay_ip, relay_mac)) |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 344 | cls.onos_interface_load(interface_list) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 345 | |
| 346 | @classmethod |
| 347 | def dhcp_l2_relay_cleanup(cls): |
| 348 | ##reset the ONOS port configuration back to default |
| 349 | for config in cls.configs.items(): |
| 350 | OnosCtrl.delete(config) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 351 | cls.onos_load_config(cls.default_onos_config) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 352 | # if cls.onos_restartable is True: |
| 353 | # log_test.info('Cleaning up dhcp relay config by restarting ONOS with default network cfg') |
| 354 | # return cord_test_onos_restart(config = {}) |
| 355 | |
| 356 | @classmethod |
| 357 | def onos_load_config(cls, config): |
| 358 | status, code = OnosCtrl.config(config) |
| 359 | if status is False: |
| 360 | log_test.info('JSON request returned status %d' %code) |
| 361 | assert_equal(status, True) |
| 362 | time.sleep(3) |
| 363 | |
| 364 | @classmethod |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 365 | def onos_delete_config(cls, config): |
| 366 | status, code = OnosCtrl.delete(config) |
| 367 | if status is False: |
| 368 | log_test.info('JSON request returned status %d' %code) |
| 369 | assert_equal(status, True) |
| 370 | time.sleep(3) |
| 371 | |
| 372 | @classmethod |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 373 | def onos_interface_load(cls, interface_list): |
| 374 | interface_dict = { 'ports': {} } |
| 375 | for port_num, ip, mac in interface_list: |
| 376 | port_map = interface_dict['ports'] |
| 377 | port = '{}/{}'.format(cls.relay_device_id, port_num) |
| 378 | port_map[port] = { 'interfaces': [] } |
| 379 | interface_list = port_map[port]['interfaces'] |
| 380 | interface_map = { 'ips' : [ '{}/{}'.format(ip, 24) ], |
| 381 | 'mac' : mac, |
| 382 | 'name': 'vir-{}'.format(port_num) |
| 383 | } |
| 384 | interface_list.append(interface_map) |
| 385 | |
| 386 | cls.onos_load_config(interface_dict) |
| 387 | cls.configs['interface_config'] = interface_dict |
| 388 | |
| 389 | @classmethod |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 390 | def cord_l2_relay_load(cls, dhcp_server_connectPoint = None, delete = False): |
A R Karthick | 5373566 | 2017-10-05 12:53:35 -0700 | [diff] [blame] | 391 | ##read the current config |
| 392 | current_netcfg = OnosCtrl.get_config() |
| 393 | connect_points = set([]) |
| 394 | try: |
| 395 | connect_points = set(current_netcfg['apps']['org.opencord.dhcpl2relay']['dhcpl2relay']['dhcpServerConnectPoints']) |
| 396 | except KeyError, e: |
| 397 | pass |
| 398 | |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 399 | OnosCtrl.uninstall_app(cls.dhcpl2_app_file) |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 400 | relay_device_map = '{}/{}'.format(cls.relay_device_id, cls.relay_interface_port) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 401 | #### We have to work on later versions by removing these hard coded values |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 402 | if dhcp_server_connectPoint is None: |
A R Karthick | 8fe89a1 | 2017-10-05 13:12:13 -0700 | [diff] [blame] | 403 | relay_device_present = filter(lambda cp: cp.split('/')[0] == cls.relay_device_id, connect_points) |
| 404 | if not relay_device_present: |
| 405 | connect_points.add(relay_device_map) |
A R Karthick | 5373566 | 2017-10-05 12:53:35 -0700 | [diff] [blame] | 406 | else: |
| 407 | cps_unused = map(lambda cp: connect_points.add(cp), dhcp_server_connectPoint) |
| 408 | connect_points = list(connect_points) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 409 | dhcp_dict = { "apps" : { "org.opencord.dhcpl2relay" : {"dhcpl2relay" : |
A R Karthick | 5373566 | 2017-10-05 12:53:35 -0700 | [diff] [blame] | 410 | {"dhcpServerConnectPoints": connect_points} |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 411 | } |
| 412 | } |
| 413 | } |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 414 | #OnosCtrl.uninstall_app(cls.dhcpl2_app_file) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 415 | OnosCtrl.install_app(cls.dhcpl2_app_file) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 416 | if delete == False: |
| 417 | cls.onos_load_config(dhcp_dict) |
| 418 | else: |
| 419 | cls.onos_delete_config(dhcp_dict) |
| 420 | cls.onos_load_config(cls.default_onos_config) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 421 | cls.configs['relay_config'] = dhcp_dict |
| 422 | |
| 423 | @classmethod |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 424 | def cord_sadis_load(cls, sadis_info = None): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 425 | relay_device_id = '{}'.format(cls.relay_device_id) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 426 | device_details = OnosCtrl.get_devices() |
| 427 | if device_details is not None: |
| 428 | for device in device_details: |
| 429 | ## Assuming only one OVS is detected on ONOS and its for external DHCP server connect point... |
| 430 | if device['available'] is True and device['driver'] == 'pmc-olt': |
| 431 | cls.olt_serial_id = "{}".format(device['serial']) |
| 432 | else: |
| 433 | cls.olt_serial_id = " " |
| 434 | else: |
| 435 | log_test.info('On this DHCPl2relay setup, onos does not have Tibit device where DHCP client is connected on UNI point, so return with false status') |
| 436 | return False |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 437 | sadis_dict = { "apps": { |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 438 | "org.opencord.sadis": { |
| 439 | "sadis": { |
| 440 | "integration": { |
| 441 | "cache": { |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 442 | "enabled": "true", |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 443 | "maxsize": 50, |
| 444 | "ttl": "PT1m" |
| 445 | } |
| 446 | }, |
| 447 | "entries": [{ |
| 448 | "id": "uni-254", |
| 449 | "cTag": 202, |
| 450 | "sTag": 222, |
| 451 | "nasPortId": "uni-254" |
| 452 | }, |
| 453 | { |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 454 | "id": cls.olt_serial_id, |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 455 | "hardwareIdentifier": "00:0c:e2:31:05:00", |
| 456 | "ipAddress": "172.17.0.1", |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 457 | "nasId": "B100-NASID" |
| 458 | } |
| 459 | ] |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 460 | } |
| 461 | } |
| 462 | } |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 463 | } |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 464 | #OnosCtrl.uninstall_app(cls.olt_app_file) |
| 465 | OnosCtrl.install_app(cls.olt_app_file) |
| 466 | time.sleep(5) |
| 467 | #OnosCtrl.uninstall_app(cls.sadis_app_file) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 468 | OnosCtrl.install_app(cls.sadis_app_file) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 469 | if sadis_info: |
| 470 | sadis_dict = sadis_info |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 471 | cls.onos_load_config(sadis_dict) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 472 | cls.sadis_configs['relay_config'] = sadis_dict |
| 473 | |
| 474 | def sadis_info_dict(self, subscriber_port_id =None, c_tag = None, s_tag = None, nas_port_id =None,olt_serial_id =None,olt_mac=None,olt_ip =None,olt_nas_id=None): |
| 475 | ### Need to work on these hard coded values on later merges |
| 476 | if subscriber_port_id is None: |
| 477 | subscriber_port_id = "uni-254" |
| 478 | if c_tag is None: |
| 479 | c_tag = 202 |
| 480 | if s_tag is None: |
| 481 | s_tag = 222 |
| 482 | if nas_port_id is None: |
| 483 | nas_port_id = "uni-254" |
| 484 | if olt_serial_id is None: |
| 485 | olt_serial_id = self.olt_serial_id |
| 486 | if olt_mac is None: |
| 487 | olt_mac = "00:0c:e2:31:05:00" |
| 488 | if olt_ip is None: |
| 489 | olt_ip = "172.17.0.1" |
| 490 | if olt_nas_id is None: |
| 491 | olt_nas_id = "B100-NASID" |
| 492 | sadis_dict = { "apps": { |
| 493 | "org.opencord.sadis": { |
| 494 | "sadis": { |
| 495 | "integration": { |
| 496 | "cache": { |
| 497 | "enabled": "true", |
| 498 | "maxsize": 50, |
| 499 | "ttl": "PT1m" |
| 500 | } |
| 501 | }, |
| 502 | "entries": [{ |
| 503 | "id": subscriber_port_id, |
| 504 | "cTag": c_tag, |
| 505 | "sTag": s_tag, |
| 506 | "nasPortId": nas_port_id |
| 507 | }, |
| 508 | { |
| 509 | "id": olt_serial_id, |
| 510 | "hardwareIdentifier": olt_mac, |
| 511 | "ipAddress": olt_ip, |
| 512 | "nasId": olt_nas_id |
| 513 | } |
| 514 | ] |
| 515 | } |
| 516 | } |
| 517 | } |
| 518 | } |
| 519 | return sadis_dict |
| 520 | |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 521 | |
| 522 | @classmethod |
| 523 | def get_host_ip(cls, port): |
| 524 | if cls.host_ip_map.has_key(port): |
| 525 | return cls.host_ip_map[port] |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 526 | cls.host_ip_map[port] = '192.168.100.{}'.format(port) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 527 | return cls.host_ip_map[port] |
| 528 | |
| 529 | @classmethod |
| 530 | def host_load(cls, iface): |
| 531 | '''Have ONOS discover the hosts for dhcp-relay responses''' |
| 532 | port = g_subscriber_port_map[iface] |
| 533 | host = '173.17.1.{}'.format(port) |
| 534 | cmds = ( 'ifconfig {} 0'.format(iface), |
| 535 | 'ifconfig {0} {1}'.format(iface, host), |
| 536 | 'arping -I {0} {1} -c 2'.format(iface, host), |
| 537 | 'ifconfig {} 0'.format(iface), ) |
| 538 | for c in cmds: |
| 539 | os.system(c) |
| 540 | |
| 541 | @classmethod |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 542 | def get_mac(cls, iface): |
| 543 | if cls.interface_to_mac_map.has_key(iface): |
| 544 | return cls.interface_to_mac_map[iface] |
| 545 | mac = get_mac(iface, pad = 0) |
| 546 | cls.interface_to_mac_map[iface] = mac |
| 547 | return mac |
| 548 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 549 | 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] | 550 | |
| 551 | self.ip_count = 0 |
| 552 | self.failure_count = 0 |
| 553 | self.start_time = 0 |
| 554 | self.diff = 0 |
| 555 | self.transaction_count = 0 |
| 556 | |
| 557 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 558 | self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = iface) |
| 559 | self.start_time = time.time() |
| 560 | |
| 561 | while self.diff <= 60: |
| 562 | |
| 563 | if only_discover: |
| 564 | cip, sip, mac, _ = self.dhcp.only_discover(multiple = True) |
| 565 | log_test.info('Got dhcp client IP %s from server %s for mac %s' % |
| 566 | (cip, sip, mac)) |
| 567 | else: |
| 568 | cip, sip = self.send_recv(mac=mac, update_seed = True, validate = False) |
| 569 | |
| 570 | if cip: |
| 571 | self.ip_count +=1 |
| 572 | elif cip == None: |
| 573 | self.failure_count += 1 |
| 574 | log_test.info('Failed to get ip') |
| 575 | if success_rate and self.ip_count > 0: |
| 576 | break |
| 577 | |
| 578 | self.diff = round(time.time() - self.start_time, 0) |
| 579 | |
| 580 | self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2) |
| 581 | self.transactions += (self.ip_count+self.failure_count) |
| 582 | self.running_time += self.diff |
| 583 | self.total_success += self.ip_count |
| 584 | self.total_failure += self.failure_count |
| 585 | |
| 586 | def send_recv(self, mac=None, update_seed = False, validate = True): |
| 587 | cip, sip = self.dhcp.discover(mac = mac, update_seed = update_seed) |
| 588 | if validate: |
| 589 | assert_not_equal(cip, None) |
| 590 | assert_not_equal(sip, None) |
| 591 | log_test.info('Got dhcp client IP %s from server %s for mac %s' % |
| 592 | (cip, sip, self.dhcp.get_mac(cip)[0])) |
| 593 | return cip,sip |
| 594 | |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 595 | def test_dhcpl2relay_initialize(self): |
A R Karthick | 760d138 | 2017-10-05 13:48:40 -0700 | [diff] [blame] | 596 | '''Configure the DHCP L2 relay app and start dhcpd''' |
| 597 | self.dhcpd_start() |
A R Karthick | c0a008f | 2017-10-04 18:35:25 -0700 | [diff] [blame] | 598 | |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 599 | def test_dhcpl2relay_with_one_request(self, iface = 'veth0'): |
| 600 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 601 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 602 | self.send_recv(mac=mac) |
| 603 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 604 | def test_dhcpl2relay_app_install(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 605 | mac = self.get_mac(iface) |
| 606 | onos_netcfg = OnosCtrl.get_config() |
| 607 | app_status = False |
| 608 | app_name = 'org.opencord.dhcpl2relay' |
| 609 | for app in onos_netcfg['apps']: |
| 610 | if app == app_name: |
| 611 | log_test.info('%s app is being installed'%app) |
| 612 | app_status = True |
| 613 | if app_status is not True: |
| 614 | log_test.info('%s app is not being installed'%app_name) |
| 615 | assert_equal(True, app_status) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 616 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 617 | def test_dhcpl2relay_sadis_app_install(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 618 | mac = self.get_mac(iface) |
| 619 | onos_netcfg = OnosCtrl.get_config() |
| 620 | app_status = False |
| 621 | app_name = 'org.opencord.sadis' |
| 622 | for app in onos_netcfg['apps']: |
| 623 | if app == app_name: |
| 624 | log_test.info('%s app is being installed'%app) |
| 625 | app_status = True |
| 626 | if app_status is not True: |
| 627 | log_test.info('%s app is not being installed'%app_name) |
| 628 | assert_equal(True, app_status) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 629 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 630 | def test_dhcpl2relay_netcfg(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 631 | mac = self.get_mac(iface) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 632 | onos_netcfg = OnosCtrl.get_config() |
| 633 | app_status = False |
| 634 | app_name = 'org.opencord.dhcpl2relay' |
| 635 | for app in onos_netcfg['apps']: |
| 636 | if app == app_name: |
| 637 | log_test.info('%s app is being installed'%app) |
| 638 | if onos_netcfg['apps'][app_name] == {}: |
| 639 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
| 640 | else: |
| 641 | log_test.info('The network configuration is shown = %s'%onos_netcfg['apps'][app_name]) |
| 642 | app_status = True |
| 643 | if app_status is not True: |
| 644 | log_test.info('%s app is not installed or network configuration is not shown'%app_name) |
| 645 | assert_equal(True, False) |
| 646 | |
| 647 | def test_dhcpl2relay_sadis_netcfg(self, iface = 'veth0'): |
| 648 | mac = self.get_mac(iface) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 649 | onos_netcfg = OnosCtrl.get_config() |
| 650 | app_status = False |
| 651 | app_name = 'org.opencord.sadis' |
| 652 | for app in onos_netcfg['apps']: |
| 653 | if app == app_name: |
| 654 | log_test.info('%s app is being installed'%app) |
| 655 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 656 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
| 657 | else: |
| 658 | log_test.info('The network configuration is shown = %s'%(onos_netcfg['apps'][app_name])) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 659 | app_status = True |
| 660 | if app_status is not True: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 661 | log_test.info('%s app is not installed or network configuration is not shown'%app_name) |
| 662 | assert_equal(True, False) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 663 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 664 | def test_dhcpl2relay_with_array_of_connect_points_for_dhcp_server(self, iface = 'veth0'): |
| 665 | relay_device_map = '{}/{}'.format(self.relay_device_id, self.relay_interface_port) |
| 666 | relay_device_map1 = '{}/1'.format(self.relay_device_id) |
| 667 | relay_device_map2 = '{}/9'.format(self.relay_device_id) |
| 668 | relay_device_map3 = '{}/6'.format(self.relay_device_id) |
| 669 | relay_device_map4 = '{}/7'.format(self.relay_device_id) |
| 670 | dhcp_server_array_connectPoints = [relay_device_map,relay_device_map1,relay_device_map2,relay_device_map3,relay_device_map4] |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 671 | mac = self.get_mac(iface) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 672 | self.onos_delete_config(self.configs['relay_config']) |
| 673 | self.onos_load_config(self.default_onos_netcfg) |
| 674 | self.cord_l2_relay_load(dhcp_server_connectPoint = dhcp_server_array_connectPoints, delete = False) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 675 | onos_netcfg = OnosCtrl.get_config() |
| 676 | app_status = False |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 677 | app_name = 'org.opencord.dhcpl2relay' |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 678 | for app in onos_netcfg['apps']: |
| 679 | if app == app_name: |
| 680 | log_test.info('%s app is being installed'%app) |
| 681 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 682 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 683 | elif onos_netcfg['apps'][app_name]['dhcpServerConnectPoints'] == dhcp_server_array_connectPoints: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 684 | log_test.info('The network configuration is shown = %s'%onos_netcfg['apps'][app_name]['dhcpServerConnectPoints']) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 685 | app_status = True |
| 686 | if app_status is not True: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 687 | log_test.info('%s app is not installed or network configuration is not shown'%app_name) |
| 688 | assert_equal(True, False) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 689 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 690 | self.send_recv(mac=mac) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 691 | |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 692 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 693 | def test_dhcpl2relay_with_subscriber_configured_with_ctag_stag_as_per_sadis(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 694 | mac = self.get_mac(iface) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 695 | c_tag = 600 |
| 696 | invalid_sadis_info = self.sadis_info_dict(c_tag = 600,s_tag = 500) |
| 697 | self.cord_sadis_load(sadis_info = invalid_sadis_info) |
| 698 | onos_netcfg = OnosCtrl.get_config() |
| 699 | app_status = False |
| 700 | app_name = 'org.opencord.sadis' |
| 701 | for app in onos_netcfg['apps']: |
| 702 | if app == app_name: |
| 703 | log_test.info('%s app is being installed'%app) |
| 704 | if onos_netcfg['apps'][app_name] == {}: |
| 705 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
| 706 | elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['cTag'] == c_tag: |
| 707 | log_test.info('The S Tag and C Tag info from network configuration are %s and %s respectively '%(onos_netcfg['apps'][app_name]['sadis']['entries'][0]['sTag'],onos_netcfg['apps'][app_name]['sadis']['entries'][0]['cTag'])) |
| 708 | app_status = True |
| 709 | if app_status is not True: |
| 710 | log_test.info('%s app is not installed or network configuration is not shown '%app_name) |
| 711 | assert_equal(True, False) |
| 712 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 713 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 714 | assert_equal(cip,None) |
| 715 | |
| 716 | def test_dhcpl2relay_app_activation_and_deactivation_multiple_times(self, iface = 'veth0'): |
| 717 | iterations = 15 |
| 718 | for i in range(iterations): |
| 719 | self.onos_ctrl.deactivate() |
| 720 | time.sleep(3) |
| 721 | self.onos_ctrl.activate() |
| 722 | log_test.info('Dhcpl2relay app is activated and deactivated multiple times around %s, now sending DHCP discover'%iterations) |
| 723 | mac = self.get_mac(iface) |
| 724 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 725 | self.send_recv(mac=mac) |
| 726 | |
| 727 | def test_dhcpl2relay_without_sadis_app(self, iface = 'veth0'): |
| 728 | mac = self.get_mac(iface) |
| 729 | OnosCtrl.uninstall_app(self.sadis_app_file) |
| 730 | OnosCtrl(self.sadis_app).deactivate() |
| 731 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 732 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 733 | assert_equal(cip,None) |
| 734 | |
| 735 | def test_dhcpl2relay_delete_and_add_sadis_app(self, iface = 'veth0'): |
| 736 | mac = self.get_mac(iface) |
| 737 | OnosCtrl.uninstall_app(self.sadis_app_file) |
| 738 | OnosCtrl(self.sadis_app).deactivate() |
| 739 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 740 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 741 | assert_equal(cip,None) |
| 742 | OnosCtrl.uninstall_app(self.sadis_app_file) |
| 743 | OnosCtrl(self.sadis_app).deactivate() |
| 744 | #self.onos_load_config(self.sadis_configs['relay_config']) |
| 745 | self.send_recv(mac=mac) |
| 746 | |
| 747 | def test_dhcpl2relay_with_option_82(self, iface = 'veth0'): |
| 748 | pass |
| 749 | |
| 750 | def test_dhcpl2relay_without_option_82(self, iface = 'veth0'): |
| 751 | pass |
| 752 | |
| 753 | def test_dhcl2relay_for_option82_without_configuring_dhcpserver_to_accept_option82(self, iface = 'veth0'): |
| 754 | pass |
| 755 | |
| 756 | def test_dhcpl2relay_with_different_uni_port_entry_sadis_config(self, iface = 'veth0'): |
| 757 | mac = self.get_mac(iface) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 758 | subscriber_port_id = "uni-200" |
| 759 | invalid_sadis_info = self.sadis_info_dict(subscriber_port_id = "uni-200") |
| 760 | self.cord_sadis_load(sadis_info = invalid_sadis_info) |
| 761 | onos_netcfg = OnosCtrl.get_config() |
| 762 | app_status = False |
| 763 | app_name = 'org.opencord.sadis' |
| 764 | for app in onos_netcfg['apps']: |
| 765 | if app == app_name: |
| 766 | log_test.info('%s app is being installed'%app) |
| 767 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 768 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 769 | elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['id'] == subscriber_port_id: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 770 | log_test.info('The network configuration is shown = %s'%(onos_netcfg['apps'][app_name]['sadis']['entries'][0]['id'])) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 771 | app_status = True |
| 772 | if app_status is not True: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 773 | log_test.info('%s app is not installed or network configuration is not shown '%app_name) |
| 774 | |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 775 | assert_equal(True, False) |
| 776 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 777 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 778 | assert_equal(cip,None) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 779 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 780 | def test_dhcpl2relay_with_different_ctag_options(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 781 | mac = self.get_mac(iface) |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 782 | c_tag = 600 |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 783 | invalid_sadis_info = self.sadis_info_dict(c_tag = 600) |
| 784 | self.cord_sadis_load(sadis_info = invalid_sadis_info) |
| 785 | onos_netcfg = OnosCtrl.get_config() |
| 786 | app_status = False |
| 787 | app_name = 'org.opencord.sadis' |
| 788 | for app in onos_netcfg['apps']: |
| 789 | if app == app_name: |
| 790 | log_test.info('%s app is being installed'%app) |
| 791 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 792 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 793 | elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['cTag'] == c_tag: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 794 | log_test.info('The C Tag info from network configuration is = %s'%(onos_netcfg['apps'][app_name]['sadis']['entries'][0]['cTag'])) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 795 | app_status = True |
| 796 | if app_status is not True: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 797 | log_test.info('%s app is not installed or network configuration is not shown '%app_name) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 798 | assert_equal(True, False) |
| 799 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 800 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 801 | assert_equal(cip,None) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 802 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 803 | def test_dhcpl2relay_with_different_stag_options(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 804 | mac = self.get_mac(iface) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 805 | s_tag = 600 |
| 806 | invalid_sadis_info = self.sadis_info_dict(s_tag = 600) |
| 807 | self.cord_sadis_load(sadis_info = invalid_sadis_info) |
| 808 | onos_netcfg = OnosCtrl.get_config() |
| 809 | app_status = False |
| 810 | app_name = 'org.opencord.sadis' |
| 811 | for app in onos_netcfg['apps']: |
| 812 | if app == app_name: |
| 813 | log_test.info('%s app is being installed'%app) |
| 814 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 815 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 816 | elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['sTag'] == s_tag: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 817 | log_test.info('The S Tag info from the network configuration is = %s'%(onos_netcfg['apps'][app_name]['sadis']['entries'][0]['sTag'])) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 818 | app_status = True |
| 819 | if app_status is not True: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 820 | log_test.info('%s app is not installed or network configuration is not shown '%app_name) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 821 | assert_equal(True, False) |
| 822 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 823 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 824 | assert_equal(cip,None) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 825 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 826 | def test_dhcpl2relay_without_nasportid_option_in_sadis(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 827 | mac = self.get_mac(iface) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 828 | invalid_sadis_info = self.sadis_info_dict(nas_port_id = " ") |
| 829 | self.cord_sadis_load(sadis_info = invalid_sadis_info) |
| 830 | onos_netcfg = OnosCtrl.get_config() |
| 831 | app_status = False |
| 832 | app_name = 'org.opencord.sadis' |
| 833 | for app in onos_netcfg['apps']: |
| 834 | if app == app_name: |
| 835 | log_test.info('%s app is being installed'%app) |
| 836 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 837 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 838 | elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['nasPortId'] == " ": |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 839 | log_test.info('The nasPortId info from network configuration is shown = %s'%(onos_netcfg['apps'][app_name]['sadis']['entries'][0]['nasPortId'])) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 840 | app_status = True |
| 841 | if app_status is not True: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 842 | log_test.info('%s app is not installed or network configuration is not shown '%app_name) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 843 | assert_equal(True, False) |
| 844 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 845 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 846 | assert_equal(cip,None) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 847 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 848 | def test_dhcpl2relay_with_nasportid_different_from_id(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 849 | mac = self.get_mac(iface) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 850 | nas_port_id = "uni-509" |
| 851 | invalid_sadis_info = self.sadis_info_dict(nas_port_id = "uni-509") |
| 852 | self.cord_sadis_load(sadis_info = invalid_sadis_info) |
| 853 | onos_netcfg = OnosCtrl.get_config() |
| 854 | app_status = False |
| 855 | app_name = 'org.opencord.sadis' |
| 856 | for app in onos_netcfg['apps']: |
| 857 | if app == app_name: |
| 858 | log_test.info('%s app is being installed'%app) |
| 859 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 860 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 861 | elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['nasPortId'] == nas_port_id: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 862 | log_test.info('The nasPortId info from network configuration is shown = %s'%(onos_netcfg['apps'][app_name]['sadis']['entries'][0]['nasPortId'])) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 863 | app_status = True |
| 864 | if app_status is not True: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 865 | log_test.info('%s app is not installed or network configuration is not shown '%app_name) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 866 | assert_equal(True, False) |
| 867 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 868 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 869 | assert_equal(cip,None) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 870 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 871 | def test_dhcpl2relay_without_serial_id_of_olt(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 872 | mac = self.get_mac(iface) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 873 | invalid_sadis_info = self.sadis_info_dict(olt_serial_id = " ") |
| 874 | self.cord_sadis_load(sadis_info = invalid_sadis_info) |
| 875 | onos_netcfg = OnosCtrl.get_config() |
| 876 | app_status = False |
| 877 | app_name = 'org.opencord.sadis' |
| 878 | for app in onos_netcfg['apps']: |
| 879 | if app == app_name: |
| 880 | log_test.info('%s app is being installed'%app) |
| 881 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 882 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 883 | elif onos_netcfg['apps'][app_name]['sadis']['entries'][1]['id'] == " ": |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 884 | log_test.info('The serial Id info from network configuration is shown = %s'%(onos_netcfg['apps'][app_name]['sadis']['entries'][1]['id'])) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 885 | app_status = True |
| 886 | if app_status is not True: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 887 | log_test.info('%s app is not installed or network configuration is not shown '%app_name) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 888 | assert_equal(True, False) |
| 889 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 890 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 891 | assert_equal(cip,None) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 892 | |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 893 | def test_dhcpl2relay_with_wrong_serial_id_of_olt(self, iface = 'veth0'): |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 894 | mac = self.get_mac(iface) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 895 | olt_serial_id = "07f20d06696041febf974ccdhdhhjh37" |
| 896 | invalid_sadis_info = self.sadis_info_dict(olt_serial_id = "07f20d06696041febf974ccdhdhhjh37") |
| 897 | self.cord_sadis_load(sadis_info = invalid_sadis_info) |
| 898 | onos_netcfg = OnosCtrl.get_config() |
| 899 | app_status = False |
| 900 | app_name = 'org.opencord.sadis' |
| 901 | for app in onos_netcfg['apps']: |
| 902 | if app == app_name: |
| 903 | log_test.info('%s app is being installed'%app) |
| 904 | if onos_netcfg['apps'][app_name] == {}: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 905 | log_test.info('The network configuration is not shown'%onos_netcfg['apps'][app_name]) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 906 | elif onos_netcfg['apps'][app_name]['sadis']['entries'][1]['id'] == olt_serial_id: |
Thangavelu K S | 905e548 | 2017-09-12 06:48:02 -0700 | [diff] [blame] | 907 | log_test.info('The serial Id info from network configuration is shown = %s'%(onos_netcfg['apps'][app_name]['sadis']['entries'][1]['id'])) |
Thangavelu K S | 46063d0 | 2017-09-08 21:13:24 +0000 | [diff] [blame] | 908 | app_status = True |
| 909 | if app_status is not True: |
| 910 | assert_equal(True, False) |
| 911 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 912 | cip, sip, mac, _ = self.dhcp.only_discover(mac=mac) |
| 913 | assert_equal(cip,None) |
Chetan Gaonker | 891302d | 2017-09-05 15:09:26 +0000 | [diff] [blame] | 914 | |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 915 | def test_dhcpl2relay_for_one_request_with_invalid_source_mac_broadcast(self, iface = 'veth0'): |
| 916 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 917 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 918 | cip, sip, mac, _ = self.dhcp.only_discover(mac='ff:ff:ff:ff:ff:ff') |
| 919 | assert_equal(cip,None) |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 920 | 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] | 921 | |
| 922 | def test_dhcpl2relay_for_one_request_with_invalid_source_mac_multicast(self, iface = 'veth0'): |
| 923 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 924 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 925 | cip, sip, mac, _ = self.dhcp.only_discover(mac='01:80:c2:01:98:05') |
| 926 | assert_equal(cip,None) |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 927 | 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] | 928 | |
| 929 | def test_dhcpl2relay_for_one_request_with_invalid_source_mac_zero(self, iface = 'veth0'): |
| 930 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 931 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 932 | cip, sip, mac, _ = self.dhcp.only_discover(mac='00:00:00:00:00:00') |
| 933 | assert_equal(cip,None) |
| 934 | log_test.info('dhcp server rejected client discover with invalid source mac, as expected') |
| 935 | |
| 936 | def test_dhcpl2relay_with_N_requests(self, iface = 'veth0',requests=10): |
| 937 | mac = self.get_mac(iface) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 938 | self.dhcp = DHCPTest(seed_ip = '192.169.100.1', iface = iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 939 | ip_map = {} |
| 940 | for i in range(requests): |
| 941 | #mac = RandMAC()._fix() |
| 942 | #log_test.info('mac is %s'%mac) |
| 943 | cip, sip = self.send_recv(update_seed = True) |
| 944 | if ip_map.has_key(cip): |
| 945 | log_test.info('IP %s given out multiple times' %cip) |
| 946 | assert_equal(False, ip_map.has_key(cip)) |
| 947 | ip_map[cip] = sip |
| 948 | time.sleep(1) |
| 949 | |
| 950 | def test_dhcpl2relay_with_one_release(self, iface = 'veth0'): |
| 951 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 952 | self.dhcp = DHCPTest(seed_ip = '10.10.100.10', iface = iface) |
| 953 | cip, sip = self.send_recv(mac=mac) |
| 954 | log_test.info('Releasing ip %s to server %s' %(cip, sip)) |
| 955 | assert_equal(self.dhcp.release(cip), True) |
| 956 | log_test.info('Triggering DHCP discover again after release') |
| 957 | cip2, sip2 = self.send_recv(mac=mac) |
| 958 | log_test.info('Verifying released IP was given back on rediscover') |
| 959 | assert_equal(cip, cip2) |
| 960 | log_test.info('Test done. Releasing ip %s to server %s' %(cip2, sip2)) |
| 961 | assert_equal(self.dhcp.release(cip2), True) |
| 962 | |
| 963 | def test_dhcpl2relay_with_Nreleases(self, iface = 'veth0'): |
| 964 | mac = None |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 965 | self.dhcp = DHCPTest(seed_ip = '192.170.1.10', iface = iface) |
| 966 | ip_map = {} |
| 967 | for i in range(10): |
| 968 | cip, sip = self.send_recv(mac=mac, update_seed = True) |
| 969 | if ip_map.has_key(cip): |
| 970 | log_test.info('IP %s given out multiple times' %cip) |
| 971 | assert_equal(False, ip_map.has_key(cip)) |
| 972 | ip_map[cip] = sip |
| 973 | |
| 974 | for ip in ip_map.keys(): |
| 975 | log_test.info('Releasing IP %s' %ip) |
| 976 | assert_equal(self.dhcp.release(ip), True) |
| 977 | |
| 978 | ip_map2 = {} |
| 979 | log_test.info('Triggering DHCP discover again after release') |
| 980 | self.dhcp = DHCPTest(seed_ip = '192.170.1.10', iface = iface) |
| 981 | for i in range(len(ip_map.keys())): |
| 982 | cip, sip = self.send_recv(mac=mac, update_seed = True) |
| 983 | ip_map2[cip] = sip |
| 984 | |
| 985 | log_test.info('Verifying released IPs were given back on rediscover') |
| 986 | if ip_map != ip_map2: |
| 987 | log_test.info('Map before release %s' %ip_map) |
| 988 | log_test.info('Map after release %s' %ip_map2) |
| 989 | assert_equal(ip_map, ip_map2) |
| 990 | |
| 991 | def test_dhcpl2relay_starvation(self, iface = 'veth0'): |
| 992 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 993 | self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = iface) |
| 994 | log_test.info('Verifying 1 ') |
| 995 | count = 0 |
| 996 | while True: |
| 997 | #mac = RandMAC()._fix() |
| 998 | cip, sip = self.send_recv(update_seed = True,validate = False) |
| 999 | if cip is None: |
| 1000 | break |
| 1001 | else: |
| 1002 | count += 1 |
| 1003 | assert_equal(count,91) |
| 1004 | log_test.info('Verifying 2 ') |
| 1005 | cip, sip = self.send_recv(mac=mac, update_seed = True, validate = False) |
| 1006 | assert_equal(cip, None) |
| 1007 | assert_equal(sip, None) |
| 1008 | |
| 1009 | def test_dhcpl2relay_with_same_client_and_multiple_discovers(self, iface = 'veth0'): |
| 1010 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1011 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 1012 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1013 | log_test.info('Got dhcp client IP %s from server %s for mac %s . Not going to send DHCPREQUEST.' % |
| 1014 | (cip, sip, mac) ) |
| 1015 | assert_not_equal(cip, None) |
| 1016 | log_test.info('Triggering DHCP discover again.') |
| 1017 | new_cip, new_sip, new_mac, _ = self.dhcp.only_discover() |
| 1018 | assert_equal(new_cip, cip) |
| 1019 | log_test.info('got same ip to smae the client when sent discover again, as expected') |
| 1020 | |
| 1021 | def test_dhcpl2relay_with_same_client_and_multiple_requests(self, iface = 'veth0'): |
| 1022 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1023 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 1024 | log_test.info('Sending DHCP discover and DHCP request.') |
| 1025 | cip, sip = self.send_recv(mac=mac) |
| 1026 | mac = self.dhcp.get_mac(cip)[0] |
| 1027 | log_test.info("Sending DHCP request again.") |
| 1028 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1029 | assert_equal(new_cip, cip) |
| 1030 | log_test.info('got same ip to smae the client when sent request again, as expected') |
| 1031 | |
| 1032 | def test_dhcpl2relay_with_clients_desired_address(self, iface = 'veth0'): |
| 1033 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1034 | self.dhcp = DHCPTest(seed_ip = '192.168.1.31', iface = iface) |
| 1035 | cip, sip, mac, _ = self.dhcp.only_discover(desired = True) |
| 1036 | assert_equal(cip,self.dhcp.seed_ip) |
| 1037 | log_test.info('Got dhcp client desired IP %s from server %s for mac %s as expected' % |
| 1038 | (cip, sip, mac) ) |
| 1039 | |
| 1040 | def test_dhcpl2relay_with_clients_desired_address_in_out_of_pool(self, iface = 'veth0'): |
| 1041 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1042 | self.dhcp = DHCPTest(seed_ip = '20.20.20.35', iface = iface) |
| 1043 | cip, sip, mac, _ = self.dhcp.only_discover(desired = True) |
| 1044 | assert_not_equal(cip,None) |
| 1045 | assert_not_equal(cip,self.dhcp.seed_ip) |
| 1046 | log_test.info('server offered IP from its pool when requested out of pool IP, as expected') |
| 1047 | |
| 1048 | def test_dhcpl2relay_nak_packet(self, iface = 'veth0'): |
| 1049 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1050 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 1051 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1052 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1053 | (cip, sip, mac) ) |
| 1054 | assert_not_equal(cip, None) |
| 1055 | new_cip, new_sip = self.dhcp.only_request('20.20.20.31', mac) |
| 1056 | assert_equal(new_cip, None) |
| 1057 | log_test.info('server sent NAK packet when requested other IP than that server offered') |
| 1058 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1059 | 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] | 1060 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1061 | self.dhcp = DHCPTest(seed_ip = '10.10.10.70', iface = iface) |
| 1062 | self.dhcp.return_option = 'lease' |
| 1063 | cip, sip, mac, lval = self.dhcp.only_discover(lease_time=True,lease_value=lease_time) |
| 1064 | assert_equal(lval, lease_time) |
| 1065 | log_test.info('dhcp server offered IP address with client requested lease time') |
| 1066 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1067 | def test_dhcpl2relay_with_client_request_after_reboot(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1068 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1069 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1070 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1071 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1072 | (cip, sip, mac) ) |
| 1073 | assert_not_equal(cip, None) |
| 1074 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1075 | log_test.info('client rebooting...') |
| 1076 | os.system('ifconfig '+iface+' down') |
| 1077 | time.sleep(5) |
| 1078 | os.system('ifconfig '+iface+' up') |
| 1079 | new_cip2, new_sip = self.dhcp.only_request(cip, mac, cl_reboot = True) |
| 1080 | assert_equal(new_cip2, cip) |
| 1081 | log_test.info('client got same IP after reboot, as expected') |
| 1082 | |
| 1083 | |
| 1084 | def test_dhcpl2relay_after_server_reboot(self, iface = 'veth0'): |
| 1085 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1086 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1087 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1088 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1089 | (cip, sip, mac) ) |
| 1090 | assert_not_equal(cip, None) |
| 1091 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1092 | log_test.info('server rebooting...') |
| 1093 | self.tearDownClass() |
| 1094 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1095 | assert_equal(new_cip,None) |
| 1096 | self.setUpClass() |
| 1097 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1098 | assert_equal(new_cip, cip) |
| 1099 | log_test.info('client got same IP after server rebooted, as expected') |
| 1100 | |
| 1101 | def test_dhcpl2relay_specific_lease_time_only_in_discover_but_not_in_request_packet(self, iface = 'veth0',lease_time=700): |
| 1102 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1103 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1104 | self.dhcp.return_option = 'lease' |
| 1105 | log_test.info('Sending DHCP discover with lease time of 700') |
| 1106 | cip, sip, mac, lval = self.dhcp.only_discover(lease_time = True, lease_value=lease_time) |
| 1107 | assert_equal(lval,lease_time) |
| 1108 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, lease_time = True) |
| 1109 | assert_equal(new_cip,cip) |
| 1110 | assert_not_equal(lval, lease_time) #Negative Test Case |
| 1111 | log_test.info('client requested lease time in discover packer is not seen in server ACK packet as expected') |
| 1112 | |
| 1113 | def test_dhcpl2relay_specific_lease_time_only_in_request_but_not_in_discover_packet(self, iface = 'veth0',lease_time=800): |
| 1114 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1115 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1116 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1117 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, lease_time = True,lease_value=lease_time) |
| 1118 | assert_equal(new_cip,cip) |
| 1119 | assert_equal(lval, lease_time) |
| 1120 | log_test.info('client requested lease time in request packet seen in servre replied ACK packet as expected') |
| 1121 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1122 | def test_dhcpl2relay_with_client_renew_time(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1123 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1124 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1125 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1126 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1127 | (cip, sip, mac) ) |
| 1128 | assert_not_equal(cip,None) |
| 1129 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, renew_time = True) |
| 1130 | log_test.info('waiting for renew time..') |
| 1131 | time.sleep(lval) |
| 1132 | latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac, unicast = True) |
| 1133 | assert_equal(latest_cip, cip) |
| 1134 | log_test.info('server renewed client IP when client sends request after renew time, as expected') |
| 1135 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1136 | def test_dhcpl2relay_with_client_rebind_time(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1137 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1138 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1139 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1140 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1141 | (cip, sip, mac) ) |
| 1142 | assert_not_equal(cip,None) |
| 1143 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, rebind_time = True) |
| 1144 | log_test.info('waiting for rebind time..') |
| 1145 | time.sleep(lval) |
| 1146 | latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac) |
| 1147 | assert_equal(latest_cip, cip) |
| 1148 | log_test.info('server renewed client IP when client sends request after rebind time, as expected') |
| 1149 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1150 | def test_dhcpl2relay_with_client_expected_subnet_mask(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1151 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1152 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1153 | expected_subnet = '255.255.255.0' |
| 1154 | self.dhcp.return_option = 'subnet' |
| 1155 | |
| 1156 | cip, sip, mac, subnet_mask = self.dhcp.only_discover() |
| 1157 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1158 | (cip, sip, mac) ) |
| 1159 | assert_equal(subnet_mask,expected_subnet) |
| 1160 | log_test.info('subnet mask in server offer packet is same as configured subnet mask in dhcp server') |
| 1161 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1162 | 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] | 1163 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1164 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1165 | |
| 1166 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1167 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1168 | (cip, sip, mac) ) |
| 1169 | assert_not_equal(cip,None) |
| 1170 | self.dhcp.send_different_option = 'subnet' |
| 1171 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1172 | assert_equal(new_cip, cip) |
| 1173 | log_test.info("Got DHCP Ack despite of specifying wrong Subnet Mask in DHCP Request.") |
| 1174 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1175 | def test_dhcpl2relay_with_client_expected_router_address(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1176 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1177 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1178 | expected_router_address = '20.20.20.1' |
| 1179 | self.dhcp.return_option = 'router' |
| 1180 | |
| 1181 | cip, sip, mac, router_address_value = self.dhcp.only_discover() |
| 1182 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1183 | (cip, sip, mac) ) |
| 1184 | assert_equal(expected_router_address, router_address_value) |
| 1185 | log_test.info('router address in server offer packet is same as configured router address in dhcp server') |
| 1186 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1187 | 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] | 1188 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1189 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1190 | |
| 1191 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1192 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1193 | (cip, sip, mac) ) |
| 1194 | assert_not_equal(cip,None) |
| 1195 | self.dhcp.send_different_option = 'router' |
| 1196 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1197 | assert_equal(new_cip, cip) |
| 1198 | log_test.info("Got DHCP Ack despite of specifying wrong Router Address in DHCP Request.") |
| 1199 | |
| 1200 | def test_dhcpl2relay_with_client_expecting_broadcast_address(self, iface = 'veth0'): |
| 1201 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1202 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1203 | expected_broadcast_address = '192.168.1.255' |
| 1204 | self.dhcp.return_option = 'broadcast_address' |
| 1205 | |
| 1206 | cip, sip, mac, broadcast_address_value = self.dhcp.only_discover() |
| 1207 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1208 | (cip, sip, mac) ) |
| 1209 | assert_equal(expected_broadcast_address, broadcast_address_value) |
| 1210 | log_test.info('broadcast address in server offer packet is same as configured broadcast address in dhcp server') |
| 1211 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1212 | 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] | 1213 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1214 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1215 | |
| 1216 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1217 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1218 | (cip, sip, mac) ) |
| 1219 | assert_not_equal(cip,None) |
| 1220 | self.dhcp.send_different_option = 'broadcast_address' |
| 1221 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1222 | assert_equal(new_cip, cip) |
| 1223 | log_test.info("Got DHCP Ack despite of specifying wrong Broadcast Address in DHCP Request.") |
| 1224 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1225 | def test_dhcpl2relay_with_client_expecting_dns_address(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1226 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1227 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1228 | expected_dns_address = '192.168.1.1' |
| 1229 | self.dhcp.return_option = 'dns' |
| 1230 | |
| 1231 | cip, sip, mac, dns_address_value = self.dhcp.only_discover() |
| 1232 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1233 | (cip, sip, mac) ) |
| 1234 | assert_equal(expected_dns_address, dns_address_value) |
| 1235 | log_test.info('dns address in server offer packet is same as configured dns address in dhcp server') |
| 1236 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1237 | 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] | 1238 | mac = self.get_mac(iface) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1239 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface) |
| 1240 | |
| 1241 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1242 | log_test.info('Got dhcp client IP %s from server %s for mac %s .' % |
| 1243 | (cip, sip, mac) ) |
| 1244 | assert_not_equal(cip,None) |
| 1245 | self.dhcp.send_different_option = 'dns' |
| 1246 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1247 | assert_equal(new_cip, cip) |
| 1248 | log_test.info("Got DHCP Ack despite of specifying wrong DNS Address in DHCP Request.") |
| 1249 | |
| 1250 | |
| 1251 | def test_dhcpl2relay_transactions_per_second(self, iface = 'veth0'): |
| 1252 | |
| 1253 | for i in range(1,4): |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1254 | self.dhcpl2relay_stats_calc() |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1255 | log_test.info("Statistics for run %d",i) |
| 1256 | log_test.info("----------------------------------------------------------------------------------") |
| 1257 | log_test.info("No. of transactions No. of successes No. of failures Running Time ") |
| 1258 | log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff)) |
| 1259 | log_test.info("----------------------------------------------------------------------------------") |
| 1260 | log_test.info("No. of transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 1261 | |
| 1262 | log_test.info("Final Statistics for total transactions") |
| 1263 | log_test.info("----------------------------------------------------------------------------------") |
| 1264 | log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 1265 | log_test.info(" %d %d %d %d" %(self.transactions, |
| 1266 | self.total_success, self.total_failure, self.running_time)) |
| 1267 | log_test.info("----------------------------------------------------------------------------------") |
| 1268 | log_test.info("Average no. of transactions per second: %d", round(self.transactions/self.running_time,0)) |
| 1269 | |
| 1270 | def test_dhcpl2relay_consecutive_successes_per_second(self, iface = 'veth0'): |
| 1271 | |
| 1272 | for i in range(1,4): |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1273 | self.dhcpl2relay_stats_calc(success_rate = True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1274 | log_test.info("Statistics for run %d",i) |
| 1275 | log_test.info("----------------------------------------------------------------------------------") |
| 1276 | log_test.info("No. of consecutive successful transactions Running Time ") |
| 1277 | log_test.info(" %d %d " %(self.ip_count, self.diff)) |
| 1278 | log_test.info("----------------------------------------------------------------------------------") |
| 1279 | log_test.info("No. of successful transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 1280 | log_test.info("----------------------------------------------------------------------------------") |
| 1281 | |
| 1282 | log_test.info("Final Statistics for total successful transactions") |
| 1283 | log_test.info("----------------------------------------------------------------------------------") |
| 1284 | log_test.info("Total transactions Total No. of consecutive successes Running Time ") |
| 1285 | log_test.info(" %d %d %d " %(self.transactions, |
| 1286 | self.total_success, self.running_time)) |
| 1287 | log_test.info("----------------------------------------------------------------------------------") |
| 1288 | log_test.info("Average no. of consecutive successful transactions per second: %d", round(self.total_success/self.running_time,0)) |
| 1289 | log_test.info("----------------------------------------------------------------------------------") |
| 1290 | |
| 1291 | def test_dhcpl2relay_with_max_clients_per_second(self, iface = 'veth0'): |
| 1292 | |
| 1293 | for i in range(1,4): |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1294 | self.dhcpl2relay_stats_calc(only_discover = True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1295 | log_test.info("----------------------------------------------------------------------------------") |
| 1296 | log_test.info("Statistics for run %d of sending only DHCP Discover",i) |
| 1297 | log_test.info("----------------------------------------------------------------------------------") |
| 1298 | log_test.info("No. of transactions No. of successes No. of failures Running Time ") |
| 1299 | log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff)) |
| 1300 | log_test.info("----------------------------------------------------------------------------------") |
| 1301 | log_test.info("No. of clients per second in run %d:%f " |
| 1302 | %(i, self.transaction_count)) |
| 1303 | log_test.info("----------------------------------------------------------------------------------") |
| 1304 | log_test.info("Final Statistics for total transactions of sending only DHCP Discover") |
| 1305 | log_test.info("----------------------------------------------------------------------------------") |
| 1306 | log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 1307 | log_test.info(" %d %d %d %d" %(self.transactions, |
| 1308 | self.total_success, self.total_failure, self.running_time)) |
| 1309 | log_test.info("----------------------------------------------------------------------------------") |
| 1310 | log_test.info("Average no. of clients per second: %d ", |
| 1311 | round(self.transactions/self.running_time,0)) |
| 1312 | log_test.info("----------------------------------------------------------------------------------") |
| 1313 | |
| 1314 | def test_dhcpl2relay_consecutive_successful_clients_per_second(self, iface = 'veth0'): |
| 1315 | |
| 1316 | for i in range(1,4): |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1317 | self.dhcpl2relay_stats_calc(success_rate = True, only_discover = True) |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1318 | log_test.info("----------------------------------------------------------------------------------") |
| 1319 | log_test.info("Statistics for run %d for sending only DHCP Discover",i) |
| 1320 | log_test.info("----------------------------------------------------------------------------------") |
| 1321 | log_test.info("No. of consecutive successful transactions Running Time ") |
| 1322 | log_test.info(" %d %d " %(self.ip_count, self.diff)) |
| 1323 | log_test.info("----------------------------------------------------------------------------------") |
| 1324 | log_test.info("No. of consecutive successful clients per second in run %d:%f" %(i, self.transaction_count)) |
| 1325 | log_test.info("----------------------------------------------------------------------------------") |
| 1326 | |
| 1327 | log_test.info("Final Statistics for total successful transactions") |
| 1328 | log_test.info("----------------------------------------------------------------------------------") |
| 1329 | log_test.info("Total transactions Total No. of consecutive successes Running Time ") |
| 1330 | log_test.info(" %d %d %d " %(self.transactions, |
| 1331 | self.total_success, self.running_time)) |
| 1332 | log_test.info("----------------------------------------------------------------------------------") |
| 1333 | log_test.info("Average no. of consecutive successful clients per second: %d", round(self.total_success/self.running_time,0)) |
| 1334 | log_test.info("----------------------------------------------------------------------------------") |
| 1335 | |
| 1336 | def test_dhcpl2relay_concurrent_transactions_per_second(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1337 | for key in (key for key in g_subscriber_port_map if key < 100): |
| 1338 | self.host_load(g_subscriber_port_map[key]) |
| 1339 | |
| 1340 | def thread_fun(i): |
| 1341 | mac = self.get_mac('veth{}'.format(i)) |
| 1342 | cip, sip = DHCPTest(iface = 'veth{}'.format(i)).discover(mac = mac) |
| 1343 | log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac)) |
| 1344 | self.lock.acquire() |
| 1345 | |
| 1346 | if cip: |
| 1347 | self.ip_count += 1 |
| 1348 | |
| 1349 | elif cip is None: |
| 1350 | self.failure_count += 1 |
| 1351 | |
| 1352 | self.lock.notify_all() |
| 1353 | self.lock.release() |
| 1354 | |
| 1355 | for i in range (1,4): |
| 1356 | self.ip_count = 0 |
| 1357 | self.failure_count = 0 |
| 1358 | self.start_time = 0 |
| 1359 | self.diff = 0 |
| 1360 | self.transaction_count = 0 |
| 1361 | self.start_time = time.time() |
| 1362 | |
| 1363 | while self.diff <= 60: |
| 1364 | t = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(0, random.randrange(1,40,1), 1)}) |
| 1365 | t1 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(42, random.randrange(43,80,1), 1)}) |
| 1366 | t2 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(82, random.randrange(83,120,1), 1)}) |
| 1367 | t3 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(122, random.randrange(123,160,1), 1)}) |
| 1368 | t4 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(162, random.randrange(163,180,1), 1)}) |
| 1369 | t5 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(182, random.randrange(183,196,1), 1)}) |
| 1370 | |
| 1371 | t.start() |
| 1372 | t1.start() |
| 1373 | t2.start() |
| 1374 | t3.start() |
| 1375 | t4.start() |
| 1376 | t5.start() |
| 1377 | |
| 1378 | t.join() |
| 1379 | t1.join() |
| 1380 | t2.join() |
| 1381 | t3.join() |
| 1382 | t4.join() |
| 1383 | t5.join() |
| 1384 | |
| 1385 | self.diff = round(time.time() - self.start_time, 0) |
| 1386 | |
| 1387 | self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2) |
| 1388 | |
| 1389 | self.transactions += (self.ip_count+self.failure_count) |
| 1390 | self.running_time += self.diff |
| 1391 | self.total_success += self.ip_count |
| 1392 | self.total_failure += self.failure_count |
| 1393 | |
| 1394 | |
| 1395 | log_test.info("----------------------------------------------------------------------------------") |
| 1396 | log_test.info("Statistics for run %d",i) |
| 1397 | log_test.info("----------------------------------------------------------------------------------") |
| 1398 | log_test.info("No. of transactions No. of successes No. of failures Running Time ") |
| 1399 | log_test.info(" %d %d %d %d" |
| 1400 | %(self.ip_count+self.failure_count,self.ip_count, self.failure_count, self.diff)) |
| 1401 | log_test.info("----------------------------------------------------------------------------------") |
| 1402 | log_test.info("No. of transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 1403 | log_test.info("----------------------------------------------------------------------------------") |
| 1404 | |
| 1405 | log_test.info("----------------------------------------------------------------------------------") |
| 1406 | log_test.info("Final Statistics for total transactions") |
| 1407 | log_test.info("----------------------------------------------------------------------------------") |
| 1408 | log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 1409 | log_test.info(" %d %d %d %d" %(self.transactions, |
| 1410 | self.total_success, self.total_failure, self.running_time)) |
| 1411 | |
| 1412 | log_test.info("----------------------------------------------------------------------------------") |
| 1413 | log_test.info("Average no. of transactions per second: %d", round(self.transactions/self.running_time,0)) |
| 1414 | log_test.info("----------------------------------------------------------------------------------") |
| 1415 | |
| 1416 | def test_dhcpl2relay_concurrent_consecutive_successes_per_second(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1417 | failure_dir = {} |
| 1418 | |
| 1419 | for key in (key for key in g_subscriber_port_map if key != 100): |
| 1420 | self.host_load(g_subscriber_port_map[key]) |
| 1421 | |
| 1422 | def thread_fun(i, j): |
| 1423 | # log_test.info("Thread Name:%s",current_thread().name) |
| 1424 | # failure_dir[current_thread().name] = True |
| 1425 | while failure_dir.has_key(current_thread().name) is False: |
| 1426 | mac = RandMAC()._fix() |
| 1427 | cip, sip = DHCPTest(iface = 'veth{}'.format(i)).discover(mac = mac) |
| 1428 | i += 2 |
| 1429 | log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac)) |
| 1430 | self.lock.acquire() |
| 1431 | |
| 1432 | if cip: |
| 1433 | self.ip_count += 1 |
| 1434 | self.lock.notify_all() |
| 1435 | self.lock.release() |
| 1436 | elif cip is None: |
| 1437 | self.failure_count += 1 |
| 1438 | failure_dir[current_thread().name] = True |
| 1439 | self.lock.notify_all() |
| 1440 | self.lock.release() |
| 1441 | break |
| 1442 | # self.lock.notify_all() |
| 1443 | # self.lock.release() |
| 1444 | |
| 1445 | for i in range (1,4): |
| 1446 | failure_dir = {} |
| 1447 | self.ip_count = 0 |
| 1448 | self.failure_count = 0 |
| 1449 | self.start_time = 0 |
| 1450 | self.diff = 0 |
| 1451 | self.transaction_count = 0 |
| 1452 | self.start_time = time.time() |
| 1453 | |
| 1454 | while len(failure_dir) != 6: |
| 1455 | t = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 1456 | t1 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 1457 | t2 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 1458 | t3 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 1459 | t4 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 1460 | t5 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2}) |
| 1461 | |
| 1462 | t.start() |
| 1463 | t1.start() |
| 1464 | t2.start() |
| 1465 | t3.start() |
| 1466 | t4.start() |
| 1467 | t5.start() |
| 1468 | |
| 1469 | t.join() |
| 1470 | t1.join() |
| 1471 | t2.join() |
| 1472 | t3.join() |
| 1473 | t4.join() |
| 1474 | t5.join() |
| 1475 | |
| 1476 | self.diff = round(time.time() - self.start_time, 0) |
| 1477 | self.transaction_count = round((self.ip_count)/self.diff, 2) |
| 1478 | |
| 1479 | self.transactions += (self.ip_count+self.failure_count) |
| 1480 | self.running_time += self.diff |
| 1481 | self.total_success += self.ip_count |
| 1482 | self.total_failure += self.failure_count |
| 1483 | |
| 1484 | |
| 1485 | log_test.info("Statistics for run %d",i) |
| 1486 | log_test.info("----------------------------------------------------------------------------------") |
| 1487 | log_test.info("No. of consecutive successful transactions Running Time ") |
| 1488 | log_test.info(" %d %d " %(self.ip_count, self.diff)) |
| 1489 | log_test.info("----------------------------------------------------------------------------------") |
| 1490 | log_test.info("No. of successful transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 1491 | log_test.info("----------------------------------------------------------------------------------") |
| 1492 | |
| 1493 | log_test.info("Final Statistics for total successful transactions") |
| 1494 | log_test.info("----------------------------------------------------------------------------------") |
| 1495 | log_test.info("Total transactions Total No. of consecutive successes Running Time ") |
| 1496 | log_test.info(" %d %d %d " %(self.transactions, |
| 1497 | self.total_success, self.running_time)) |
| 1498 | log_test.info("----------------------------------------------------------------------------------") |
| 1499 | log_test.info("Average no. of consecutive successful transactions per second: %d", round(self.total_success/self.running_time,2)) |
| 1500 | log_test.info("----------------------------------------------------------------------------------") |
| 1501 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1502 | def test_dhcpl2relay_for_concurrent_clients_per_second(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1503 | for key in (key for key in g_subscriber_port_map if key < 100): |
| 1504 | self.host_load(g_subscriber_port_map[key]) |
| 1505 | |
| 1506 | def thread_fun(i): |
| 1507 | # mac = self.get_mac('veth{}'.format(i)) |
| 1508 | cip, sip, mac, _ = DHCPTest(iface = 'veth{}'.format(i)).only_discover(mac = RandMAC()._fix()) |
| 1509 | log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac)) |
| 1510 | self.lock.acquire() |
| 1511 | |
| 1512 | if cip: |
| 1513 | self.ip_count += 1 |
| 1514 | elif cip is None: |
| 1515 | self.failure_count += 1 |
| 1516 | |
| 1517 | self.lock.notify_all() |
| 1518 | self.lock.release() |
| 1519 | |
| 1520 | for i in range (1,4): |
| 1521 | self.ip_count = 0 |
| 1522 | self.failure_count = 0 |
| 1523 | self.start_time = 0 |
| 1524 | self.diff = 0 |
| 1525 | self.transaction_count = 0 |
| 1526 | self.start_time = time.time() |
| 1527 | |
| 1528 | while self.diff <= 60: |
| 1529 | t = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(0, random.randrange(1,40,1), 1)}) |
| 1530 | t1 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(42, random.randrange(43,80,1), 1)}) |
| 1531 | t2 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(82, random.randrange(83,120,1), 1)}) |
| 1532 | t3 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(122, random.randrange(123,160,1), 1)}) |
| 1533 | t4 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(162, random.randrange(163,180,1), 1)}) |
| 1534 | t5 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(182, random.randrange(183,196,1), 1)}) |
| 1535 | |
| 1536 | t.start() |
| 1537 | t1.start() |
| 1538 | t2.start() |
| 1539 | t3.start() |
| 1540 | t4.start() |
| 1541 | t5.start() |
| 1542 | |
| 1543 | t.join() |
| 1544 | t1.join() |
| 1545 | t2.join() |
| 1546 | t3.join() |
| 1547 | t4.join() |
| 1548 | t5.join() |
| 1549 | |
| 1550 | self.diff = round(time.time() - self.start_time, 0) |
| 1551 | self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2) |
| 1552 | self.transactions += (self.ip_count+self.failure_count) |
| 1553 | self.running_time += self.diff |
| 1554 | self.total_success += self.ip_count |
| 1555 | self.total_failure += self.failure_count |
| 1556 | |
| 1557 | log_test.info("----------------------------------------------------------------------------------") |
| 1558 | log_test.info("Statistics for run %d of sending only DHCP Discover",i) |
| 1559 | log_test.info("----------------------------------------------------------------------------------") |
| 1560 | log_test.info("No. of transactions No. of successes No. of failures Running Time ") |
| 1561 | log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff)) |
| 1562 | log_test.info("----------------------------------------------------------------------------------") |
| 1563 | log_test.info("No. of clients per second in run %d:%f " |
| 1564 | %(i, self.transaction_count)) |
| 1565 | log_test.info("----------------------------------------------------------------------------------") |
| 1566 | |
| 1567 | log_test.info("Final Statistics for total transactions of sending only DHCP Discover") |
| 1568 | log_test.info("----------------------------------------------------------------------------------") |
| 1569 | log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 1570 | log_test.info(" %d %d %d %d" %(self.transactions, |
| 1571 | self.total_success, self.total_failure, self.running_time)) |
| 1572 | log_test.info("----------------------------------------------------------------------------------") |
| 1573 | log_test.info("Average no. of clients per second: %d ", |
| 1574 | round(self.transactions/self.running_time,0)) |
| 1575 | log_test.info("----------------------------------------------------------------------------------") |
| 1576 | |
Chetan Gaonker | a6050ae | 2017-09-02 19:15:01 +0000 | [diff] [blame] | 1577 | def test_dhcpl2relay_with_client_conflict(self, iface = 'veth0'): |
Chetan Gaonker | c1df33a | 2017-08-18 01:29:54 +0000 | [diff] [blame] | 1578 | mac = self.get_mac(iface) |
| 1579 | self.host_load(iface) |
| 1580 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 1581 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 1582 | log_test.info('Got dhcp client IP %s from server %s for mac %s.' % |
| 1583 | (cip, sip, mac) ) |
| 1584 | self.dhcp1 = DHCPTest(seed_ip = cip, iface = iface) |
| 1585 | new_cip, new_sip, new_mac, _ = self.dhcp1.only_discover(desired = True) |
| 1586 | new_cip, new_sip = self.dhcp1.only_request(new_cip, new_mac) |
| 1587 | log_test.info('Got dhcp client IP %s from server %s for mac %s.' % |
| 1588 | (new_cip, new_sip, new_mac) ) |
| 1589 | log_test.info("IP %s alredy consumed by mac %s." % (new_cip, new_mac)) |
| 1590 | log_test.info("Now sending DHCP Request for old DHCP discover.") |
| 1591 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 1592 | if new_cip is None: |
| 1593 | log_test.info('Got dhcp client IP %s from server %s for mac %s.Which is expected behavior.' |
| 1594 | %(new_cip, new_sip, new_mac) ) |
| 1595 | elif new_cip: |
| 1596 | 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.' |
| 1597 | %(new_cip, new_sip, new_mac, new_cip) ) |
| 1598 | assert_equal(new_cip, None) |