blob: 44d338b6122ec7ca14f5fb637d72f60fd1f28acf [file] [log] [blame]
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +00001
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#
32import unittest
33from nose.tools import *
34from nose.twistedtools import reactor, deferred
35from twisted.internet import defer
36import time
37import os, sys
38from DHCP import DHCPTest
39from CordTestUtils import get_mac, log_test
40from OnosCtrl import OnosCtrl
41from OltConfig import OltConfig
42from CordTestServer import cord_test_onos_restart
Thangavelu K Sa61d1da2017-09-05 05:32:21 -070043from CordTestConfig import setup_module, teardown_module
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +000044from CordLogger import CordLogger
45from portmaps import g_subscriber_port_map
Thangavelu K Sa61d1da2017-09-05 05:32:21 -070046from CordContainer import Onos
A R Karthicke7232092017-09-07 18:01:33 -070047from VolthaCtrl import VolthaCtrl
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +000048import threading, random
49from threading import current_thread
50log_test.setLevel('INFO')
51
52class dhcpl2relay_exchange(CordLogger):
53
Thangavelu K Sa61d1da2017-09-05 05:32:21 -070054 VOLTHA_HOST = None
A R Karthicke7232092017-09-07 18:01:33 -070055 VOLTHA_REST_PORT = VolthaCtrl.REST_PORT
Thangavelu K Sa61d1da2017-09-05 05:32:21 -070056 VOLTHA_ENABLED = bool(int(os.getenv('VOLTHA_ENABLED', 0)))
57 VOLTHA_OLT_TYPE = 'simulated_olt'
58 VOLTHA_OLT_MAC = '00:0c:e2:31:12:00'
59 VOLTHA_UPLINK_VLAN_MAP = { 'of:0000000000000001' : '222' }
60
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +000061 app = 'org.opencord.dhcpl2relay'
62 sadis_app = 'org.opencord.sadis'
63 app_dhcp = 'org.onosproject.dhcp'
64 relay_interfaces_last = ()
65 interface_to_mac_map = {}
66 host_ip_map = {}
67 test_path = os.path.dirname(os.path.realpath(__file__))
68 dhcp_data_dir = os.path.join(test_path, '..', 'setup')
Thangavelu K Sa61d1da2017-09-05 05:32:21 -070069 dhcpl2_app_file = os.path.join(test_path, '..', 'apps/dhcpl2relay-1.0.0.oar')
70 sadis_app_file = os.path.join(test_path, '..', 'apps/sadis-app-1.0.0-SNAPSHOT.oar')
71 olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config_voltha_local.json'))
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +000072 default_config = { 'default-lease-time' : 600, 'max-lease-time' : 7200, }
73 default_options = [ ('subnet-mask', '255.255.255.0'),
74 ('broadcast-address', '192.168.1.255'),
75 ('domain-name-servers', '192.168.1.1'),
76 ('domain-name', '"mydomain.cord-tester"'),
77 ]
78 default_subnet_config = [ ('192.168.1.2',
79'''
80subnet 192.168.1.0 netmask 255.255.255.0 {
81 range 192.168.1.10 192.168.1.100;
82}
83'''), ]
84
85 lock = threading.Condition()
86 ip_count = 0
87 failure_count = 0
88 start_time = 0
89 diff = 0
90
91 transaction_count = 0
92 transactions = 0
93 running_time = 0
94 total_success = 0
95 total_failure = 0
96 #just in case we want to reset ONOS to default network cfg after relay tests
97 onos_restartable = bool(int(os.getenv('ONOS_RESTART', 0)))
98 configs = {}
99
100 @classmethod
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700101 def update_apps_version(cls):
102 version = Onos.getVersion()
103 major = int(version.split('.')[0])
104 minor = int(version.split('.')[1])
105 dhcpl2_app_version = '1.0.0'
106 sadis_app_version = '1.0.0-SNAPSHOT'
107# sadis-app-1.0.0-SNAPSHOT.oar
108# if major > 1:
109# cordigmp_app_version = '3.0-SNAPSHOT'
110# olt_app_version = '2.0-SNAPSHOT'
111# elif major == 1:
112# if minor > 10:
113# cordigmp_app_version = '3.0-SNAPSHOT'
114# olt_app_version = '2.0-SNAPSHOT'
115# elif minor <= 8:
116# olt_app_version = '1.1-SNAPSHOT'
117 cls.dhcpl2_app_file = os.path.join(cls.test_path, '..', 'apps/dhcpl2relay-{}.oar'.format(dhcpl2_app_version))
118 cls.sadis_app_file = os.path.join(cls.test_path, '..', 'apps/sadis-app-{}.oar'.format(sadis_app_version))
119
120
121 @classmethod
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000122 def setUpClass(cls):
123 ''' Activate the cord dhcpl2relay app'''
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700124 cls.update_apps_version()
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000125 OnosCtrl(cls.app_dhcp).deactivate()
126 time.sleep(3)
127 cls.onos_ctrl = OnosCtrl(cls.app)
128 status, _ = cls.onos_ctrl.activate()
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700129 #assert_equal(status, True)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000130 time.sleep(3)
131 cls.onos_ctrl = OnosCtrl(cls.sadis_app)
132 status, _ = cls.onos_ctrl.activate()
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700133 #assert_equal(status, True)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000134 time.sleep(3)
135 cls.dhcp_l2_relay_setup()
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700136 cls.cord_sadis_load()
137 cls.cord_l2_relay_load()
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000138 ##start dhcpd initially with default config
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700139 #cls.dhcpd_start()
140
141 def setUp(self):
142 super(dhcpl2relay_exchange, self).setUp()
143
144 def tearDown(self):
145 super(dhcpl2relay_exchange, self).tearDown()
Thangavelu K Saf3a1512017-09-06 06:34:14 -0700146 OnosCtrl.uninstall_app(self.dhcpl2_app_file)
147 OnosCtrl.uninstall_app(self.sadis_app_file)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000148
149 @classmethod
150 def tearDownClass(cls):
151 '''Deactivate the cord dhcpl2relay app'''
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700152 #try:
153 # os.unlink('{}/dhcpd.conf'.format(cls.dhcp_data_dir))
154 # os.unlink('{}/dhcpd.leases'.format(cls.dhcp_data_dir))
155 #except: pass
156 OnosCtrl.uninstall_app(cls.dhcpl2_app_file)
157 OnosCtrl.uninstall_app(cls.sadis_app_file)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000158 cls.onos_ctrl.deactivate()
Thangavelu K Saf3a1512017-09-06 06:34:14 -0700159 OnosCtrl(cls.app).deactivate()
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700160 #cls.dhcpd_stop()
Thangavelu K Saf3a1512017-09-06 06:34:14 -0700161 #cls.dhcp_l2_relay_cleanup()
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000162
163 @classmethod
164 def dhcp_l2_relay_setup(cls):
165 did = OnosCtrl.get_device_id()
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700166 #cls.relay_device_id = did
167 ### Have to change hard coded value in relay device variable on later merges
168 cls.relay_device_id = 'of:000012b722fd4948'
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000169 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
170 cls.port_map, _ = cls.olt.olt_port_map()
171 if cls.port_map:
172 ##Per subscriber, we use 1 relay port
173 try:
174 relay_port = cls.port_map[cls.port_map['relay_ports'][0]]
175 except:
176 relay_port = cls.port_map['uplink']
177 cls.relay_interface_port = relay_port
178 cls.relay_interfaces = (cls.port_map[cls.relay_interface_port],)
179 else:
180 cls.relay_interface_port = 100
181 cls.relay_interfaces = (g_subscriber_port_map[cls.relay_interface_port],)
182 cls.relay_interfaces_last = cls.relay_interfaces
183 if cls.port_map:
184 ##generate a ip/mac client virtual interface config for onos
185 interface_list = []
186 for port in cls.port_map['ports']:
187 port_num = cls.port_map[port]
188 if port_num == cls.port_map['uplink']:
189 continue
190 ip = cls.get_host_ip(port_num)
191 mac = cls.get_mac(port)
192 interface_list.append((port_num, ip, mac))
193
194 #configure dhcp server virtual interface on the same subnet as first client interface
195 relay_ip = cls.get_host_ip(interface_list[0][0])
196 relay_mac = cls.get_mac(cls.port_map[cls.relay_interface_port])
197 interface_list.append((cls.relay_interface_port, relay_ip, relay_mac))
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700198 #cls.onos_interface_load(interface_list)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000199
200 @classmethod
201 def dhcp_l2_relay_cleanup(cls):
202 ##reset the ONOS port configuration back to default
203 for config in cls.configs.items():
204 OnosCtrl.delete(config)
205 # if cls.onos_restartable is True:
206 # log_test.info('Cleaning up dhcp relay config by restarting ONOS with default network cfg')
207 # return cord_test_onos_restart(config = {})
208
209 @classmethod
210 def onos_load_config(cls, config):
211 status, code = OnosCtrl.config(config)
212 if status is False:
213 log_test.info('JSON request returned status %d' %code)
214 assert_equal(status, True)
215 time.sleep(3)
216
217 @classmethod
218 def onos_interface_load(cls, interface_list):
219 interface_dict = { 'ports': {} }
220 for port_num, ip, mac in interface_list:
221 port_map = interface_dict['ports']
222 port = '{}/{}'.format(cls.relay_device_id, port_num)
223 port_map[port] = { 'interfaces': [] }
224 interface_list = port_map[port]['interfaces']
225 interface_map = { 'ips' : [ '{}/{}'.format(ip, 24) ],
226 'mac' : mac,
227 'name': 'vir-{}'.format(port_num)
228 }
229 interface_list.append(interface_map)
230
231 cls.onos_load_config(interface_dict)
232 cls.configs['interface_config'] = interface_dict
233
234 @classmethod
235 def cord_l2_relay_load(cls):
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700236 OnosCtrl.uninstall_app(cls.dhcpl2_app_file)
237 #relay_device_map = '{}/{}'.format(cls.relay_device_id, cls.relay_interface_port)
Thangavelu K Saf3a1512017-09-06 06:34:14 -0700238 relay_device_map = "{}/12".format(cls.relay_device_id)
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700239 print relay_device_map
240 dhcp_dict = { "apps" : { "org.opencord.dhcpl2relay" : {"dhcpl2relay" :
241 {"dhcpserverConnectPoint":[relay_device_map]}
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000242 }
243 }
244 }
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700245 print "---------------------------------------------"
246 print dhcp_dict
247 print "---------------------------------------------"
248 OnosCtrl.uninstall_app(cls.dhcpl2_app_file)
249 OnosCtrl.install_app(cls.dhcpl2_app_file)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000250 cls.onos_load_config(dhcp_dict)
251 cls.configs['relay_config'] = dhcp_dict
252
253 @classmethod
254 def cord_sadis_load(cls):
255 relay_device_id = '{}'.format(cls.relay_device_id)
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700256 sadis_dict = { "apps": {
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000257 "org.opencord.sadis": {
258 "sadis": {
259 "integration": {
260 "cache": {
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700261 "enabled": "true",
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000262 "maxsize": 50,
263 "ttl": "PT1m"
264 }
265 },
266 "entries": [{
267 "id": "uni-254",
268 "cTag": 202,
269 "sTag": 222,
270 "nasPortId": "uni-254"
271 },
272 {
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700273 "id": "67cc7ae085204e3091493db645e8ae63",
274 "hardwareIdentifier": "00:0c:e2:31:05:00",
275 "ipAddress": "172.17.0.1",
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000276 "nasId": "B100-NASID"
277 }
278 ]
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700279 }
280 }
281 }
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000282 }
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700283 OnosCtrl.uninstall_app(cls.sadis_app_file)
284 OnosCtrl.install_app(cls.sadis_app_file)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000285 cls.onos_load_config(sadis_dict)
286 cls.configs['relay_config'] = sadis_dict
287
288 @classmethod
289 def get_host_ip(cls, port):
290 if cls.host_ip_map.has_key(port):
291 return cls.host_ip_map[port]
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700292 cls.host_ip_map[port] = '192.168.100.{}'.format(port)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000293 return cls.host_ip_map[port]
294
295 @classmethod
296 def host_load(cls, iface):
297 '''Have ONOS discover the hosts for dhcp-relay responses'''
298 port = g_subscriber_port_map[iface]
299 host = '173.17.1.{}'.format(port)
300 cmds = ( 'ifconfig {} 0'.format(iface),
301 'ifconfig {0} {1}'.format(iface, host),
302 'arping -I {0} {1} -c 2'.format(iface, host),
303 'ifconfig {} 0'.format(iface), )
304 for c in cmds:
305 os.system(c)
306
307 @classmethod
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000308 def get_mac(cls, iface):
309 if cls.interface_to_mac_map.has_key(iface):
310 return cls.interface_to_mac_map[iface]
311 mac = get_mac(iface, pad = 0)
312 cls.interface_to_mac_map[iface] = mac
313 return mac
314
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000315 def dhcpl2relay_stats_calc(self, success_rate = False, only_discover = False, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000316
317 self.ip_count = 0
318 self.failure_count = 0
319 self.start_time = 0
320 self.diff = 0
321 self.transaction_count = 0
322
323 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000324 self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = iface)
325 self.start_time = time.time()
326
327 while self.diff <= 60:
328
329 if only_discover:
330 cip, sip, mac, _ = self.dhcp.only_discover(multiple = True)
331 log_test.info('Got dhcp client IP %s from server %s for mac %s' %
332 (cip, sip, mac))
333 else:
334 cip, sip = self.send_recv(mac=mac, update_seed = True, validate = False)
335
336 if cip:
337 self.ip_count +=1
338 elif cip == None:
339 self.failure_count += 1
340 log_test.info('Failed to get ip')
341 if success_rate and self.ip_count > 0:
342 break
343
344 self.diff = round(time.time() - self.start_time, 0)
345
346 self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2)
347 self.transactions += (self.ip_count+self.failure_count)
348 self.running_time += self.diff
349 self.total_success += self.ip_count
350 self.total_failure += self.failure_count
351
352 def send_recv(self, mac=None, update_seed = False, validate = True):
353 cip, sip = self.dhcp.discover(mac = mac, update_seed = update_seed)
354 if validate:
355 assert_not_equal(cip, None)
356 assert_not_equal(sip, None)
357 log_test.info('Got dhcp client IP %s from server %s for mac %s' %
358 (cip, sip, self.dhcp.get_mac(cip)[0]))
359 return cip,sip
360
361 def test_dhcpl2relay_with_one_request(self, iface = 'veth0'):
362 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000363 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
364 self.send_recv(mac=mac)
365
Chetan Gaonker891302d2017-09-05 15:09:26 +0000366 def test_dhcpl2relay_app_install(self):
Thangavelu K S46063d02017-09-08 21:13:24 +0000367 mac = self.get_mac(iface)
368 onos_netcfg = OnosCtrl.get_config()
369 app_status = False
370 app_name = 'org.opencord.dhcpl2relay'
371 for app in onos_netcfg['apps']:
372 if app == app_name:
373 log_test.info('%s app is being installed'%app)
374 app_status = True
375 if app_status is not True:
376 log_test.info('%s app is not being installed'%app_name)
377 assert_equal(True, app_status)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000378
379 def test_dhcpl2relay_netcfg(self):
Thangavelu K S46063d02017-09-08 21:13:24 +0000380 mac = self.get_mac(iface)
381 onos_netcfg = OnosCtrl.get_config()
382 app_status = False
383 app_name = 'org.opencord.sadis'
384 for app in onos_netcfg['apps']:
385 if app == app_name:
386 log_test.info('%s app is being installed'%app)
387 app_status = True
388 if app_status is not True:
389 log_test.info('%s app is not being installed'%app_name)
390 assert_equal(True, app_status)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000391
392 def test_dhcpl2relay_with_array_of_connect_points_for_dhcp_server(self):
393 pass
394
395 def test_dhcpl2relay_with_subscriber_configured_with_ctag_stag_as_per_sadis(self):
396 pass
397
398 def test_dhcpl2relay_app_activation_and_deactivation_multiple_times(self):
Thangavelu K S46063d02017-09-08 21:13:24 +0000399 iterations = 10
400 for i in range(iterations):
401 cls.onos_ctrl.activate()
402 log_test.info('Dhcpl2relay app is tested activating and deactivating app multiple times %s '%iterations)
403 mac = self.get_mac(iface)
404 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
405 self.send_recv(mac=mac)
406 cls.onos_ctrl.deactivate()
407 time.sleep(3)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000408
409 def test_dhcpl2relay_without_sadis_app(self):
Thangavelu K S46063d02017-09-08 21:13:24 +0000410 mac = self.get_mac(iface)
411 self.onos_delete_config(self.sadis_configs['relay_config'])
412 onos_netcfg = OnosCtrl.get_config()
413 app_status = False
414 app_name = 'org.opencord.sadis'
415 for app in onos_netcfg['apps']:
416 if app == app_name:
417 log_test.info('%s app is being installed'%app)
418 if onos_netcfg['apps'][app_name] == {}:
419 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
420 elif onos_netcfg['apps'][app_name]['dhcpServerConnectPoints'] == dhcp_server_array_connectPoints:
421 log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['dhcpServerConnectPoints'])
422 app_status = True
423 if app_status is not True:
424 ## Testing dhcpl2relay with out Sadis app in ONOS app_status should be failed
425 assert_equal(False, False)
426 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
427 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
428 assert_equal(cip,None)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000429
Thangavelu K S46063d02017-09-08 21:13:24 +0000430 def test_dhcpl2relay_delete_and_add_for_sadis_app(self, iface = 'veth0'):
431 mac = self.get_mac(iface)
432 self.onos_delete_config(self.sadis_configs['relay_config'])
433 onos_netcfg = OnosCtrl.get_config()
434 app_status = False
435 app_name = 'org.opencord.sadis'
436 for app in onos_netcfg['apps']:
437 if app == app_name:
438 log_test.info('%s app is being installed'%app)
439 if onos_netcfg['apps'][app_name] == {}:
440 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
441 elif onos_netcfg['apps'][app_name]['dhcpServerConnectPoints'] == dhcp_server_array_connectPoints:
442 log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['dhcpServerConnectPoints'])
443 app_status = True
444 if app_status is not True:
445 ## Testing dhcpl2relay with out Sadis app in ONOS app_statu should be failed
446 assert_equal(False, False)
447 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
448 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
449 assert_equal(cip,None)
450 self.onos_load_config(self.sadis_configs['relay_config'])
451 self.send_recv(mac=mac)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000452
453 def test_dhcpl2relay_with_option_82(self):
454 pass
455
456 def test_dhcpl2relay_without_option_82(self):
457 pass
458
459 def test_dhcl2relay_for_option82_without_configuring_dhcpserver_to_accept_option82(self):
460 pass
461
Thangavelu K S46063d02017-09-08 21:13:24 +0000462 def test_dhcpl2relay_with_uni_port_entry_in_sadis_config(self):
463 mac = self.get_mac(iface)
464 self.onos_delete_config(self.sadis_configs['relay_config'])
465 subscriber_port_id = "uni-200"
466 invalid_sadis_info = self.sadis_info_dict(subscriber_port_id = "uni-200")
467 self.cord_sadis_load(sadis_info = invalid_sadis_info)
468 onos_netcfg = OnosCtrl.get_config()
469 app_status = False
470 app_name = 'org.opencord.sadis'
471 for app in onos_netcfg['apps']:
472 if app == app_name:
473 log_test.info('%s app is being installed'%app)
474 if onos_netcfg['apps'][app_name] == {}:
475 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
476 elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['id'] == subscriber_port_id:
477 #log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['sadis']['entries'][0]['id'])
478 app_status = True
479 if app_status is not True:
480 assert_equal(True, False)
481 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
482 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
483 assert_equal(cip,None)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000484
Thangavelu K S46063d02017-09-08 21:13:24 +0000485 def test_dhcpl2relay_with_different_ctag_options(self):
486 mac = self.get_mac(iface)
487 self.onos_delete_config(self.sadis_configs['relay_config'])
488 c_tag = 600 #Example
489 invalid_sadis_info = self.sadis_info_dict(c_tag = 600)
490 self.cord_sadis_load(sadis_info = invalid_sadis_info)
491 onos_netcfg = OnosCtrl.get_config()
492 app_status = False
493 app_name = 'org.opencord.sadis'
494 for app in onos_netcfg['apps']:
495 if app == app_name:
496 log_test.info('%s app is being installed'%app)
497 if onos_netcfg['apps'][app_name] == {}:
498 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
499 elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['cTag'] == c_tag:
500 #log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['sadis']['entries'][0]['cTag'])
501 app_status = True
502 if app_status is not True:
503 assert_equal(True, False)
504 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
505 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
506 assert_equal(cip,None)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000507
Thangavelu K S46063d02017-09-08 21:13:24 +0000508 def test_dhcpl2relay_with_different_stag_options(self):
509 mac = self.get_mac(iface)
510 self.onos_delete_config(self.sadis_configs['relay_config'])
511 s_tag = 600
512 invalid_sadis_info = self.sadis_info_dict(s_tag = 600)
513 self.cord_sadis_load(sadis_info = invalid_sadis_info)
514 onos_netcfg = OnosCtrl.get_config()
515 app_status = False
516 app_name = 'org.opencord.sadis'
517 for app in onos_netcfg['apps']:
518 if app == app_name:
519 log_test.info('%s app is being installed'%app)
520 if onos_netcfg['apps'][app_name] == {}:
521 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
522 elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['sTag'] == s_tag:
523 #log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['sadis']['entries'][0]['sTag'])
524 app_status = True
525 if app_status is not True:
526 assert_equal(True, False)
527 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
528 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
529 assert_equal(cip,None)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000530
531 def test_dhcpl2relay_with_nasportid_option_in_sadis(self):
Thangavelu K S46063d02017-09-08 21:13:24 +0000532 mac = self.get_mac(iface)
533 self.onos_delete_config(self.sadis_configs['relay_config'])
534 invalid_sadis_info = self.sadis_info_dict(nas_port_id = " ")
535 self.cord_sadis_load(sadis_info = invalid_sadis_info)
536 onos_netcfg = OnosCtrl.get_config()
537 app_status = False
538 app_name = 'org.opencord.sadis'
539 for app in onos_netcfg['apps']:
540 if app == app_name:
541 log_test.info('%s app is being installed'%app)
542 if onos_netcfg['apps'][app_name] == {}:
543 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
544 elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['nasPortId'] == " ":
545 #log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['sadis']['entries'][0]['nasPortId'])
546 app_status = True
547 if app_status is not True:
548 assert_equal(True, False)
549 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
550 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
551 assert_equal(cip,None)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000552
553 def test_dhcpl2relay_with_nasportid_different_from_id(self):
Thangavelu K S46063d02017-09-08 21:13:24 +0000554 mac = self.get_mac(iface)
555 self.onos_delete_config(self.sadis_configs['relay_config'])
556 nas_port_id = "uni-509"
557 invalid_sadis_info = self.sadis_info_dict(nas_port_id = "uni-509")
558 self.cord_sadis_load(sadis_info = invalid_sadis_info)
559 onos_netcfg = OnosCtrl.get_config()
560 app_status = False
561 app_name = 'org.opencord.sadis'
562 for app in onos_netcfg['apps']:
563 if app == app_name:
564 log_test.info('%s app is being installed'%app)
565 if onos_netcfg['apps'][app_name] == {}:
566 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
567 elif onos_netcfg['apps'][app_name]['sadis']['entries'][0]['nasPortId'] == nas_port_id:
568 #log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['sadis']['entries'][0]['nasPortId'])
569 app_status = True
570 if app_status is not True:
571 assert_equal(True, False)
572 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
573 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
574 assert_equal(cip,None)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000575
576 def test_dhcpl2relay_with_serial_id_of_olt(self):
Thangavelu K S46063d02017-09-08 21:13:24 +0000577 mac = self.get_mac(iface)
578 self.onos_delete_config(self.sadis_configs['relay_config'])
579 invalid_sadis_info = self.sadis_info_dict(olt_serial_id = " ")
580 self.cord_sadis_load(sadis_info = invalid_sadis_info)
581 onos_netcfg = OnosCtrl.get_config()
582 app_status = False
583 app_name = 'org.opencord.sadis'
584 for app in onos_netcfg['apps']:
585 if app == app_name:
586 log_test.info('%s app is being installed'%app)
587 if onos_netcfg['apps'][app_name] == {}:
588 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
589 elif onos_netcfg['apps'][app_name]['sadis']['entries'][1]['id'] == " ":
590 #log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['sadis']['entries'][1]['id'])
591 app_status = True
592 if app_status is not True:
593 assert_equal(True, False)
594 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
595 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
596 assert_equal(cip,None)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000597
598 def test_dhcpl2relay_with_wrong_serial_id_of_olt(self):
Thangavelu K S46063d02017-09-08 21:13:24 +0000599 mac = self.get_mac(iface)
600 self.onos_delete_config(self.sadis_configs['relay_config'])
601 olt_serial_id = "07f20d06696041febf974ccdhdhhjh37"
602 invalid_sadis_info = self.sadis_info_dict(olt_serial_id = "07f20d06696041febf974ccdhdhhjh37")
603 self.cord_sadis_load(sadis_info = invalid_sadis_info)
604 onos_netcfg = OnosCtrl.get_config()
605 app_status = False
606 app_name = 'org.opencord.sadis'
607 for app in onos_netcfg['apps']:
608 if app == app_name:
609 log_test.info('%s app is being installed'%app)
610 if onos_netcfg['apps'][app_name] == {}:
611 log_test.info('%s app is being installed but network configuration is not shown'%onos_netcfg['apps'][app_name])
612 elif onos_netcfg['apps'][app_name]['sadis']['entries'][1]['id'] == olt_serial_id:
613 #log_test.info('%s app is being installed but network configuration is shown = %s'%onos_netcfg['apps'][app_name]['sadis']['entries'][1]['id'])
614 app_status = True
615 if app_status is not True:
616 assert_equal(True, False)
617 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
618 cip, sip, mac, _ = self.dhcp.only_discover(mac=mac)
619 assert_equal(cip,None)
Chetan Gaonker891302d2017-09-05 15:09:26 +0000620
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000621 def test_dhcpl2relay_for_one_request_with_invalid_source_mac_broadcast(self, iface = 'veth0'):
622 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000623 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
624 cip, sip, mac, _ = self.dhcp.only_discover(mac='ff:ff:ff:ff:ff:ff')
625 assert_equal(cip,None)
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000626 log_test.info('Dhcp server rejected client discover with invalid source mac, as expected')
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000627
628 def test_dhcpl2relay_for_one_request_with_invalid_source_mac_multicast(self, iface = 'veth0'):
629 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000630 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
631 cip, sip, mac, _ = self.dhcp.only_discover(mac='01:80:c2:01:98:05')
632 assert_equal(cip,None)
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000633 log_test.info('Dhcp server rejected client discover with invalid source mac, as expected')
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000634
635 def test_dhcpl2relay_for_one_request_with_invalid_source_mac_zero(self, iface = 'veth0'):
636 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000637 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
638 cip, sip, mac, _ = self.dhcp.only_discover(mac='00:00:00:00:00:00')
639 assert_equal(cip,None)
640 log_test.info('dhcp server rejected client discover with invalid source mac, as expected')
641
642 def test_dhcpl2relay_with_N_requests(self, iface = 'veth0',requests=10):
643 mac = self.get_mac(iface)
Thangavelu K Sa61d1da2017-09-05 05:32:21 -0700644 self.dhcp = DHCPTest(seed_ip = '192.169.100.1', iface = iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000645 ip_map = {}
646 for i in range(requests):
647 #mac = RandMAC()._fix()
648 #log_test.info('mac is %s'%mac)
649 cip, sip = self.send_recv(update_seed = True)
650 if ip_map.has_key(cip):
651 log_test.info('IP %s given out multiple times' %cip)
652 assert_equal(False, ip_map.has_key(cip))
653 ip_map[cip] = sip
654 time.sleep(1)
655
656 def test_dhcpl2relay_with_one_release(self, iface = 'veth0'):
657 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000658 self.dhcp = DHCPTest(seed_ip = '10.10.100.10', iface = iface)
659 cip, sip = self.send_recv(mac=mac)
660 log_test.info('Releasing ip %s to server %s' %(cip, sip))
661 assert_equal(self.dhcp.release(cip), True)
662 log_test.info('Triggering DHCP discover again after release')
663 cip2, sip2 = self.send_recv(mac=mac)
664 log_test.info('Verifying released IP was given back on rediscover')
665 assert_equal(cip, cip2)
666 log_test.info('Test done. Releasing ip %s to server %s' %(cip2, sip2))
667 assert_equal(self.dhcp.release(cip2), True)
668
669 def test_dhcpl2relay_with_Nreleases(self, iface = 'veth0'):
670 mac = None
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000671 self.dhcp = DHCPTest(seed_ip = '192.170.1.10', iface = iface)
672 ip_map = {}
673 for i in range(10):
674 cip, sip = self.send_recv(mac=mac, update_seed = True)
675 if ip_map.has_key(cip):
676 log_test.info('IP %s given out multiple times' %cip)
677 assert_equal(False, ip_map.has_key(cip))
678 ip_map[cip] = sip
679
680 for ip in ip_map.keys():
681 log_test.info('Releasing IP %s' %ip)
682 assert_equal(self.dhcp.release(ip), True)
683
684 ip_map2 = {}
685 log_test.info('Triggering DHCP discover again after release')
686 self.dhcp = DHCPTest(seed_ip = '192.170.1.10', iface = iface)
687 for i in range(len(ip_map.keys())):
688 cip, sip = self.send_recv(mac=mac, update_seed = True)
689 ip_map2[cip] = sip
690
691 log_test.info('Verifying released IPs were given back on rediscover')
692 if ip_map != ip_map2:
693 log_test.info('Map before release %s' %ip_map)
694 log_test.info('Map after release %s' %ip_map2)
695 assert_equal(ip_map, ip_map2)
696
697 def test_dhcpl2relay_starvation(self, iface = 'veth0'):
698 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000699 self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = iface)
700 log_test.info('Verifying 1 ')
701 count = 0
702 while True:
703 #mac = RandMAC()._fix()
704 cip, sip = self.send_recv(update_seed = True,validate = False)
705 if cip is None:
706 break
707 else:
708 count += 1
709 assert_equal(count,91)
710 log_test.info('Verifying 2 ')
711 cip, sip = self.send_recv(mac=mac, update_seed = True, validate = False)
712 assert_equal(cip, None)
713 assert_equal(sip, None)
714
715 def test_dhcpl2relay_with_same_client_and_multiple_discovers(self, iface = 'veth0'):
716 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000717 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
718 cip, sip, mac, _ = self.dhcp.only_discover()
719 log_test.info('Got dhcp client IP %s from server %s for mac %s . Not going to send DHCPREQUEST.' %
720 (cip, sip, mac) )
721 assert_not_equal(cip, None)
722 log_test.info('Triggering DHCP discover again.')
723 new_cip, new_sip, new_mac, _ = self.dhcp.only_discover()
724 assert_equal(new_cip, cip)
725 log_test.info('got same ip to smae the client when sent discover again, as expected')
726
727 def test_dhcpl2relay_with_same_client_and_multiple_requests(self, iface = 'veth0'):
728 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000729 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
730 log_test.info('Sending DHCP discover and DHCP request.')
731 cip, sip = self.send_recv(mac=mac)
732 mac = self.dhcp.get_mac(cip)[0]
733 log_test.info("Sending DHCP request again.")
734 new_cip, new_sip = self.dhcp.only_request(cip, mac)
735 assert_equal(new_cip, cip)
736 log_test.info('got same ip to smae the client when sent request again, as expected')
737
738 def test_dhcpl2relay_with_clients_desired_address(self, iface = 'veth0'):
739 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000740 self.dhcp = DHCPTest(seed_ip = '192.168.1.31', iface = iface)
741 cip, sip, mac, _ = self.dhcp.only_discover(desired = True)
742 assert_equal(cip,self.dhcp.seed_ip)
743 log_test.info('Got dhcp client desired IP %s from server %s for mac %s as expected' %
744 (cip, sip, mac) )
745
746 def test_dhcpl2relay_with_clients_desired_address_in_out_of_pool(self, iface = 'veth0'):
747 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000748 self.dhcp = DHCPTest(seed_ip = '20.20.20.35', iface = iface)
749 cip, sip, mac, _ = self.dhcp.only_discover(desired = True)
750 assert_not_equal(cip,None)
751 assert_not_equal(cip,self.dhcp.seed_ip)
752 log_test.info('server offered IP from its pool when requested out of pool IP, as expected')
753
754 def test_dhcpl2relay_nak_packet(self, iface = 'veth0'):
755 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000756 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
757 cip, sip, mac, _ = self.dhcp.only_discover()
758 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
759 (cip, sip, mac) )
760 assert_not_equal(cip, None)
761 new_cip, new_sip = self.dhcp.only_request('20.20.20.31', mac)
762 assert_equal(new_cip, None)
763 log_test.info('server sent NAK packet when requested other IP than that server offered')
764
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000765 def test_dhcpl2relay_with_client_requests_with_specific_lease_time_in_discover_message(self, iface = 'veth0',lease_time=700):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000766 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000767 self.dhcp = DHCPTest(seed_ip = '10.10.10.70', iface = iface)
768 self.dhcp.return_option = 'lease'
769 cip, sip, mac, lval = self.dhcp.only_discover(lease_time=True,lease_value=lease_time)
770 assert_equal(lval, lease_time)
771 log_test.info('dhcp server offered IP address with client requested lease time')
772
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000773 def test_dhcpl2relay_with_client_request_after_reboot(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000774 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000775 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
776 cip, sip, mac, _ = self.dhcp.only_discover()
777 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
778 (cip, sip, mac) )
779 assert_not_equal(cip, None)
780 new_cip, new_sip = self.dhcp.only_request(cip, mac)
781 log_test.info('client rebooting...')
782 os.system('ifconfig '+iface+' down')
783 time.sleep(5)
784 os.system('ifconfig '+iface+' up')
785 new_cip2, new_sip = self.dhcp.only_request(cip, mac, cl_reboot = True)
786 assert_equal(new_cip2, cip)
787 log_test.info('client got same IP after reboot, as expected')
788
789
790 def test_dhcpl2relay_after_server_reboot(self, iface = 'veth0'):
791 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000792 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
793 cip, sip, mac, _ = self.dhcp.only_discover()
794 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
795 (cip, sip, mac) )
796 assert_not_equal(cip, None)
797 new_cip, new_sip = self.dhcp.only_request(cip, mac)
798 log_test.info('server rebooting...')
799 self.tearDownClass()
800 new_cip, new_sip = self.dhcp.only_request(cip, mac)
801 assert_equal(new_cip,None)
802 self.setUpClass()
803 new_cip, new_sip = self.dhcp.only_request(cip, mac)
804 assert_equal(new_cip, cip)
805 log_test.info('client got same IP after server rebooted, as expected')
806
807 def test_dhcpl2relay_specific_lease_time_only_in_discover_but_not_in_request_packet(self, iface = 'veth0',lease_time=700):
808 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000809 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
810 self.dhcp.return_option = 'lease'
811 log_test.info('Sending DHCP discover with lease time of 700')
812 cip, sip, mac, lval = self.dhcp.only_discover(lease_time = True, lease_value=lease_time)
813 assert_equal(lval,lease_time)
814 new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, lease_time = True)
815 assert_equal(new_cip,cip)
816 assert_not_equal(lval, lease_time) #Negative Test Case
817 log_test.info('client requested lease time in discover packer is not seen in server ACK packet as expected')
818
819 def test_dhcpl2relay_specific_lease_time_only_in_request_but_not_in_discover_packet(self, iface = 'veth0',lease_time=800):
820 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000821 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
822 cip, sip, mac, _ = self.dhcp.only_discover()
823 new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, lease_time = True,lease_value=lease_time)
824 assert_equal(new_cip,cip)
825 assert_equal(lval, lease_time)
826 log_test.info('client requested lease time in request packet seen in servre replied ACK packet as expected')
827
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000828 def test_dhcpl2relay_with_client_renew_time(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000829 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000830 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
831 cip, sip, mac, _ = self.dhcp.only_discover()
832 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
833 (cip, sip, mac) )
834 assert_not_equal(cip,None)
835 new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, renew_time = True)
836 log_test.info('waiting for renew time..')
837 time.sleep(lval)
838 latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac, unicast = True)
839 assert_equal(latest_cip, cip)
840 log_test.info('server renewed client IP when client sends request after renew time, as expected')
841
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000842 def test_dhcpl2relay_with_client_rebind_time(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000843 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000844 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
845 cip, sip, mac, _ = self.dhcp.only_discover()
846 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
847 (cip, sip, mac) )
848 assert_not_equal(cip,None)
849 new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, rebind_time = True)
850 log_test.info('waiting for rebind time..')
851 time.sleep(lval)
852 latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac)
853 assert_equal(latest_cip, cip)
854 log_test.info('server renewed client IP when client sends request after rebind time, as expected')
855
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000856 def test_dhcpl2relay_with_client_expected_subnet_mask(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000857 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000858 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
859 expected_subnet = '255.255.255.0'
860 self.dhcp.return_option = 'subnet'
861
862 cip, sip, mac, subnet_mask = self.dhcp.only_discover()
863 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
864 (cip, sip, mac) )
865 assert_equal(subnet_mask,expected_subnet)
866 log_test.info('subnet mask in server offer packet is same as configured subnet mask in dhcp server')
867
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000868 def test_dhcpl2relay_with_client_sending_dhcp_request_with_wrong_subnet_mask(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000869 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000870 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
871
872 cip, sip, mac, _ = self.dhcp.only_discover()
873 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
874 (cip, sip, mac) )
875 assert_not_equal(cip,None)
876 self.dhcp.send_different_option = 'subnet'
877 new_cip, new_sip = self.dhcp.only_request(cip, mac)
878 assert_equal(new_cip, cip)
879 log_test.info("Got DHCP Ack despite of specifying wrong Subnet Mask in DHCP Request.")
880
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000881 def test_dhcpl2relay_with_client_expected_router_address(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000882 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000883 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
884 expected_router_address = '20.20.20.1'
885 self.dhcp.return_option = 'router'
886
887 cip, sip, mac, router_address_value = self.dhcp.only_discover()
888 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
889 (cip, sip, mac) )
890 assert_equal(expected_router_address, router_address_value)
891 log_test.info('router address in server offer packet is same as configured router address in dhcp server')
892
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000893 def test_dhcpl2relay_with_client_sends_dhcp_request_with_wrong_router_address(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000894 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000895 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
896
897 cip, sip, mac, _ = self.dhcp.only_discover()
898 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
899 (cip, sip, mac) )
900 assert_not_equal(cip,None)
901 self.dhcp.send_different_option = 'router'
902 new_cip, new_sip = self.dhcp.only_request(cip, mac)
903 assert_equal(new_cip, cip)
904 log_test.info("Got DHCP Ack despite of specifying wrong Router Address in DHCP Request.")
905
906 def test_dhcpl2relay_with_client_expecting_broadcast_address(self, iface = 'veth0'):
907 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000908 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
909 expected_broadcast_address = '192.168.1.255'
910 self.dhcp.return_option = 'broadcast_address'
911
912 cip, sip, mac, broadcast_address_value = self.dhcp.only_discover()
913 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
914 (cip, sip, mac) )
915 assert_equal(expected_broadcast_address, broadcast_address_value)
916 log_test.info('broadcast address in server offer packet is same as configured broadcast address in dhcp server')
917
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000918 def test_dhcpl2relay_with_client_sends_dhcp_request_with_wrong_broadcast_address(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000919 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000920 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
921
922 cip, sip, mac, _ = self.dhcp.only_discover()
923 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
924 (cip, sip, mac) )
925 assert_not_equal(cip,None)
926 self.dhcp.send_different_option = 'broadcast_address'
927 new_cip, new_sip = self.dhcp.only_request(cip, mac)
928 assert_equal(new_cip, cip)
929 log_test.info("Got DHCP Ack despite of specifying wrong Broadcast Address in DHCP Request.")
930
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000931 def test_dhcpl2relay_with_client_expecting_dns_address(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000932 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000933 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
934 expected_dns_address = '192.168.1.1'
935 self.dhcp.return_option = 'dns'
936
937 cip, sip, mac, dns_address_value = self.dhcp.only_discover()
938 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
939 (cip, sip, mac) )
940 assert_equal(expected_dns_address, dns_address_value)
941 log_test.info('dns address in server offer packet is same as configured dns address in dhcp server')
942
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000943 def test_dhcpl2relay_with_client_sends_request_with_wrong_dns_address(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000944 mac = self.get_mac(iface)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000945 self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
946
947 cip, sip, mac, _ = self.dhcp.only_discover()
948 log_test.info('Got dhcp client IP %s from server %s for mac %s .' %
949 (cip, sip, mac) )
950 assert_not_equal(cip,None)
951 self.dhcp.send_different_option = 'dns'
952 new_cip, new_sip = self.dhcp.only_request(cip, mac)
953 assert_equal(new_cip, cip)
954 log_test.info("Got DHCP Ack despite of specifying wrong DNS Address in DHCP Request.")
955
956
957 def test_dhcpl2relay_transactions_per_second(self, iface = 'veth0'):
958
959 for i in range(1,4):
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000960 self.dhcpl2relay_stats_calc()
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000961 log_test.info("Statistics for run %d",i)
962 log_test.info("----------------------------------------------------------------------------------")
963 log_test.info("No. of transactions No. of successes No. of failures Running Time ")
964 log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff))
965 log_test.info("----------------------------------------------------------------------------------")
966 log_test.info("No. of transactions per second in run %d:%f" %(i, self.transaction_count))
967
968 log_test.info("Final Statistics for total transactions")
969 log_test.info("----------------------------------------------------------------------------------")
970 log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ")
971 log_test.info(" %d %d %d %d" %(self.transactions,
972 self.total_success, self.total_failure, self.running_time))
973 log_test.info("----------------------------------------------------------------------------------")
974 log_test.info("Average no. of transactions per second: %d", round(self.transactions/self.running_time,0))
975
976 def test_dhcpl2relay_consecutive_successes_per_second(self, iface = 'veth0'):
977
978 for i in range(1,4):
Chetan Gaonkera6050ae2017-09-02 19:15:01 +0000979 self.dhcpl2relay_stats_calc(success_rate = True)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +0000980 log_test.info("Statistics for run %d",i)
981 log_test.info("----------------------------------------------------------------------------------")
982 log_test.info("No. of consecutive successful transactions Running Time ")
983 log_test.info(" %d %d " %(self.ip_count, self.diff))
984 log_test.info("----------------------------------------------------------------------------------")
985 log_test.info("No. of successful transactions per second in run %d:%f" %(i, self.transaction_count))
986 log_test.info("----------------------------------------------------------------------------------")
987
988 log_test.info("Final Statistics for total successful transactions")
989 log_test.info("----------------------------------------------------------------------------------")
990 log_test.info("Total transactions Total No. of consecutive successes Running Time ")
991 log_test.info(" %d %d %d " %(self.transactions,
992 self.total_success, self.running_time))
993 log_test.info("----------------------------------------------------------------------------------")
994 log_test.info("Average no. of consecutive successful transactions per second: %d", round(self.total_success/self.running_time,0))
995 log_test.info("----------------------------------------------------------------------------------")
996
997 def test_dhcpl2relay_with_max_clients_per_second(self, iface = 'veth0'):
998
999 for i in range(1,4):
Chetan Gaonkera6050ae2017-09-02 19:15:01 +00001000 self.dhcpl2relay_stats_calc(only_discover = True)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +00001001 log_test.info("----------------------------------------------------------------------------------")
1002 log_test.info("Statistics for run %d of sending only DHCP Discover",i)
1003 log_test.info("----------------------------------------------------------------------------------")
1004 log_test.info("No. of transactions No. of successes No. of failures Running Time ")
1005 log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff))
1006 log_test.info("----------------------------------------------------------------------------------")
1007 log_test.info("No. of clients per second in run %d:%f "
1008 %(i, self.transaction_count))
1009 log_test.info("----------------------------------------------------------------------------------")
1010 log_test.info("Final Statistics for total transactions of sending only DHCP Discover")
1011 log_test.info("----------------------------------------------------------------------------------")
1012 log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ")
1013 log_test.info(" %d %d %d %d" %(self.transactions,
1014 self.total_success, self.total_failure, self.running_time))
1015 log_test.info("----------------------------------------------------------------------------------")
1016 log_test.info("Average no. of clients per second: %d ",
1017 round(self.transactions/self.running_time,0))
1018 log_test.info("----------------------------------------------------------------------------------")
1019
1020 def test_dhcpl2relay_consecutive_successful_clients_per_second(self, iface = 'veth0'):
1021
1022 for i in range(1,4):
Chetan Gaonkera6050ae2017-09-02 19:15:01 +00001023 self.dhcpl2relay_stats_calc(success_rate = True, only_discover = True)
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +00001024 log_test.info("----------------------------------------------------------------------------------")
1025 log_test.info("Statistics for run %d for sending only DHCP Discover",i)
1026 log_test.info("----------------------------------------------------------------------------------")
1027 log_test.info("No. of consecutive successful transactions Running Time ")
1028 log_test.info(" %d %d " %(self.ip_count, self.diff))
1029 log_test.info("----------------------------------------------------------------------------------")
1030 log_test.info("No. of consecutive successful clients per second in run %d:%f" %(i, self.transaction_count))
1031 log_test.info("----------------------------------------------------------------------------------")
1032
1033 log_test.info("Final Statistics for total successful transactions")
1034 log_test.info("----------------------------------------------------------------------------------")
1035 log_test.info("Total transactions Total No. of consecutive successes Running Time ")
1036 log_test.info(" %d %d %d " %(self.transactions,
1037 self.total_success, self.running_time))
1038 log_test.info("----------------------------------------------------------------------------------")
1039 log_test.info("Average no. of consecutive successful clients per second: %d", round(self.total_success/self.running_time,0))
1040 log_test.info("----------------------------------------------------------------------------------")
1041
1042 def test_dhcpl2relay_concurrent_transactions_per_second(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +00001043 for key in (key for key in g_subscriber_port_map if key < 100):
1044 self.host_load(g_subscriber_port_map[key])
1045
1046 def thread_fun(i):
1047 mac = self.get_mac('veth{}'.format(i))
1048 cip, sip = DHCPTest(iface = 'veth{}'.format(i)).discover(mac = mac)
1049 log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac))
1050 self.lock.acquire()
1051
1052 if cip:
1053 self.ip_count += 1
1054
1055 elif cip is None:
1056 self.failure_count += 1
1057
1058 self.lock.notify_all()
1059 self.lock.release()
1060
1061 for i in range (1,4):
1062 self.ip_count = 0
1063 self.failure_count = 0
1064 self.start_time = 0
1065 self.diff = 0
1066 self.transaction_count = 0
1067 self.start_time = time.time()
1068
1069 while self.diff <= 60:
1070 t = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(0, random.randrange(1,40,1), 1)})
1071 t1 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(42, random.randrange(43,80,1), 1)})
1072 t2 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(82, random.randrange(83,120,1), 1)})
1073 t3 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(122, random.randrange(123,160,1), 1)})
1074 t4 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(162, random.randrange(163,180,1), 1)})
1075 t5 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(182, random.randrange(183,196,1), 1)})
1076
1077 t.start()
1078 t1.start()
1079 t2.start()
1080 t3.start()
1081 t4.start()
1082 t5.start()
1083
1084 t.join()
1085 t1.join()
1086 t2.join()
1087 t3.join()
1088 t4.join()
1089 t5.join()
1090
1091 self.diff = round(time.time() - self.start_time, 0)
1092
1093 self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2)
1094
1095 self.transactions += (self.ip_count+self.failure_count)
1096 self.running_time += self.diff
1097 self.total_success += self.ip_count
1098 self.total_failure += self.failure_count
1099
1100
1101 log_test.info("----------------------------------------------------------------------------------")
1102 log_test.info("Statistics for run %d",i)
1103 log_test.info("----------------------------------------------------------------------------------")
1104 log_test.info("No. of transactions No. of successes No. of failures Running Time ")
1105 log_test.info(" %d %d %d %d"
1106 %(self.ip_count+self.failure_count,self.ip_count, self.failure_count, self.diff))
1107 log_test.info("----------------------------------------------------------------------------------")
1108 log_test.info("No. of transactions per second in run %d:%f" %(i, self.transaction_count))
1109 log_test.info("----------------------------------------------------------------------------------")
1110
1111 log_test.info("----------------------------------------------------------------------------------")
1112 log_test.info("Final Statistics for total transactions")
1113 log_test.info("----------------------------------------------------------------------------------")
1114 log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ")
1115 log_test.info(" %d %d %d %d" %(self.transactions,
1116 self.total_success, self.total_failure, self.running_time))
1117
1118 log_test.info("----------------------------------------------------------------------------------")
1119 log_test.info("Average no. of transactions per second: %d", round(self.transactions/self.running_time,0))
1120 log_test.info("----------------------------------------------------------------------------------")
1121
1122 def test_dhcpl2relay_concurrent_consecutive_successes_per_second(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +00001123 failure_dir = {}
1124
1125 for key in (key for key in g_subscriber_port_map if key != 100):
1126 self.host_load(g_subscriber_port_map[key])
1127
1128 def thread_fun(i, j):
1129# log_test.info("Thread Name:%s",current_thread().name)
1130# failure_dir[current_thread().name] = True
1131 while failure_dir.has_key(current_thread().name) is False:
1132 mac = RandMAC()._fix()
1133 cip, sip = DHCPTest(iface = 'veth{}'.format(i)).discover(mac = mac)
1134 i += 2
1135 log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac))
1136 self.lock.acquire()
1137
1138 if cip:
1139 self.ip_count += 1
1140 self.lock.notify_all()
1141 self.lock.release()
1142 elif cip is None:
1143 self.failure_count += 1
1144 failure_dir[current_thread().name] = True
1145 self.lock.notify_all()
1146 self.lock.release()
1147 break
1148# self.lock.notify_all()
1149# self.lock.release()
1150
1151 for i in range (1,4):
1152 failure_dir = {}
1153 self.ip_count = 0
1154 self.failure_count = 0
1155 self.start_time = 0
1156 self.diff = 0
1157 self.transaction_count = 0
1158 self.start_time = time.time()
1159
1160 while len(failure_dir) != 6:
1161 t = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2})
1162 t1 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2})
1163 t2 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2})
1164 t3 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2})
1165 t4 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2})
1166 t5 = threading.Thread(target = thread_fun, kwargs = {'i': 0, 'j': 2})
1167
1168 t.start()
1169 t1.start()
1170 t2.start()
1171 t3.start()
1172 t4.start()
1173 t5.start()
1174
1175 t.join()
1176 t1.join()
1177 t2.join()
1178 t3.join()
1179 t4.join()
1180 t5.join()
1181
1182 self.diff = round(time.time() - self.start_time, 0)
1183 self.transaction_count = round((self.ip_count)/self.diff, 2)
1184
1185 self.transactions += (self.ip_count+self.failure_count)
1186 self.running_time += self.diff
1187 self.total_success += self.ip_count
1188 self.total_failure += self.failure_count
1189
1190
1191 log_test.info("Statistics for run %d",i)
1192 log_test.info("----------------------------------------------------------------------------------")
1193 log_test.info("No. of consecutive successful transactions Running Time ")
1194 log_test.info(" %d %d " %(self.ip_count, self.diff))
1195 log_test.info("----------------------------------------------------------------------------------")
1196 log_test.info("No. of successful transactions per second in run %d:%f" %(i, self.transaction_count))
1197 log_test.info("----------------------------------------------------------------------------------")
1198
1199 log_test.info("Final Statistics for total successful transactions")
1200 log_test.info("----------------------------------------------------------------------------------")
1201 log_test.info("Total transactions Total No. of consecutive successes Running Time ")
1202 log_test.info(" %d %d %d " %(self.transactions,
1203 self.total_success, self.running_time))
1204 log_test.info("----------------------------------------------------------------------------------")
1205 log_test.info("Average no. of consecutive successful transactions per second: %d", round(self.total_success/self.running_time,2))
1206 log_test.info("----------------------------------------------------------------------------------")
1207
Chetan Gaonkera6050ae2017-09-02 19:15:01 +00001208 def test_dhcpl2relay_for_concurrent_clients_per_second(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +00001209 for key in (key for key in g_subscriber_port_map if key < 100):
1210 self.host_load(g_subscriber_port_map[key])
1211
1212 def thread_fun(i):
1213# mac = self.get_mac('veth{}'.format(i))
1214 cip, sip, mac, _ = DHCPTest(iface = 'veth{}'.format(i)).only_discover(mac = RandMAC()._fix())
1215 log_test.info('Got dhcp client IP %s from server %s for mac %s'%(cip, sip, mac))
1216 self.lock.acquire()
1217
1218 if cip:
1219 self.ip_count += 1
1220 elif cip is None:
1221 self.failure_count += 1
1222
1223 self.lock.notify_all()
1224 self.lock.release()
1225
1226 for i in range (1,4):
1227 self.ip_count = 0
1228 self.failure_count = 0
1229 self.start_time = 0
1230 self.diff = 0
1231 self.transaction_count = 0
1232 self.start_time = time.time()
1233
1234 while self.diff <= 60:
1235 t = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(0, random.randrange(1,40,1), 1)})
1236 t1 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(42, random.randrange(43,80,1), 1)})
1237 t2 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(82, random.randrange(83,120,1), 1)})
1238 t3 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(122, random.randrange(123,160,1), 1)})
1239 t4 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(162, random.randrange(163,180,1), 1)})
1240 t5 = threading.Thread(target = thread_fun, kwargs = {'i': random.randrange(182, random.randrange(183,196,1), 1)})
1241
1242 t.start()
1243 t1.start()
1244 t2.start()
1245 t3.start()
1246 t4.start()
1247 t5.start()
1248
1249 t.join()
1250 t1.join()
1251 t2.join()
1252 t3.join()
1253 t4.join()
1254 t5.join()
1255
1256 self.diff = round(time.time() - self.start_time, 0)
1257 self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2)
1258 self.transactions += (self.ip_count+self.failure_count)
1259 self.running_time += self.diff
1260 self.total_success += self.ip_count
1261 self.total_failure += self.failure_count
1262
1263 log_test.info("----------------------------------------------------------------------------------")
1264 log_test.info("Statistics for run %d of sending only DHCP Discover",i)
1265 log_test.info("----------------------------------------------------------------------------------")
1266 log_test.info("No. of transactions No. of successes No. of failures Running Time ")
1267 log_test.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff))
1268 log_test.info("----------------------------------------------------------------------------------")
1269 log_test.info("No. of clients per second in run %d:%f "
1270 %(i, self.transaction_count))
1271 log_test.info("----------------------------------------------------------------------------------")
1272
1273 log_test.info("Final Statistics for total transactions of sending only DHCP Discover")
1274 log_test.info("----------------------------------------------------------------------------------")
1275 log_test.info("Total transactions Total No. of successes Total No. of failures Running Time ")
1276 log_test.info(" %d %d %d %d" %(self.transactions,
1277 self.total_success, self.total_failure, self.running_time))
1278 log_test.info("----------------------------------------------------------------------------------")
1279 log_test.info("Average no. of clients per second: %d ",
1280 round(self.transactions/self.running_time,0))
1281 log_test.info("----------------------------------------------------------------------------------")
1282
Chetan Gaonkera6050ae2017-09-02 19:15:01 +00001283 def test_dhcpl2relay_with_client_conflict(self, iface = 'veth0'):
Chetan Gaonkerc1df33a2017-08-18 01:29:54 +00001284 mac = self.get_mac(iface)
1285 self.host_load(iface)
1286 self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
1287 cip, sip, mac, _ = self.dhcp.only_discover()
1288 log_test.info('Got dhcp client IP %s from server %s for mac %s.' %
1289 (cip, sip, mac) )
1290 self.dhcp1 = DHCPTest(seed_ip = cip, iface = iface)
1291 new_cip, new_sip, new_mac, _ = self.dhcp1.only_discover(desired = True)
1292 new_cip, new_sip = self.dhcp1.only_request(new_cip, new_mac)
1293 log_test.info('Got dhcp client IP %s from server %s for mac %s.' %
1294 (new_cip, new_sip, new_mac) )
1295 log_test.info("IP %s alredy consumed by mac %s." % (new_cip, new_mac))
1296 log_test.info("Now sending DHCP Request for old DHCP discover.")
1297 new_cip, new_sip = self.dhcp.only_request(cip, mac)
1298 if new_cip is None:
1299 log_test.info('Got dhcp client IP %s from server %s for mac %s.Which is expected behavior.'
1300 %(new_cip, new_sip, new_mac) )
1301 elif new_cip:
1302 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.'
1303 %(new_cip, new_sip, new_mac, new_cip) )
1304 assert_equal(new_cip, None)