ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 1 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 2 | # Copyright 2016-present Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 7 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 9 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 16 | import unittest |
| 17 | from nose.tools import * |
| 18 | from nose.twistedtools import reactor, deferred |
| 19 | from twisted.internet import defer |
| 20 | from scapy.all import * |
| 21 | import time |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 22 | import copy |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 23 | from DHCP import DHCPTest |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 24 | from OltConfig import * |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 25 | from OnosCtrl import OnosCtrl |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 26 | from portmaps import g_subscriber_port_map |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 27 | from CordLogger import CordLogger |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 28 | log.setLevel('INFO') |
| 29 | |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 30 | class dhcp_exchange(CordLogger): |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 31 | |
| 32 | dhcp_server_config = { |
| 33 | "ip": "10.1.11.50", |
| 34 | "mac": "ca:fe:ca:fe:ca:fe", |
| 35 | "subnet": "255.255.252.0", |
| 36 | "broadcast": "10.1.11.255", |
| 37 | "router": "10.1.8.1", |
| 38 | "domain": "8.8.8.8", |
| 39 | "ttl": "63", |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 40 | "delay": "2", |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 41 | "startip": "10.1.11.51", |
| 42 | "endip": "10.1.11.100" |
| 43 | } |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 44 | |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 45 | app = 'org.onosproject.dhcp' |
| 46 | |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 47 | ip_count = 0 |
| 48 | failure_count = 0 |
| 49 | start_time = 0 |
| 50 | diff = 0 |
| 51 | |
| 52 | transaction_count = 0 |
| 53 | transactions = 0 |
| 54 | running_time = 0 |
| 55 | total_success = 0 |
| 56 | total_failure = 0 |
| 57 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 58 | @classmethod |
| 59 | def setUpClass(cls): |
| 60 | cls.olt = OltConfig() |
A R Karthick | b03cecd | 2016-07-27 10:27:55 -0700 | [diff] [blame] | 61 | cls.port_map, _ = cls.olt.olt_port_map() |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 62 | if not cls.port_map: |
| 63 | cls.port_map = g_subscriber_port_map |
| 64 | cls.iface = cls.port_map[1] |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 65 | |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 66 | def setUp(self): |
| 67 | ''' Activate the dhcp app''' |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 68 | super(dhcp_exchange, self).setUp() |
Chetan Gaonker | c0566b5 | 2016-03-09 11:31:51 -0800 | [diff] [blame] | 69 | self.maxDiff = None ##for assert_equal compare outputs on failure |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 70 | self.onos_ctrl = OnosCtrl(self.app) |
| 71 | status, _ = self.onos_ctrl.activate() |
| 72 | assert_equal(status, True) |
| 73 | time.sleep(3) |
| 74 | |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 75 | def tearDown(self): |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 76 | '''Deactivate the dhcp app''' |
| 77 | self.onos_ctrl.deactivate() |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 78 | super(dhcp_exchange, self).tearDown() |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 79 | |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 80 | def onos_load_config(self, config): |
Chetan Gaonker | a2b87df | 2016-03-31 15:41:31 -0700 | [diff] [blame] | 81 | status, code = OnosCtrl.config(config) |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 82 | if status is False: |
| 83 | log.info('JSON request returned status %d' %code) |
| 84 | assert_equal(status, True) |
Chetan Gaonker | c0566b5 | 2016-03-09 11:31:51 -0800 | [diff] [blame] | 85 | time.sleep(3) |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 86 | |
| 87 | def onos_dhcp_table_load(self, config = None): |
| 88 | dhcp_dict = {'apps' : { 'org.onosproject.dhcp' : { 'dhcp' : copy.copy(self.dhcp_server_config) } } } |
| 89 | dhcp_config = dhcp_dict['apps']['org.onosproject.dhcp']['dhcp'] |
| 90 | if config: |
| 91 | for k in config.keys(): |
| 92 | if dhcp_config.has_key(k): |
| 93 | dhcp_config[k] = config[k] |
| 94 | self.onos_load_config(dhcp_dict) |
| 95 | |
Chetan Gaonker | 6c68e91 | 2016-04-15 17:22:14 -0700 | [diff] [blame] | 96 | def send_recv(self, mac = None, update_seed = False, validate = True): |
| 97 | cip, sip = self.dhcp.discover(mac = mac, update_seed = update_seed) |
| 98 | if validate: |
| 99 | assert_not_equal(cip, None) |
| 100 | assert_not_equal(sip, None) |
| 101 | log.info('Got dhcp client IP %s from server %s for mac %s' % |
| 102 | (cip, sip, self.dhcp.get_mac(cip)[0])) |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 103 | return cip,sip |
| 104 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 105 | def stats(self,success_rate = False, only_discover = False): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 106 | |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 107 | self.ip_count = 0 |
| 108 | self.failure_count = 0 |
| 109 | self.start_time = 0 |
| 110 | self.diff = 0 |
| 111 | self.transaction_count = 0 |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 112 | config = {'startip':'182.17.0.3', 'endip':'182.17.0.180', |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 113 | 'ip':'182.17.0.2', 'mac': "ca:fe:c3:fe:ca:fe", |
| 114 | 'subnet': '255.255.255.0', 'broadcast':'182.17.0.255', 'router':'182.17.0.1'} |
| 115 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 116 | self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = self.iface) |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 117 | self.start_time = time.time() |
| 118 | |
| 119 | while self.diff <= 60: |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 120 | if only_discover: |
| 121 | cip, sip, mac, _ = self.dhcp.only_discover(multiple = True) |
| 122 | log.info('Got dhcp client IP %s from server %s for mac %s' % |
| 123 | (cip, sip, mac)) |
| 124 | else: |
| 125 | cip, sip = self.send_recv(update_seed = True, validate = False) |
| 126 | |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 127 | if cip: |
| 128 | self.ip_count +=1 |
| 129 | elif cip == None: |
| 130 | self.failure_count += 1 |
| 131 | log.info('Failed to get ip') |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 132 | if success_rate and self.ip_count > 0: |
| 133 | break |
| 134 | self.diff = round(time.time() - self.start_time, 0) |
| 135 | |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 136 | |
| 137 | self.transaction_count = round((self.ip_count+self.failure_count)/self.diff, 2) |
| 138 | |
| 139 | self.transactions += (self.ip_count+self.failure_count) |
| 140 | self.running_time += self.diff |
| 141 | self.total_success += self.ip_count |
| 142 | self.total_failure += self.failure_count |
| 143 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 144 | def test_dhcp_1request(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 145 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
Chetan Gaonker | 4a25e2b | 2016-03-04 14:45:15 -0800 | [diff] [blame] | 146 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 147 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 148 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 149 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = self.iface) |
Anil Kumar Sanka | 5099890 | 2016-12-13 12:10:25 +0530 | [diff] [blame] | 150 | self.send_recv() |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 151 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 152 | def test_dhcp_1request_with_invalid_source_mac_broadcast(self): |
| 153 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
| 154 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 155 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 156 | self.onos_dhcp_table_load(config) |
| 157 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = self.iface) |
| 158 | cip, sip, mac, _ = self.dhcp.only_discover(mac='ff:ff:ff:ff:ff:ff') |
| 159 | assert_equal(cip,None) |
| 160 | log.info('ONOS dhcp server rejected client discover with invalid source mac as expected') |
| 161 | |
| 162 | def test_dhcp_1request_with_invalid_source_mac_multicast(self): |
| 163 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
| 164 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 165 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 166 | self.onos_dhcp_table_load(config) |
| 167 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = self.iface) |
| 168 | cip, sip, mac, _ = self.dhcp.only_discover(mac='01:80:c2:91:02:e4') |
| 169 | assert_equal(cip,None) |
| 170 | log.info('ONOS dhcp server rejected client discover with invalid source mac as expected') |
| 171 | |
| 172 | def test_dhcp_1request_with_invalid_source_mac_zero(self): |
| 173 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
| 174 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 175 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 176 | self.onos_dhcp_table_load(config) |
| 177 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = self.iface) |
| 178 | cip, sip, mac, _ = self.dhcp.only_discover(mac='00:00:00:00:00:00') |
| 179 | assert_equal(cip,None) |
| 180 | log.info('ONOS dhcp server rejected client discover with invalid source mac as expected') |
| 181 | |
| 182 | def test_dhcp_Nrequest(self,requests=10): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 183 | config = {'startip':'192.168.1.20', 'endip':'192.168.1.69', |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 184 | 'ip':'192.168.1.2', 'mac': "ca:fe:ca:fe:cc:fe", |
| 185 | 'subnet': '255.255.255.0', 'broadcast':'192.168.1.255', 'router': '192.168.1.1'} |
| 186 | self.onos_dhcp_table_load(config) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 187 | self.dhcp = DHCPTest(seed_ip = '192.168.1.1', iface = self.iface) |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 188 | ip_map = {} |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 189 | for i in range(requests): |
Chetan Gaonker | b2bd824 | 2016-03-03 15:39:24 -0800 | [diff] [blame] | 190 | cip, sip = self.send_recv(update_seed = True) |
| 191 | if ip_map.has_key(cip): |
| 192 | log.info('IP %s given out multiple times' %cip) |
| 193 | assert_equal(False, ip_map.has_key(cip)) |
| 194 | ip_map[cip] = sip |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 195 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 196 | def test_dhcp_1release(self): |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 197 | config = {'startip':'10.10.100.20', 'endip':'10.10.100.230', |
Chetan Gaonker | c0566b5 | 2016-03-09 11:31:51 -0800 | [diff] [blame] | 198 | 'ip':'10.10.100.2', 'mac': "ca:fe:ca:fe:8a:fe", |
| 199 | 'subnet': '255.255.255.0', 'broadcast':'10.10.100.255', 'router':'10.10.100.1'} |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 200 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 201 | self.dhcp = DHCPTest(seed_ip = '10.10.100.10', iface = self.iface) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 202 | cip, sip = self.send_recv() |
| 203 | log.info('Releasing ip %s to server %s' %(cip, sip)) |
| 204 | assert_equal(self.dhcp.release(cip), True) |
| 205 | log.info('Triggering DHCP discover again after release') |
| 206 | cip2, sip2 = self.send_recv(update_seed = True) |
| 207 | log.info('Verifying released IP was given back on rediscover') |
| 208 | assert_equal(cip, cip2) |
| 209 | log.info('Test done. Releasing ip %s to server %s' %(cip2, sip2)) |
| 210 | assert_equal(self.dhcp.release(cip2), True) |
| 211 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 212 | def test_dhcp_Nrelease(self): |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 213 | config = {'startip':'192.170.1.20', 'endip':'192.170.1.230', |
Chetan Gaonker | c0566b5 | 2016-03-09 11:31:51 -0800 | [diff] [blame] | 214 | 'ip':'192.170.1.2', 'mac': "ca:fe:ca:fe:9a:fe", |
| 215 | 'subnet': '255.255.255.0', 'broadcast':'192.170.1.255', 'router': '192.170.1.1'} |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 216 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 217 | self.dhcp = DHCPTest(seed_ip = '192.170.1.10', iface = self.iface) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 218 | ip_map = {} |
| 219 | for i in range(10): |
| 220 | cip, sip = self.send_recv(update_seed = True) |
| 221 | if ip_map.has_key(cip): |
| 222 | log.info('IP %s given out multiple times' %cip) |
| 223 | assert_equal(False, ip_map.has_key(cip)) |
| 224 | ip_map[cip] = sip |
| 225 | |
| 226 | for ip in ip_map.keys(): |
| 227 | log.info('Releasing IP %s' %ip) |
| 228 | assert_equal(self.dhcp.release(ip), True) |
| 229 | |
| 230 | ip_map2 = {} |
| 231 | log.info('Triggering DHCP discover again after release') |
| 232 | for i in range(len(ip_map.keys())): |
| 233 | cip, sip = self.send_recv(update_seed = True) |
| 234 | ip_map2[cip] = sip |
| 235 | |
| 236 | log.info('Verifying released IPs were given back on rediscover') |
Chetan Gaonker | c0566b5 | 2016-03-09 11:31:51 -0800 | [diff] [blame] | 237 | if ip_map != ip_map2: |
| 238 | log.info('Map before release %s' %ip_map) |
| 239 | log.info('Map after release %s' %ip_map2) |
Chetan Gaonker | 1f7c3f8 | 2016-03-08 12:17:37 -0800 | [diff] [blame] | 240 | assert_equal(ip_map, ip_map2) |
Chetan Gaonker | 6c68e91 | 2016-04-15 17:22:14 -0700 | [diff] [blame] | 241 | |
| 242 | |
Anil Kumar Sanka | 5099890 | 2016-12-13 12:10:25 +0530 | [diff] [blame] | 243 | def test_dhcp_starvation_passitive(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 244 | config = {'startip':'193.170.1.20', 'endip':'193.170.1.69', |
Chetan Gaonker | 6c68e91 | 2016-04-15 17:22:14 -0700 | [diff] [blame] | 245 | 'ip':'193.170.1.2', 'mac': "ca:fe:c2:fe:cc:fe", |
| 246 | 'subnet': '255.255.255.0', 'broadcast':'192.168.1.255', 'router': '192.168.1.1'} |
| 247 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 248 | self.dhcp = DHCPTest(seed_ip = '192.169.1.1', iface = self.iface) |
Chetan Gaonker | 6c68e91 | 2016-04-15 17:22:14 -0700 | [diff] [blame] | 249 | ip_map = {} |
| 250 | for i in range(10): |
| 251 | cip, sip = self.send_recv(update_seed = True) |
| 252 | if ip_map.has_key(cip): |
| 253 | log.info('IP %s given out multiple times' %cip) |
| 254 | assert_equal(False, ip_map.has_key(cip)) |
| 255 | ip_map[cip] = sip |
| 256 | |
| 257 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 258 | def test_dhcp_starvation_negative(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 259 | config = {'startip':'182.17.0.20', 'endip':'182.17.0.69', |
Chetan Gaonker | 6c68e91 | 2016-04-15 17:22:14 -0700 | [diff] [blame] | 260 | 'ip':'182.17.0.2', 'mac': "ca:fe:c3:fe:ca:fe", |
| 261 | 'subnet': '255.255.255.0', 'broadcast':'182.17.0.255', 'router':'182.17.0.1'} |
| 262 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 263 | self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = self.iface) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 264 | log.info('Verifying passitive case') |
Chetan Gaonker | 6c68e91 | 2016-04-15 17:22:14 -0700 | [diff] [blame] | 265 | for x in xrange(50): |
| 266 | mac = RandMAC()._fix() |
| 267 | self.send_recv(mac = mac) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 268 | log.info('Verifying negative case') |
Chetan Gaonker | 6c68e91 | 2016-04-15 17:22:14 -0700 | [diff] [blame] | 269 | cip, sip = self.send_recv(update_seed = True, validate = False) |
| 270 | assert_equal(cip, None) |
| 271 | assert_equal(sip, None) |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 272 | |
| 273 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 274 | def test_dhcp_same_client_multiple_discover(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 275 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 276 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 277 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 278 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 279 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 280 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 281 | log.info('Got dhcp client IP %s from server %s for mac %s . Not going to send DHCPREQUEST.' % |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 282 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 283 | assert_not_equal(cip, None) |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 284 | log.info('Triggering DHCP discover again.') |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 285 | new_cip, new_sip, new_mac, _ = self.dhcp.only_discover() |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 286 | assert_equal(new_cip, cip) |
| 287 | log.info('client got same IP as expected when sent 2nd discovery') |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 288 | |
| 289 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 290 | def test_dhcp_same_client_multiple_request(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 291 | config = {'startip':'10.10.10.20', 'endip':'10.10.10.69', |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 292 | 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 293 | 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'} |
| 294 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 295 | self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = self.iface) |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 296 | log.info('Sending DHCP discover and DHCP request.') |
| 297 | cip, sip = self.send_recv() |
| 298 | mac = self.dhcp.get_mac(cip)[0] |
| 299 | log.info("Sending DHCP request again.") |
| 300 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 301 | assert_equal(new_cip,cip) |
| 302 | log.info('server offered same IP to clain for multiple requests, as expected') |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 303 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 304 | def test_dhcp_client_desired_address(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 305 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 306 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 307 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 308 | self.onos_dhcp_table_load(config) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 309 | self.dhcp = DHCPTest(seed_ip = '20.20.20.50', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 310 | cip, sip, mac, _ = self.dhcp.only_discover(desired = True) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 311 | assert_not_equal(cip, None) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 312 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 313 | (cip, sip, mac)) |
| 314 | assert_equal(cip,self.dhcp.seed_ip) |
| 315 | log.info('ONOS dhcp server offered client requested IP %s as expected'%self.dhcp.seed_ip) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 316 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 317 | #test failing, server not returns NAK when requested out of pool IP |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 318 | def test_dhcp_client_desired_address_out_of_pool(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 319 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 320 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 321 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 322 | self.onos_dhcp_table_load(config) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 323 | self.dhcp = DHCPTest(seed_ip = '20.20.20.75', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 324 | cip, sip, mac, _ = self.dhcp.only_discover(desired = True) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 325 | assert_not_equal(cip, None) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 326 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | f72ca40 | 2016-05-02 16:29:32 -0700 | [diff] [blame] | 327 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 328 | assert_not_equal(cip,self.dhcp.seed_ip) |
| 329 | log.info('server offered IP from its pool of IPs when requested out of pool IP, as expected') |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 330 | |
| 331 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 332 | def test_dhcp_server_nak_packet(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 333 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 334 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 335 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 336 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 337 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 338 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 339 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 340 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 341 | assert_not_equal(cip, None) |
| 342 | new_cip, new_sip = self.dhcp.only_request('20.20.20.31', mac) |
| 343 | assert_equal(new_cip, None) #Negative Test Case |
| 344 | log.info('dhcp servers sent NAK as expected when requested different IP from same client') |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 345 | |
| 346 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 347 | #test_dhcp_lease_packet |
| 348 | def test_dhcp_client_requests_specific_lease_time_in_discover(self,lease_time = 700): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 349 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 350 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 351 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 352 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 353 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 354 | self.dhcp.return_option = 'lease' |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 355 | log.info('Sending DHCP discover with lease time of 700') |
Anil Kumar Sanka | 5099890 | 2016-12-13 12:10:25 +0530 | [diff] [blame] | 356 | cip, sip, mac, lval = self.dhcp.only_discover(lease_time = True, lease_value = lease_time) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 357 | assert_equal(lval, 700) |
| 358 | log.info('dhcp server offered IP address with client requested lease time') |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 359 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 360 | def test_dhcp_client_request_after_reboot(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 361 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 362 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 363 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 364 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 365 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 366 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 367 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 368 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 369 | assert_not_equal(cip,None) |
| 370 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 371 | log.info('verifying client IP after reboot') |
| 372 | os.system('ifconfig '+self.iface+' down') |
| 373 | time.sleep(5) |
| 374 | os.system('ifconfig '+self.iface+' up') |
| 375 | new_cip, new_sip = self.dhcp.only_request(cip, mac, cl_reboot = True) |
| 376 | assert_equal(new_cip,cip) |
| 377 | log.info('client got same ip after reboot, as expected') |
Anil Kumar Sanka | 5099890 | 2016-12-13 12:10:25 +0530 | [diff] [blame] | 378 | |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 379 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 380 | def test_dhcp_server_after_reboot(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 381 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 382 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 383 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 384 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 385 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 386 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 387 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | f148386 | 2016-05-06 14:14:31 -0700 | [diff] [blame] | 388 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 389 | assert_not_equal(cip, None) |
| 390 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 391 | self.onos_ctrl.deactivate() |
| 392 | new_cip1, new_sip = self.dhcp.only_request(cip, mac) |
| 393 | assert_equal(new_cip1,None) |
| 394 | status, _ = self.onos_ctrl.activate() |
| 395 | assert_equal(status, True) |
| 396 | time.sleep(3) |
| 397 | new_cip2, new_sip = self.dhcp.only_request(cip, mac) |
| 398 | assert_equal(new_cip2,cip) |
| 399 | log.info('client got same ip after server reboot, as expected') |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 400 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 401 | def test_dhcp_specific_lease_time_only_in_discover_but_not_in_request_packet(self,lease_time=700): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 402 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 403 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 404 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 405 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 406 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 407 | log.info('Sending DHCP discover with lease time of 700') |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 408 | cip, sip, mac, _ = self.dhcp.only_discover(lease_time = True,lease_value=lease_time) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 409 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 410 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 411 | assert_not_equal(cip, None) |
| 412 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, lease_time = True) |
| 413 | assert_equal(new_cip,cip) |
| 414 | assert_not_equal(lval, lease_time) #Negative Test Case |
| 415 | log.info('client requested lease time only in discover but not in request, not seen in server ACK packet as expected') |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 416 | |
| 417 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 418 | def test_dhcp_specific_lease_time_only_in_request_but_not_in_discover_packet(self,lease_time=800): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 419 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 420 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 421 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 422 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 423 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 424 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 425 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 426 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 427 | assert_not_equal(cip, None) |
| 428 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, lease_time = True, lease_value=lease_time) |
| 429 | assert_equal(lval, lease_time) |
| 430 | log.info('client requested lease time in request packet, seen in server ACK packet as expected') |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 431 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 432 | def test_dhcp_client_renew_time(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 433 | |
| 434 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 435 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 436 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 437 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 438 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 439 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 440 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 441 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 442 | assert_not_equal(cip, None) |
| 443 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, renew_time = True) |
Anil Kumar Sanka | 5099890 | 2016-12-13 12:10:25 +0530 | [diff] [blame] | 444 | log.info('waiting renew time %d seconds to send next request packet'%lval) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 445 | time.sleep(lval) |
| 446 | latest_cip, latest_sip, lval = self.dhcp.only_request(cip, mac, renew_time = True) |
| 447 | assert_equal(latest_cip,cip) |
| 448 | log.info('client got same IP after renew time, as expected') |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 449 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 450 | def test_dhcp_client_rebind_time(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 451 | |
| 452 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 453 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 454 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 455 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 456 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 457 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 458 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | c11d322 | 2016-05-11 17:39:36 -0700 | [diff] [blame] | 459 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 460 | assert_not_equal(cip, None) |
| 461 | new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, rebind_time = True) |
| 462 | log.info('waiting rebind time %d seconds to send next request packet'%lval) |
| 463 | time.sleep(lval) |
| 464 | latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac) |
| 465 | assert_equal(latest_cip,cip) |
| 466 | log.info('client got same IP after rebind time, as expected') |
Chetan Gaonker | 717b294 | 2016-05-13 17:42:59 -0700 | [diff] [blame] | 467 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 468 | def test_dhcp_client_expected_subnet_mask(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 469 | |
| 470 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | 717b294 | 2016-05-13 17:42:59 -0700 | [diff] [blame] | 471 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 472 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 473 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 474 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
Chetan Gaonker | 717b294 | 2016-05-13 17:42:59 -0700 | [diff] [blame] | 475 | expected_subnet = '255.255.255.0' |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 476 | self.dhcp.return_option = 'subnet' |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 477 | cip, sip, mac, subnet_mask = self.dhcp.only_discover() |
| 478 | assert_equal(subnet_mask, expected_subnet) |
| 479 | assert_not_equal(cip, None) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 480 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | 717b294 | 2016-05-13 17:42:59 -0700 | [diff] [blame] | 481 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 482 | log.info('seen expected subnet mask %s in dhcp offer packet'%subnet_mask) |
Chetan Gaonker | 717b294 | 2016-05-13 17:42:59 -0700 | [diff] [blame] | 483 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 484 | def test_dhcp_client_sends_dhcp_request_with_wrong_subnet_mask(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 485 | |
| 486 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 487 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 488 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 489 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 490 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 491 | |
| 492 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 493 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 494 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 495 | assert_not_equal(cip, None) |
| 496 | self.dhcp.send_different_option = 'subnet' |
| 497 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 498 | assert_equal(new_cip, cip) |
| 499 | log.info("Got DHCP Ack despite of specifying wrong Subnet Mask in DHCP Request.") |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 500 | |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 501 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 502 | def test_dhcp_client_expected_router_address(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 503 | |
| 504 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 505 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 506 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 507 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 508 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 509 | expected_router_address = '20.20.20.1' |
| 510 | self.dhcp.return_option = 'router' |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 511 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 512 | cip, sip, mac, router_address_ip = self.dhcp.only_discover() |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 513 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 514 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 515 | assert_not_equal(cip, None) |
| 516 | assert_equal(expected_router_address, router_address_ip) |
| 517 | log.info('seen expected rouer address %s ip in dhcp offer packet'%router_address_ip) |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 518 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 519 | def test_dhcp_client_sends_dhcp_request_with_wrong_router_address(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 520 | |
| 521 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 522 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 523 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 524 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 525 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 526 | |
| 527 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 528 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 529 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 530 | assert_not_equal(cip, None) |
| 531 | self.dhcp.send_different_option = 'router' |
| 532 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 533 | assert_equal(new_cip, cip) |
| 534 | log.info("Got DHCP Ack despite of specifying wrong Router Address in DHCP Request.") |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 535 | |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 536 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 537 | def test_dhcp_client_expected_broadcast_address(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 538 | |
| 539 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 540 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 541 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 542 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 543 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 544 | expected_broadcast_address = '20.20.20.255' |
| 545 | self.dhcp.return_option = 'broadcast_address' |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 546 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 547 | cip, sip, mac, broadcast_address = self.dhcp.only_discover() |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 548 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 549 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 550 | assert_not_equal(cip, None) |
| 551 | assert_equal(expected_broadcast_address, broadcast_address) |
| 552 | log.info('seen expected broadcast address %s in dhcp offer packet'%broadcast_address) |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 553 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 554 | def test_dhcp_client_sends_dhcp_request_with_wrong_broadcast_address(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 555 | |
| 556 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 557 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 558 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'} |
| 559 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 560 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 561 | |
| 562 | cip, sip, mac, _ = self.dhcp.only_discover() |
| 563 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 564 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 565 | assert_not_equal(cip, None) |
| 566 | self.dhcp.send_different_option = 'broadcast_address' |
| 567 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 568 | assert_equal(new_cip, cip) |
| 569 | log.info("Got DHCP Ack despite of specifying wrong Broadcast Address in DHCP Request.") |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 570 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 571 | def test_dhcp_client_expected_dns_address(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 572 | |
| 573 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 574 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 575 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1', 'domain':'8.8.8.8'} |
| 576 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 577 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 578 | expected_dns_address = '8.8.8.8' |
| 579 | self.dhcp.return_option = 'dns' |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 580 | |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 581 | cip, sip, mac, dns_address = self.dhcp.only_discover() |
| 582 | assert_not_equal(cip, None) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 583 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 584 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 585 | assert_equal(expected_dns_address, dns_address) |
| 586 | log.info('seen expected DNS ip address %s in dhcp offer packet'%dns_address) |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 587 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 588 | def test_dhcp_client_sends_request_with_wrong_dns_address(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 589 | |
| 590 | config = {'startip':'20.20.20.30', 'endip':'20.20.20.69', |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 591 | 'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe", |
| 592 | 'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1', 'domain':'8.8.8.8'} |
| 593 | self.onos_dhcp_table_load(config) |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 594 | self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = self.iface) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 595 | |
| 596 | cip, sip, mac, _ = self.dhcp.only_discover() |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 597 | assert_not_equal(cip, None) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 598 | log.info('Got dhcp client IP %s from server %s for mac %s .' % |
Chetan Gaonker | 1dabecc | 2016-05-16 14:56:01 -0700 | [diff] [blame] | 599 | (cip, sip, mac) ) |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 600 | self.dhcp.send_different_option = 'dns' |
| 601 | new_cip, new_sip = self.dhcp.only_request(cip, mac) |
| 602 | assert_equal(new_cip, cip) |
| 603 | log.info("Got DHCP Ack despite of specifying wrong DNS Address in DHCP Request.") |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 604 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 605 | def test_dhcp_server_transactions_per_second(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 606 | |
| 607 | for i in range(1,4): |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 608 | self.stats() |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 609 | log.info("Stats for run %d",i) |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 610 | log.info("----------------------------------------------------------------------------------") |
| 611 | log.info("No. of transactions No. of successes No. of failures Running Time ") |
| 612 | log.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff)) |
| 613 | log.info("----------------------------------------------------------------------------------") |
| 614 | log.info("No. of transactions per second in run %d:%f" %(i, self.transaction_count)) |
| 615 | |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 616 | log.info("Final Statistics for total transactions") |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 617 | log.info("----------------------------------------------------------------------------------") |
| 618 | log.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 619 | log.info(" %d %d %d %d" %(self.transactions, |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 620 | self.total_success, self.total_failure, self.running_time)) |
| 621 | log.info("----------------------------------------------------------------------------------") |
| 622 | log.info("Average no. of transactions per second: %d", round(self.transactions/self.running_time,0)) |
| 623 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 624 | def test_dhcp_server_consecutive_successes_per_second(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 625 | |
| 626 | for i in range(1,4): |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 627 | self.stats(success_rate = True) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 628 | log.info("Stats for run %d",i) |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 629 | log.info("----------------------------------------------------------------------------------") |
| 630 | log.info("No. of consecutive successful transactions Running Time ") |
| 631 | log.info(" %d %d " %(self.ip_count, self.diff)) |
| 632 | log.info("----------------------------------------------------------------------------------") |
| 633 | log.info("No. of successful transactions per second in run %d:%f" %(i, self.transaction_count)) |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 634 | log.info("----------------------------------------------------------------------------------") |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 635 | |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 636 | log.info("Final Statistics for total successful transactions") |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 637 | log.info("----------------------------------------------------------------------------------") |
| 638 | log.info("Total transactions Total No. of consecutive successes Running Time ") |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 639 | log.info(" %d %d %d " %(self.transactions, |
Chetan Gaonker | 4a82bae | 2016-05-19 17:35:30 -0700 | [diff] [blame] | 640 | self.total_success, self.running_time)) |
| 641 | log.info("----------------------------------------------------------------------------------") |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 642 | log.info("Average no. of consecutive successful transactions per second: %d", round(self.total_success/self.running_time,0)) |
| 643 | log.info("----------------------------------------------------------------------------------") |
Chetan Gaonker | 717b294 | 2016-05-13 17:42:59 -0700 | [diff] [blame] | 644 | |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 645 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 646 | def test_dhcp_server_client_transactions_per_second(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 647 | |
| 648 | for i in range(1,4): |
| 649 | self.stats(only_discover = True) |
| 650 | log.info("----------------------------------------------------------------------------------") |
| 651 | log.info("Stats for run %d of sending only DHCP Discover",i) |
| 652 | log.info("----------------------------------------------------------------------------------") |
| 653 | log.info("No. of transactions No. of successes No. of failures Running Time ") |
| 654 | log.info(" %d %d %d %d" %(self.ip_count+self.failure_count, self.ip_count, self.failure_count, self.diff)) |
| 655 | log.info("----------------------------------------------------------------------------------") |
| 656 | log.info("No. of clients per second in run %d:%f " |
| 657 | %(i, self.transaction_count)) |
| 658 | log.info("----------------------------------------------------------------------------------") |
| 659 | log.info("Final Statistics for total transactions of sending only DHCP Discover") |
| 660 | log.info("----------------------------------------------------------------------------------") |
| 661 | log.info("Total transactions Total No. of successes Total No. of failures Running Time ") |
| 662 | log.info(" %d %d %d %d" %(self.transactions, |
| 663 | self.total_success, self.total_failure, self.running_time)) |
| 664 | log.info("----------------------------------------------------------------------------------") |
| 665 | log.info("Average no. of clients per second: %d ", |
| 666 | round(self.transactions/self.running_time,0)) |
| 667 | log.info("----------------------------------------------------------------------------------") |
| 668 | |
A R Karthick | 10fe00e | 2016-07-12 16:13:16 -0700 | [diff] [blame] | 669 | def test_dhcp_server_consecutive_successful_clients_per_second(self): |
ChetanGaonker | 42d7581 | 2016-06-06 16:32:52 -0700 | [diff] [blame] | 670 | |
| 671 | for i in range(1,4): |
| 672 | self.stats(success_rate = True, only_discover = True) |
| 673 | log.info("----------------------------------------------------------------------------------") |
| 674 | log.info("Stats for run %d for sending only DHCP Discover",i) |
| 675 | log.info("----------------------------------------------------------------------------------") |
| 676 | log.info("No. of consecutive successful transactions Running Time ") |
| 677 | log.info(" %d %d " %(self.ip_count, self.diff)) |
| 678 | log.info("----------------------------------------------------------------------------------") |
| 679 | log.info("No. of consecutive successful clients per second in run %d:%f" %(i, self.transaction_count)) |
| 680 | log.info("----------------------------------------------------------------------------------") |
| 681 | |
| 682 | log.info("Final Statistics for total successful transactions") |
| 683 | log.info("----------------------------------------------------------------------------------") |
| 684 | log.info("Total transactions Total No. of consecutive successes Running Time ") |
| 685 | log.info(" %d %d %d " %(self.transactions, |
| 686 | self.total_success, self.running_time)) |
| 687 | log.info("----------------------------------------------------------------------------------") |
| 688 | log.info("Average no. of consecutive successful clients per second: %d", round(self.total_success/self.running_time,0)) |
| 689 | log.info("----------------------------------------------------------------------------------") |
Anil Kumar Sanka | cfa7c58 | 2016-12-09 23:17:22 +0000 | [diff] [blame] | 690 | |