Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 17 | #copyright 2016-present Ciena Corporation |
| 18 | # |
| 19 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 20 | # you may not use this file except in compliance with the License. |
| 21 | # You may obtain a copy of the License at |
| 22 | # |
| 23 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 24 | # |
| 25 | # Unless required by applicable law or agreed to in writing, software |
| 26 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 27 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 28 | # See the License for the specific language governing permissions and |
| 29 | # limitations under the License. |
| 30 | # |
| 31 | import unittest |
| 32 | from nose.tools import * |
| 33 | from scapy.all import * |
A.R Karthick | be7768c | 2017-03-17 11:39:41 -0700 | [diff] [blame] | 34 | from OnosCtrl import OnosCtrl |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 35 | from OltConfig import OltConfig |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 36 | from CordTestUtils import get_mac, get_controller, get_controllers, log_test |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 37 | from OnosFlowCtrl import OnosFlowCtrl |
| 38 | from nose.twistedtools import reactor, deferred |
| 39 | from twisted.internet import defer |
| 40 | from onosclidriver import OnosCliDriver |
| 41 | from CordContainer import Container, Onos, Quagga |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 42 | from CordTestServer import cord_test_onos_restart, cord_test_onos_shutdown, cord_test_onos_add_cluster, cord_test_quagga_restart, cord_test_restart_cluster |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 43 | from portmaps import g_subscriber_port_map |
| 44 | from scapy.all import * |
| 45 | import time, monotonic |
| 46 | import threading |
| 47 | from threading import current_thread |
| 48 | from Cluster import * |
| 49 | from EapTLS import TLSAuthTest |
| 50 | from ACL import ACLTest |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 51 | from OnosLog import OnosLog |
| 52 | from CordLogger import CordLogger |
A R Karthick | 9dc6e92 | 2017-07-12 14:40:16 -0700 | [diff] [blame] | 53 | from CordTestConfig import setup_module, teardown_module |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 54 | import os |
| 55 | import json |
| 56 | import random |
| 57 | import collections |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 58 | log_test.setLevel('INFO') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 59 | |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 60 | class cluster_exchange(CordLogger): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 61 | test_path = os.path.dirname(os.path.realpath(__file__)) |
| 62 | onos_config_path = os.path.join(test_path, '..', 'setup/onos-config') |
| 63 | mac = RandMAC()._fix() |
| 64 | flows_eth = Ether(src = RandMAC()._fix(), dst = RandMAC()._fix()) |
| 65 | igmp_eth = Ether(dst = '01:00:5e:00:00:16', type = ETH_P_IP) |
| 66 | igmp_ip = IP(dst = '224.0.0.22') |
| 67 | ONOS_INSTANCES = 3 |
| 68 | V_INF1 = 'veth0' |
| 69 | TLS_TIMEOUT = 100 |
| 70 | device_id = 'of:' + get_mac() |
| 71 | igmp = cluster_igmp() |
| 72 | igmp_groups = igmp.mcast_ip_range(start_ip = '224.1.8.10',end_ip = '224.1.10.49') |
| 73 | igmp_sources = igmp.source_ip_range(start_ip = '38.24.29.35',end_ip='38.24.35.56') |
| 74 | tls = cluster_tls() |
| 75 | flows = cluster_flows() |
| 76 | proxyarp = cluster_proxyarp() |
| 77 | vrouter = cluster_vrouter() |
| 78 | acl = cluster_acl() |
| 79 | dhcprelay = cluster_dhcprelay() |
| 80 | subscriber = cluster_subscriber() |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 81 | testcaseLoggers = ('test_cluster_controller_restarts', 'test_cluster_graceful_controller_restarts', |
| 82 | 'test_cluster_single_controller_restarts', 'test_cluster_restarts') |
A.R Karthick | 9904482 | 2017-02-09 14:04:20 -0800 | [diff] [blame] | 83 | ITERATIONS = int(os.getenv('ITERATIONS', 10)) |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 84 | ARCHIVE_PARTITION = False |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 85 | |
| 86 | def setUp(self): |
| 87 | if self._testMethodName not in self.testcaseLoggers: |
| 88 | super(cluster_exchange, self).setUp() |
| 89 | |
| 90 | def tearDown(self): |
| 91 | if self._testMethodName not in self.testcaseLoggers: |
| 92 | super(cluster_exchange, self).tearDown() |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 93 | |
A R Karthick | 6cc8b81 | 2016-12-09 10:24:40 -0800 | [diff] [blame] | 94 | def cliEnter(self, controller = None): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 95 | retries = 0 |
A R Karthick | 6cc8b81 | 2016-12-09 10:24:40 -0800 | [diff] [blame] | 96 | while retries < 30: |
| 97 | self.cli = OnosCliDriver(controller = controller, connect = True) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 98 | if self.cli.handle: |
| 99 | break |
| 100 | else: |
| 101 | retries += 1 |
| 102 | time.sleep(2) |
| 103 | |
| 104 | def cliExit(self): |
| 105 | self.cli.disconnect() |
| 106 | |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 107 | def get_leader(self, controller = None): |
| 108 | self.cliEnter(controller = controller) |
A R Karthick | de6b9dc | 2016-11-29 17:46:16 -0800 | [diff] [blame] | 109 | try: |
| 110 | result = json.loads(self.cli.leaders(jsonFormat = True)) |
| 111 | except: |
| 112 | result = None |
| 113 | |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 114 | if result is None: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 115 | log_test.info('Leaders command failure for controller %s' %controller) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 116 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 117 | log_test.info('Leaders returned: %s' %result) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 118 | self.cliExit() |
| 119 | return result |
| 120 | |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 121 | def onos_shutdown(self, controller = None): |
| 122 | status = True |
| 123 | self.cliEnter(controller = controller) |
| 124 | try: |
| 125 | self.cli.shutdown(timeout = 10) |
| 126 | except: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 127 | log_test.info('Graceful shutdown of ONOS failed for controller: %s' %controller) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 128 | status = False |
| 129 | |
| 130 | self.cliExit() |
| 131 | return status |
| 132 | |
A R Karthick | e14fc02 | 2016-12-08 14:50:29 -0800 | [diff] [blame] | 133 | def log_set(self, level = None, app = 'org.onosproject', controllers = None): |
| 134 | CordLogger.logSet(level = level, app = app, controllers = controllers, forced = True) |
A R Karthick | ef1232d | 2016-12-07 09:18:15 -0800 | [diff] [blame] | 135 | |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 136 | def get_leaders(self, controller = None): |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 137 | result_map = {} |
| 138 | if controller is None: |
A.R Karthick | be7768c | 2017-03-17 11:39:41 -0700 | [diff] [blame] | 139 | controller = get_controller() |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 140 | if type(controller) in [ list, tuple ]: |
| 141 | for c in controller: |
| 142 | leaders = self.get_leader(controller = c) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 143 | result_map[c] = leaders |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 144 | else: |
| 145 | leaders = self.get_leader(controller = controller) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 146 | result_map[controller] = leaders |
| 147 | return result_map |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 148 | |
A R Karthick | ec2db32 | 2016-11-17 15:06:01 -0800 | [diff] [blame] | 149 | def verify_leaders(self, controller = None): |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 150 | leaders_map = self.get_leaders(controller = controller) |
| 151 | failed = [ k for k,v in leaders_map.items() if v == None ] |
A R Karthick | ec2db32 | 2016-11-17 15:06:01 -0800 | [diff] [blame] | 152 | return failed |
| 153 | |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 154 | def verify_cluster_status(self,controller = None,onos_instances=ONOS_INSTANCES,verify=False): |
| 155 | tries = 0 |
| 156 | try: |
| 157 | self.cliEnter(controller = controller) |
| 158 | while tries <= 10: |
| 159 | cluster_summary = json.loads(self.cli.summary(jsonFormat = True)) |
| 160 | if cluster_summary: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 161 | log_test.info("cluster 'summary' command output is %s"%cluster_summary) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 162 | nodes = cluster_summary['nodes'] |
| 163 | if verify: |
| 164 | if nodes == onos_instances: |
| 165 | self.cliExit() |
| 166 | return True |
| 167 | else: |
| 168 | tries += 1 |
| 169 | time.sleep(1) |
| 170 | else: |
| 171 | if nodes >= onos_instances: |
| 172 | self.cliExit() |
| 173 | return True |
| 174 | else: |
| 175 | tries += 1 |
| 176 | time.sleep(1) |
| 177 | else: |
| 178 | tries += 1 |
| 179 | time.sleep(1) |
| 180 | self.cliExit() |
| 181 | return False |
| 182 | except: |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 183 | raise Exception('Failed to get cluster members') |
| 184 | return False |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 185 | |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 186 | def get_cluster_current_member_ips(self, controller = None, nodes_filter = None): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 187 | tries = 0 |
| 188 | cluster_ips = [] |
| 189 | try: |
| 190 | self.cliEnter(controller = controller) |
| 191 | while tries <= 10: |
| 192 | cluster_nodes = json.loads(self.cli.nodes(jsonFormat = True)) |
| 193 | if cluster_nodes: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 194 | log_test.info("cluster 'nodes' output is %s"%cluster_nodes) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 195 | if nodes_filter: |
| 196 | cluster_nodes = nodes_filter(cluster_nodes) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 197 | cluster_ips = map(lambda c: c['id'], cluster_nodes) |
| 198 | self.cliExit() |
| 199 | cluster_ips.sort(lambda i1,i2: int(i1.split('.')[-1]) - int(i2.split('.')[-1])) |
| 200 | return cluster_ips |
| 201 | else: |
| 202 | tries += 1 |
| 203 | self.cliExit() |
| 204 | return cluster_ips |
| 205 | except: |
| 206 | raise Exception('Failed to get cluster members') |
| 207 | return cluster_ips |
| 208 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 209 | def get_cluster_container_names_ips(self,controller=None): |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 210 | onos_names_ips = {} |
A.R Karthick | be7768c | 2017-03-17 11:39:41 -0700 | [diff] [blame] | 211 | controllers = get_controllers() |
A R Karthick | 0f3f25b | 2016-12-15 09:50:57 -0800 | [diff] [blame] | 212 | i = 0 |
| 213 | for controller in controllers: |
| 214 | if i == 0: |
| 215 | name = Onos.NAME |
| 216 | else: |
| 217 | name = '{}-{}'.format(Onos.NAME, i+1) |
| 218 | onos_names_ips[controller] = name |
| 219 | onos_names_ips[name] = controller |
| 220 | i += 1 |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 221 | return onos_names_ips |
A R Karthick | 0f3f25b | 2016-12-15 09:50:57 -0800 | [diff] [blame] | 222 | # onos_ips = self.get_cluster_current_member_ips(controller=controller) |
| 223 | # onos_names_ips[onos_ips[0]] = Onos.NAME |
| 224 | # onos_names_ips[Onos.NAME] = onos_ips[0] |
| 225 | # for i in range(1,len(onos_ips)): |
| 226 | # name = '{0}-{1}'.format(Onos.NAME,i+1) |
| 227 | # onos_names_ips[onos_ips[i]] = name |
| 228 | # onos_names_ips[name] = onos_ips[i] |
| 229 | |
| 230 | # return onos_names_ips |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 231 | |
| 232 | #identifying current master of a connected device, not tested |
| 233 | def get_cluster_current_master_standbys(self,controller=None,device_id=device_id): |
| 234 | master = None |
| 235 | standbys = [] |
| 236 | tries = 0 |
| 237 | try: |
| 238 | cli = self.cliEnter(controller = controller) |
| 239 | while tries <= 10: |
| 240 | roles = json.loads(self.cli.roles(jsonFormat = True)) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 241 | log_test.info("cluster 'roles' command output is %s"%roles) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 242 | if roles: |
| 243 | for device in roles: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 244 | log_test.info('Verifying device info in line %s'%device) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 245 | if device['id'] == device_id: |
| 246 | master = str(device['master']) |
| 247 | standbys = map(lambda d: str(d), device['standbys']) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 248 | log_test.info('Master and standbys for device %s are %s and %s'%(device_id, master, standbys)) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 249 | self.cliExit() |
| 250 | return master, standbys |
| 251 | self.cliExit() |
| 252 | return master, standbys |
| 253 | else: |
| 254 | tries += 1 |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 255 | time.sleep(1) |
| 256 | self.cliExit() |
| 257 | return master,standbys |
| 258 | except: |
| 259 | raise Exception('Failed to get cluster members') |
| 260 | return master,standbys |
| 261 | |
| 262 | def get_cluster_current_master_standbys_of_connected_devices(self,controller=None): |
| 263 | ''' returns master and standbys of all the connected devices to ONOS cluster instance''' |
| 264 | device_dict = {} |
| 265 | tries = 0 |
| 266 | try: |
| 267 | cli = self.cliEnter(controller = controller) |
| 268 | while tries <= 10: |
| 269 | device_dict = {} |
| 270 | roles = json.loads(self.cli.roles(jsonFormat = True)) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 271 | log_test.info("cluster 'roles' command output is %s"%roles) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 272 | if roles: |
| 273 | for device in roles: |
| 274 | device_dict[str(device['id'])]= {'master':str(device['master']),'standbys':device['standbys']} |
| 275 | for i in range(len(device_dict[device['id']]['standbys'])): |
| 276 | device_dict[device['id']]['standbys'][i] = str(device_dict[device['id']]['standbys'][i]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 277 | log_test.info('master and standbys for device %s are %s and %s'%(device['id'],device_dict[device['id']]['master'],device_dict[device['id']]['standbys'])) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 278 | self.cliExit() |
| 279 | return device_dict |
| 280 | else: |
| 281 | tries += 1 |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 282 | time.sleep(1) |
| 283 | self.cliExit() |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 284 | return device_dict |
| 285 | except: |
| 286 | raise Exception('Failed to get cluster members') |
| 287 | return device_dict |
| 288 | |
| 289 | #identify current master of a connected device, not tested |
| 290 | def get_cluster_connected_devices(self,controller=None): |
| 291 | '''returns all the devices connected to ONOS cluster''' |
| 292 | device_list = [] |
| 293 | tries = 0 |
| 294 | try: |
| 295 | cli = self.cliEnter(controller = controller) |
| 296 | while tries <= 10: |
| 297 | device_list = [] |
| 298 | devices = json.loads(self.cli.devices(jsonFormat = True)) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 299 | log_test.info("cluster 'devices' command output is %s"%devices) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 300 | if devices: |
| 301 | for device in devices: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 302 | log_test.info('device id is %s'%device['id']) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 303 | device_list.append(str(device['id'])) |
| 304 | self.cliExit() |
| 305 | return device_list |
| 306 | else: |
| 307 | tries += 1 |
| 308 | time.sleep(1) |
| 309 | self.cliExit() |
| 310 | return device_list |
| 311 | except: |
| 312 | raise Exception('Failed to get cluster members') |
| 313 | return device_list |
| 314 | |
| 315 | def get_number_of_devices_of_master(self,controller=None): |
| 316 | '''returns master-device pairs, which master having what devices''' |
| 317 | master_count = {} |
| 318 | try: |
| 319 | cli = self.cliEnter(controller = controller) |
| 320 | masters = json.loads(self.cli.masters(jsonFormat = True)) |
| 321 | if masters: |
| 322 | for master in masters: |
| 323 | master_count[str(master['id'])] = {'size':int(master['size']),'devices':master['devices']} |
| 324 | return master_count |
| 325 | else: |
| 326 | return master_count |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 327 | except: |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 328 | raise Exception('Failed to get cluster members') |
| 329 | return master_count |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 330 | |
| 331 | def change_master_current_cluster(self,new_master=None,device_id=device_id,controller=None): |
| 332 | if new_master is None: return False |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 333 | self.cliEnter(controller=controller) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 334 | cmd = 'device-role' + ' ' + device_id + ' ' + new_master + ' ' + 'master' |
| 335 | command = self.cli.command(cmd = cmd, jsonFormat = False) |
| 336 | self.cliExit() |
| 337 | time.sleep(60) |
| 338 | master, standbys = self.get_cluster_current_master_standbys(controller=controller,device_id=device_id) |
| 339 | assert_equal(master,new_master) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 340 | log_test.info('Cluster master changed to %s successfully'%new_master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 341 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 342 | def withdraw_cluster_current_mastership(self,master_ip=None,device_id=device_id,controller=None): |
| 343 | '''current master looses its mastership and hence new master will be elected''' |
| 344 | self.cliEnter(controller=controller) |
| 345 | cmd = 'device-role' + ' ' + device_id + ' ' + master_ip + ' ' + 'none' |
| 346 | command = self.cli.command(cmd = cmd, jsonFormat = False) |
| 347 | self.cliExit() |
| 348 | time.sleep(60) |
| 349 | new_master_ip, standbys = self.get_cluster_current_master_standbys(controller=controller,device_id=device_id) |
| 350 | assert_not_equal(new_master_ip,master_ip) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 351 | log_test.info('Device-role of device %s successfully changed to none for controller %s'%(device_id,master_ip)) |
| 352 | log_test.info('Cluster new master is %s'%new_master_ip) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 353 | return True |
| 354 | |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 355 | def cluster_controller_restarts(self, graceful = False): |
A.R Karthick | be7768c | 2017-03-17 11:39:41 -0700 | [diff] [blame] | 356 | controllers = get_controllers() |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 357 | ctlr_len = len(controllers) |
| 358 | if ctlr_len <= 1: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 359 | log_test.info('ONOS is not running in cluster mode. This test only works for cluster mode') |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 360 | assert_greater(ctlr_len, 1) |
| 361 | |
| 362 | #this call would verify the cluster for once |
| 363 | onos_map = self.get_cluster_container_names_ips() |
| 364 | |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 365 | def check_exception(iteration, controller = None): |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 366 | adjacent_controller = None |
| 367 | adjacent_controllers = None |
| 368 | if controller: |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 369 | adjacent_controllers = list(set(controllers) - set([controller])) |
| 370 | adjacent_controller = adjacent_controllers[0] |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 371 | for node in controllers: |
| 372 | onosLog = OnosLog(host = node) |
| 373 | ##check the logs for storage exception |
| 374 | _, output = onosLog.get_log(('ERROR', 'Exception',)) |
A R Karthick | ec2db32 | 2016-11-17 15:06:01 -0800 | [diff] [blame] | 375 | if output and output.find('StorageException$Timeout') >= 0: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 376 | log_test.info('\nStorage Exception Timeout found on node: %s\n' %node) |
| 377 | log_test.info('Dumping the ERROR and Exception logs for node: %s\n' %node) |
| 378 | log_test.info('\n' + '-' * 50 + '\n') |
| 379 | log_test.info('%s' %output) |
| 380 | log_test.info('\n' + '-' * 50 + '\n') |
A R Karthick | ec2db32 | 2016-11-17 15:06:01 -0800 | [diff] [blame] | 381 | failed = self.verify_leaders(controllers) |
| 382 | if failed: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 383 | log_test.info('Leaders command failed on nodes: %s' %failed) |
| 384 | log_test.error('Test failed on ITERATION %d' %iteration) |
A R Karthick | 81ece15 | 2017-01-11 16:46:43 -0800 | [diff] [blame] | 385 | CordLogger.archive_results(self._testMethodName, |
| 386 | controllers = controllers, |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 387 | iteration = 'FAILED', |
| 388 | archive_partition = self.ARCHIVE_PARTITION) |
A R Karthick | ec2db32 | 2016-11-17 15:06:01 -0800 | [diff] [blame] | 389 | assert_equal(len(failed), 0) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 390 | return controller |
| 391 | |
| 392 | try: |
A R Karthick | ec2db32 | 2016-11-17 15:06:01 -0800 | [diff] [blame] | 393 | ips = self.get_cluster_current_member_ips(controller = adjacent_controller) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 394 | log_test.info('ONOS cluster formed with controllers: %s' %ips) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 395 | st = True |
| 396 | except: |
| 397 | st = False |
| 398 | |
A R Karthick | ec2db32 | 2016-11-17 15:06:01 -0800 | [diff] [blame] | 399 | failed = self.verify_leaders(controllers) |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 400 | if failed: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 401 | log_test.error('Test failed on ITERATION %d' %iteration) |
A R Karthick | 3396ec4 | 2017-01-11 17:12:13 -0800 | [diff] [blame] | 402 | CordLogger.archive_results(self._testMethodName, |
| 403 | controllers = controllers, |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 404 | iteration = 'FAILED', |
| 405 | archive_partition = self.ARCHIVE_PARTITION) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 406 | assert_equal(len(failed), 0) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 407 | if st is False: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 408 | log_test.info('No storage exception and ONOS cluster was not formed successfully') |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 409 | else: |
| 410 | controller = None |
| 411 | |
| 412 | return controller |
| 413 | |
| 414 | next_controller = None |
A.R Karthick | 9904482 | 2017-02-09 14:04:20 -0800 | [diff] [blame] | 415 | tries = self.ITERATIONS |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 416 | for num in range(tries): |
| 417 | index = num % ctlr_len |
| 418 | #index = random.randrange(0, ctlr_len) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 419 | controller_name = onos_map[controllers[index]] if next_controller is None else onos_map[next_controller] |
| 420 | controller = onos_map[controller_name] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 421 | log_test.info('ITERATION: %d. Restarting Controller %s' %(num + 1, controller_name)) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 422 | try: |
A R Karthick | ef1232d | 2016-12-07 09:18:15 -0800 | [diff] [blame] | 423 | #enable debug log for the other controllers before restarting this controller |
A R Karthick | e14fc02 | 2016-12-08 14:50:29 -0800 | [diff] [blame] | 424 | adjacent_controllers = list( set(controllers) - set([controller]) ) |
| 425 | self.log_set(controllers = adjacent_controllers) |
| 426 | self.log_set(app = 'io.atomix', controllers = adjacent_controllers) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 427 | if graceful is True: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 428 | log_test.info('Gracefully shutting down controller: %s' %controller) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 429 | self.onos_shutdown(controller) |
| 430 | cord_test_onos_restart(node = controller, timeout = 0) |
A R Karthick | e14fc02 | 2016-12-08 14:50:29 -0800 | [diff] [blame] | 431 | self.log_set(controllers = controller) |
| 432 | self.log_set(app = 'io.atomix', controllers = controller) |
A R Karthick | de6b9dc | 2016-11-29 17:46:16 -0800 | [diff] [blame] | 433 | time.sleep(60) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 434 | except: |
| 435 | time.sleep(5) |
| 436 | continue |
A R Karthick | e8935c6 | 2016-12-08 18:17:17 -0800 | [diff] [blame] | 437 | |
| 438 | #first archive the test case logs for this run |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 439 | CordLogger.archive_results(self._testMethodName, |
A R Karthick | e8935c6 | 2016-12-08 18:17:17 -0800 | [diff] [blame] | 440 | controllers = controllers, |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 441 | iteration = 'iteration_{}'.format(num+1), |
| 442 | archive_partition = self.ARCHIVE_PARTITION) |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 443 | next_controller = check_exception(num, controller = controller) |
A R Karthick | 1f90820 | 2016-11-16 17:32:20 -0800 | [diff] [blame] | 444 | |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 445 | def test_cluster_controller_restarts(self): |
| 446 | '''Test the cluster by repeatedly killing the controllers''' |
| 447 | self.cluster_controller_restarts() |
| 448 | |
| 449 | def test_cluster_graceful_controller_restarts(self): |
| 450 | '''Test the cluster by repeatedly restarting the controllers gracefully''' |
| 451 | self.cluster_controller_restarts(graceful = True) |
| 452 | |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 453 | def test_cluster_single_controller_restarts(self): |
| 454 | '''Test the cluster by repeatedly restarting the same controller''' |
A.R Karthick | be7768c | 2017-03-17 11:39:41 -0700 | [diff] [blame] | 455 | controllers = get_controllers() |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 456 | ctlr_len = len(controllers) |
| 457 | if ctlr_len <= 1: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 458 | log_test.info('ONOS is not running in cluster mode. This test only works for cluster mode') |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 459 | assert_greater(ctlr_len, 1) |
| 460 | |
| 461 | #this call would verify the cluster for once |
| 462 | onos_map = self.get_cluster_container_names_ips() |
| 463 | |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 464 | def check_exception(iteration, controller, inclusive = False): |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 465 | adjacent_controllers = list(set(controllers) - set([controller])) |
| 466 | adjacent_controller = adjacent_controllers[0] |
| 467 | controller_list = adjacent_controllers if inclusive == False else controllers |
| 468 | storage_exceptions = [] |
| 469 | for node in controller_list: |
| 470 | onosLog = OnosLog(host = node) |
| 471 | ##check the logs for storage exception |
| 472 | _, output = onosLog.get_log(('ERROR', 'Exception',)) |
| 473 | if output and output.find('StorageException$Timeout') >= 0: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 474 | log_test.info('\nStorage Exception Timeout found on node: %s\n' %node) |
| 475 | log_test.info('Dumping the ERROR and Exception logs for node: %s\n' %node) |
| 476 | log_test.info('\n' + '-' * 50 + '\n') |
| 477 | log_test.info('%s' %output) |
| 478 | log_test.info('\n' + '-' * 50 + '\n') |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 479 | storage_exceptions.append(node) |
| 480 | |
| 481 | failed = self.verify_leaders(controller_list) |
| 482 | if failed: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 483 | log_test.info('Leaders command failed on nodes: %s' %failed) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 484 | if storage_exceptions: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 485 | log_test.info('Storage exception seen on nodes: %s' %storage_exceptions) |
| 486 | log_test.error('Test failed on ITERATION %d' %iteration) |
A R Karthick | 81ece15 | 2017-01-11 16:46:43 -0800 | [diff] [blame] | 487 | CordLogger.archive_results('test_cluster_single_controller_restarts', |
| 488 | controllers = controllers, |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 489 | iteration = 'FAILED', |
| 490 | archive_partition = self.ARCHIVE_PARTITION) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 491 | assert_equal(len(failed), 0) |
| 492 | return controller |
| 493 | |
| 494 | for ctlr in controller_list: |
| 495 | ips = self.get_cluster_current_member_ips(controller = ctlr, |
| 496 | nodes_filter = \ |
| 497 | lambda nodes: [ n for n in nodes if n['state'] in [ 'ACTIVE', 'READY'] ]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 498 | log_test.info('ONOS cluster on node %s formed with controllers: %s' %(ctlr, ips)) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 499 | if controller in ips and inclusive is False: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 500 | log_test.info('Controller %s still ACTIVE on Node %s after it was shutdown' %(controller, ctlr)) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 501 | if controller not in ips and inclusive is True: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 502 | log_test.info('Controller %s still INACTIVE on Node %s after it was restarted' %(controller, ctlr)) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 503 | |
| 504 | return controller |
| 505 | |
A.R Karthick | 9904482 | 2017-02-09 14:04:20 -0800 | [diff] [blame] | 506 | tries = self.ITERATIONS |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 507 | #chose a random controller for shutdown/restarts |
| 508 | controller = controllers[random.randrange(0, ctlr_len)] |
| 509 | controller_name = onos_map[controller] |
A R Karthick | 6cc8b81 | 2016-12-09 10:24:40 -0800 | [diff] [blame] | 510 | ##enable the log level for the controllers |
| 511 | self.log_set(controllers = controllers) |
| 512 | self.log_set(app = 'io.atomix', controllers = controllers) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 513 | for num in range(tries): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 514 | log_test.info('ITERATION: %d. Shutting down Controller %s' %(num + 1, controller_name)) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 515 | try: |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 516 | cord_test_onos_shutdown(node = controller) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 517 | time.sleep(20) |
| 518 | except: |
| 519 | time.sleep(5) |
| 520 | continue |
| 521 | #check for exceptions on the adjacent nodes |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 522 | check_exception(num, controller) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 523 | #Now restart the controller back |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 524 | log_test.info('Restarting back the controller %s' %controller_name) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 525 | cord_test_onos_restart(node = controller) |
A R Karthick | 6cc8b81 | 2016-12-09 10:24:40 -0800 | [diff] [blame] | 526 | self.log_set(controllers = controller) |
| 527 | self.log_set(app = 'io.atomix', controllers = controller) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 528 | time.sleep(60) |
A R Karthick | e8935c6 | 2016-12-08 18:17:17 -0800 | [diff] [blame] | 529 | #archive the logs for this run |
| 530 | CordLogger.archive_results('test_cluster_single_controller_restarts', |
| 531 | controllers = controllers, |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 532 | iteration = 'iteration_{}'.format(num+1), |
| 533 | archive_partition = self.ARCHIVE_PARTITION) |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 534 | check_exception(num, controller, inclusive = True) |
A.R Karthick | 45ab3e1 | 2016-11-30 11:25:51 -0800 | [diff] [blame] | 535 | |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 536 | def test_cluster_restarts(self): |
| 537 | '''Test the cluster by repeatedly restarting the entire cluster''' |
A.R Karthick | be7768c | 2017-03-17 11:39:41 -0700 | [diff] [blame] | 538 | controllers = get_controllers() |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 539 | ctlr_len = len(controllers) |
| 540 | if ctlr_len <= 1: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 541 | log_test.info('ONOS is not running in cluster mode. This test only works for cluster mode') |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 542 | assert_greater(ctlr_len, 1) |
| 543 | |
| 544 | #this call would verify the cluster for once |
| 545 | onos_map = self.get_cluster_container_names_ips() |
| 546 | |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 547 | def check_exception(iteration): |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 548 | controller_list = controllers |
| 549 | storage_exceptions = [] |
| 550 | for node in controller_list: |
| 551 | onosLog = OnosLog(host = node) |
| 552 | ##check the logs for storage exception |
| 553 | _, output = onosLog.get_log(('ERROR', 'Exception',)) |
| 554 | if output and output.find('StorageException$Timeout') >= 0: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 555 | log_test.info('\nStorage Exception Timeout found on node: %s\n' %node) |
| 556 | log_test.info('Dumping the ERROR and Exception logs for node: %s\n' %node) |
| 557 | log_test.info('\n' + '-' * 50 + '\n') |
| 558 | log_test.info('%s' %output) |
| 559 | log_test.info('\n' + '-' * 50 + '\n') |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 560 | storage_exceptions.append(node) |
| 561 | |
| 562 | failed = self.verify_leaders(controller_list) |
| 563 | if failed: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 564 | log_test.info('Leaders command failed on nodes: %s' %failed) |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 565 | if storage_exceptions: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 566 | log_test.info('Storage exception seen on nodes: %s' %storage_exceptions) |
| 567 | log_test.error('Test failed on ITERATION %d' %iteration) |
A R Karthick | 81ece15 | 2017-01-11 16:46:43 -0800 | [diff] [blame] | 568 | CordLogger.archive_results('test_cluster_restarts', |
| 569 | controllers = controllers, |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 570 | iteration = 'FAILED', |
| 571 | archive_partition = self.ARCHIVE_PARTITION) |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 572 | assert_equal(len(failed), 0) |
| 573 | return |
| 574 | |
| 575 | for ctlr in controller_list: |
| 576 | ips = self.get_cluster_current_member_ips(controller = ctlr, |
| 577 | nodes_filter = \ |
| 578 | lambda nodes: [ n for n in nodes if n['state'] in [ 'ACTIVE', 'READY'] ]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 579 | log_test.info('ONOS cluster on node %s formed with controllers: %s' %(ctlr, ips)) |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 580 | if len(ips) != len(controllers): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 581 | log_test.error('Test failed on ITERATION %d' %iteration) |
A R Karthick | 81ece15 | 2017-01-11 16:46:43 -0800 | [diff] [blame] | 582 | CordLogger.archive_results('test_cluster_restarts', |
| 583 | controllers = controllers, |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 584 | iteration = 'FAILED', |
| 585 | archive_partition = self.ARCHIVE_PARTITION) |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 586 | assert_equal(len(ips), len(controllers)) |
| 587 | |
A.R Karthick | 9904482 | 2017-02-09 14:04:20 -0800 | [diff] [blame] | 588 | tries = self.ITERATIONS |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 589 | for num in range(tries): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 590 | log_test.info('ITERATION: %d. Restarting cluster with controllers at %s' %(num+1, controllers)) |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 591 | try: |
| 592 | cord_test_restart_cluster() |
A R Karthick | 6cc8b81 | 2016-12-09 10:24:40 -0800 | [diff] [blame] | 593 | self.log_set(controllers = controllers) |
| 594 | self.log_set(app = 'io.atomix', controllers = controllers) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 595 | log_test.info('Delaying before verifying cluster status') |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 596 | time.sleep(60) |
| 597 | except: |
| 598 | time.sleep(10) |
| 599 | continue |
A R Karthick | e8935c6 | 2016-12-08 18:17:17 -0800 | [diff] [blame] | 600 | |
| 601 | #archive the logs for this run before verification |
| 602 | CordLogger.archive_results('test_cluster_restarts', |
| 603 | controllers = controllers, |
A.R Karthick | 53d9270 | 2017-03-13 10:10:38 -0700 | [diff] [blame] | 604 | iteration = 'iteration_{}'.format(num+1), |
| 605 | archive_partition = self.ARCHIVE_PARTITION) |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 606 | #check for exceptions on the adjacent nodes |
A R Karthick | 2a70a2f | 2016-12-16 14:40:16 -0800 | [diff] [blame] | 607 | check_exception(num) |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 608 | |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 609 | #pass |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 610 | def test_cluster_formation_and_verification(self,onos_instances = ONOS_INSTANCES): |
| 611 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 612 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 613 | log_test.info('Cluster exists with %d ONOS instances'%onos_instances) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 614 | |
| 615 | #nottest cluster not coming up properly if member goes down |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 616 | def test_cluster_adding_members(self, add = 2, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 617 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 618 | assert_equal(status, True) |
| 619 | onos_ips = self.get_cluster_current_member_ips() |
| 620 | onos_instances = len(onos_ips)+add |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 621 | log_test.info('Adding %d nodes to the ONOS cluster' %add) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 622 | cord_test_onos_add_cluster(count = add) |
| 623 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 624 | assert_equal(status, True) |
| 625 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 626 | def test_cluster_removing_master(self, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 627 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 628 | assert_equal(status, True) |
| 629 | master, standbys = self.get_cluster_current_master_standbys() |
| 630 | assert_equal(len(standbys),(onos_instances-1)) |
| 631 | onos_names_ips = self.get_cluster_container_names_ips() |
| 632 | master_onos_name = onos_names_ips[master] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 633 | log_test.info('Removing cluster current master %s'%(master)) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 634 | cord_test_onos_shutdown(node = master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 635 | time.sleep(60) |
| 636 | onos_instances -= 1 |
| 637 | status = self.verify_cluster_status(onos_instances = onos_instances,controller=standbys[0]) |
| 638 | assert_equal(status, True) |
| 639 | new_master, standbys = self.get_cluster_current_master_standbys(controller=standbys[0]) |
| 640 | assert_not_equal(master,new_master) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 641 | log_test.info('Successfully removed clusters master instance') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 642 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 643 | def test_cluster_removing_one_member(self, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 644 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 645 | assert_equal(status, True) |
| 646 | master, standbys = self.get_cluster_current_master_standbys() |
| 647 | assert_equal(len(standbys),(onos_instances-1)) |
| 648 | onos_names_ips = self.get_cluster_container_names_ips() |
| 649 | member_onos_name = onos_names_ips[standbys[0]] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 650 | log_test.info('Removing cluster member %s'%standbys[0]) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 651 | cord_test_onos_shutdown(node = standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 652 | time.sleep(60) |
| 653 | onos_instances -= 1 |
| 654 | status = self.verify_cluster_status(onos_instances = onos_instances,controller=master) |
| 655 | assert_equal(status, True) |
| 656 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 657 | def test_cluster_removing_two_members(self,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 658 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 659 | assert_equal(status, True) |
| 660 | master, standbys = self.get_cluster_current_master_standbys() |
| 661 | assert_equal(len(standbys),(onos_instances-1)) |
| 662 | onos_names_ips = self.get_cluster_container_names_ips() |
| 663 | member1_onos_name = onos_names_ips[standbys[0]] |
| 664 | member2_onos_name = onos_names_ips[standbys[1]] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 665 | log_test.info('Removing cluster member %s'%standbys[0]) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 666 | cord_test_onos_shutdown(node = standbys[0]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 667 | log_test.info('Removing cluster member %s'%standbys[1]) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 668 | cord_test_onos_shutdown(node = standbys[1]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 669 | time.sleep(60) |
| 670 | onos_instances = onos_instances - 2 |
| 671 | status = self.verify_cluster_status(onos_instances = onos_instances,controller=master) |
| 672 | assert_equal(status, True) |
| 673 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 674 | def test_cluster_removing_N_members(self,remove = 2, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 675 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 676 | assert_equal(status, True) |
| 677 | master, standbys = self.get_cluster_current_master_standbys() |
| 678 | assert_equal(len(standbys),(onos_instances-1)) |
| 679 | onos_names_ips = self.get_cluster_container_names_ips() |
| 680 | for i in range(remove): |
| 681 | member_onos_name = onos_names_ips[standbys[i]] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 682 | log_test.info('Removing onos container with name %s'%standbys[i]) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 683 | cord_test_onos_shutdown(node = standbys[i]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 684 | time.sleep(60) |
| 685 | onos_instances = onos_instances - remove |
| 686 | status = self.verify_cluster_status(onos_instances = onos_instances, controller=master) |
| 687 | assert_equal(status, True) |
| 688 | |
| 689 | #nottest test cluster not coming up properly if member goes down |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 690 | def test_cluster_adding_and_removing_members(self,onos_instances = ONOS_INSTANCES , add = 2, remove = 2): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 691 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 692 | assert_equal(status, True) |
| 693 | onos_ips = self.get_cluster_current_member_ips() |
| 694 | onos_instances = len(onos_ips)+add |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 695 | log_test.info('Adding %d ONOS instances to the cluster'%add) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 696 | cord_test_onos_add_cluster(count = add) |
| 697 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 698 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 699 | log_test.info('Removing %d ONOS instances from the cluster'%remove) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 700 | for i in range(remove): |
| 701 | name = '{}-{}'.format(Onos.NAME, onos_instances - i) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 702 | log_test.info('Removing onos container with name %s'%name) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 703 | cord_test_onos_shutdown(node = name) |
| 704 | time.sleep(60) |
| 705 | onos_instances = onos_instances-remove |
| 706 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 707 | assert_equal(status, True) |
| 708 | |
| 709 | #nottest cluster not coming up properly if member goes down |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 710 | def test_cluster_removing_and_adding_member(self,onos_instances = ONOS_INSTANCES,add = 1, remove = 1): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 711 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 712 | assert_equal(status, True) |
| 713 | onos_ips = self.get_cluster_current_member_ips() |
| 714 | onos_instances = onos_instances-remove |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 715 | log_test.info('Removing %d ONOS instances from the cluster'%remove) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 716 | for i in range(remove): |
| 717 | name = '{}-{}'.format(Onos.NAME, len(onos_ips)-i) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 718 | log_test.info('Removing onos container with name %s'%name) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 719 | cord_test_onos_shutdown(node = name) |
| 720 | time.sleep(60) |
| 721 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 722 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 723 | log_test.info('Adding %d ONOS instances to the cluster'%add) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 724 | cord_test_onos_add_cluster(count = add) |
| 725 | onos_instances = onos_instances+add |
| 726 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 727 | assert_equal(status, True) |
| 728 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 729 | def test_cluster_restart(self, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 730 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 731 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 732 | log_test.info('Restarting cluster') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 733 | cord_test_onos_restart() |
| 734 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 735 | assert_equal(status, True) |
| 736 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 737 | def test_cluster_master_restart(self,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 738 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 739 | assert_equal(status, True) |
| 740 | master, standbys = self.get_cluster_current_master_standbys() |
| 741 | onos_names_ips = self.get_cluster_container_names_ips() |
| 742 | master_onos_name = onos_names_ips[master] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 743 | log_test.info('Restarting cluster master %s'%master) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 744 | cord_test_onos_restart(node = master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 745 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 746 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 747 | log_test.info('Cluster came up after master restart as expected') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 748 | |
| 749 | #test fail. master changing after restart. Need to check correct behavior. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 750 | def test_cluster_master_ip_after_master_restart(self,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 751 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 752 | assert_equal(status, True) |
| 753 | master1, standbys = self.get_cluster_current_master_standbys() |
| 754 | onos_names_ips = self.get_cluster_container_names_ips() |
| 755 | master_onos_name = onos_names_ips[master1] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 756 | log_test.info('Restarting cluster master %s'%master1) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 757 | cord_test_onos_restart(node = master1) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 758 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 759 | assert_equal(status, True) |
| 760 | master2, standbys = self.get_cluster_current_master_standbys() |
| 761 | assert_equal(master1,master2) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 762 | log_test.info('Cluster master is same before and after cluster master restart as expected') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 763 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 764 | def test_cluster_one_member_restart(self,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 765 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 766 | assert_equal(status, True) |
| 767 | master, standbys = self.get_cluster_current_master_standbys() |
| 768 | assert_equal(len(standbys),(onos_instances-1)) |
| 769 | onos_names_ips = self.get_cluster_container_names_ips() |
| 770 | member_onos_name = onos_names_ips[standbys[0]] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 771 | log_test.info('Restarting cluster member %s'%standbys[0]) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 772 | cord_test_onos_restart(node = standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 773 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 774 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 775 | log_test.info('Cluster came up as expected after restarting one member') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 776 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 777 | def test_cluster_two_members_restart(self,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 778 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 779 | assert_equal(status, True) |
| 780 | master, standbys = self.get_cluster_current_master_standbys() |
| 781 | assert_equal(len(standbys),(onos_instances-1)) |
| 782 | onos_names_ips = self.get_cluster_container_names_ips() |
| 783 | member1_onos_name = onos_names_ips[standbys[0]] |
| 784 | member2_onos_name = onos_names_ips[standbys[1]] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 785 | log_test.info('Restarting cluster members %s and %s'%(standbys[0],standbys[1])) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 786 | cord_test_onos_restart(node = standbys[0]) |
| 787 | cord_test_onos_restart(node = standbys[1]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 788 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 789 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 790 | log_test.info('Cluster came up as expected after restarting two members') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 791 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 792 | def test_cluster_state_with_N_members_restart(self, members = 2, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 793 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 794 | assert_equal(status,True) |
| 795 | master, standbys = self.get_cluster_current_master_standbys() |
| 796 | assert_equal(len(standbys),(onos_instances-1)) |
| 797 | onos_names_ips = self.get_cluster_container_names_ips() |
| 798 | for i in range(members): |
| 799 | member_onos_name = onos_names_ips[standbys[i]] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 800 | log_test.info('Restarting cluster member %s'%standbys[i]) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 801 | cord_test_onos_restart(node = standbys[i]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 802 | |
| 803 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 804 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 805 | log_test.info('Cluster came up as expected after restarting %d members'%members) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 806 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 807 | def test_cluster_state_with_master_change(self,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 808 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 809 | assert_equal(status, True) |
| 810 | master, standbys = self.get_cluster_current_master_standbys() |
| 811 | assert_equal(len(standbys),(onos_instances-1)) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 812 | log_test.info('Cluster current master of devices is %s'%master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 813 | self.change_master_current_cluster(new_master=standbys[0]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 814 | log_test.info('Cluster master changed successfully') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 815 | |
| 816 | #tested on single onos setup. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 817 | def test_cluster_with_vrouter_routes_in_cluster_members(self,networks = 5,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 818 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 819 | assert_equal(status, True) |
| 820 | onos_ips = self.get_cluster_current_member_ips() |
| 821 | self.vrouter.setUpClass() |
| 822 | res = self.vrouter.vrouter_network_verify(networks, peers = 1) |
| 823 | assert_equal(res, True) |
| 824 | for onos_ip in onos_ips: |
| 825 | tries = 0 |
| 826 | flag = False |
| 827 | try: |
| 828 | self.cliEnter(controller = onos_ip) |
| 829 | while tries <= 5: |
| 830 | routes = json.loads(self.cli.routes(jsonFormat = True)) |
| 831 | if routes: |
| 832 | assert_equal(len(routes['routes4']), networks) |
| 833 | self.cliExit() |
| 834 | flag = True |
| 835 | break |
| 836 | else: |
| 837 | tries += 1 |
| 838 | time.sleep(1) |
| 839 | assert_equal(flag, True) |
| 840 | except: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 841 | log_test.info('Exception occured while checking routes in onos instance %s'%onos_ip) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 842 | raise |
| 843 | |
| 844 | #tested on single onos setup. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 845 | def test_cluster_with_vrouter_and_master_down(self,networks = 5, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 846 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 847 | assert_equal(status, True) |
| 848 | onos_ips = self.get_cluster_current_member_ips() |
| 849 | master, standbys = self.get_cluster_current_master_standbys() |
| 850 | onos_names_ips = self.get_cluster_container_names_ips() |
| 851 | master_onos_name = onos_names_ips[master] |
| 852 | self.vrouter.setUpClass() |
| 853 | res = self.vrouter.vrouter_network_verify(networks, peers = 1) |
| 854 | assert_equal(res,True) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 855 | cord_test_onos_shutdown(node = master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 856 | time.sleep(60) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 857 | log_test.info('Verifying vrouter traffic after cluster master is down') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 858 | self.vrouter.vrouter_traffic_verify() |
| 859 | |
| 860 | #tested on single onos setup. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 861 | def test_cluster_with_vrouter_and_restarting_master(self,networks = 5,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 862 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 863 | assert_equal(status, True) |
| 864 | onos_ips = self.get_cluster_current_member_ips() |
| 865 | master, standbys = self.get_cluster_current_master_standbys() |
| 866 | onos_names_ips = self.get_cluster_container_names_ips() |
| 867 | master_onos_name = onos_names_ips[master] |
| 868 | self.vrouter.setUpClass() |
| 869 | res = self.vrouter.vrouter_network_verify(networks, peers = 1) |
| 870 | assert_equal(res, True) |
| 871 | cord_test_onos_restart() |
| 872 | self.vrouter.vrouter_traffic_verify() |
| 873 | |
| 874 | #tested on single onos setup. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 875 | def test_cluster_deactivating_vrouter_app(self,networks = 5, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 876 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 877 | assert_equal(status, True) |
| 878 | self.vrouter.setUpClass() |
| 879 | res = self.vrouter.vrouter_network_verify(networks, peers = 1) |
| 880 | assert_equal(res, True) |
| 881 | self.vrouter.vrouter_activate(deactivate=True) |
| 882 | time.sleep(15) |
| 883 | self.vrouter.vrouter_traffic_verify(positive_test=False) |
| 884 | self.vrouter.vrouter_activate(deactivate=False) |
| 885 | |
| 886 | #tested on single onos setup. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 887 | def test_cluster_deactivating_vrouter_app_and_making_master_down(self,networks = 5,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 888 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 889 | assert_equal(status, True) |
| 890 | master, standbys = self.get_cluster_current_master_standbys() |
| 891 | onos_names_ips = self.get_cluster_container_names_ips() |
| 892 | master_onos_name = onos_names_ips[master] |
| 893 | self.vrouter.setUpClass() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 894 | log_test.info('Verifying vrouter before master down') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 895 | res = self.vrouter.vrouter_network_verify(networks, peers = 1) |
| 896 | assert_equal(res, True) |
| 897 | self.vrouter.vrouter_activate(deactivate=True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 898 | log_test.info('Verifying vrouter traffic after app deactivated') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 899 | time.sleep(15) ## Expecting vrouter should work properly if master of cluster goes down |
| 900 | self.vrouter.vrouter_traffic_verify(positive_test=False) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 901 | log_test.info('Verifying vrouter traffic after master down') |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 902 | cord_test_onos_shutdown(node = master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 903 | time.sleep(60) |
| 904 | self.vrouter.vrouter_traffic_verify(positive_test=False) |
| 905 | self.vrouter.vrouter_activate(deactivate=False) |
| 906 | |
| 907 | #tested on single onos setup. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 908 | def test_cluster_for_vrouter_app_and_making_member_down(self, networks = 5,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 909 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 910 | assert_equal(status, True) |
| 911 | master, standbys = self.get_cluster_current_master_standbys() |
| 912 | onos_names_ips = self.get_cluster_container_names_ips() |
| 913 | member_onos_name = onos_names_ips[standbys[0]] |
| 914 | self.vrouter.setUpClass() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 915 | log_test.info('Verifying vrouter before cluster member down') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 916 | res = self.vrouter.vrouter_network_verify(networks, peers = 1) |
| 917 | assert_equal(res, True) # Expecting vrouter should work properly |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 918 | log_test.info('Verifying vrouter after cluster member down') |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 919 | cord_test_onos_shutdown(node = standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 920 | time.sleep(60) |
| 921 | self.vrouter.vrouter_traffic_verify()# Expecting vrouter should work properly if member of cluster goes down |
| 922 | |
| 923 | #tested on single onos setup. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 924 | def test_cluster_for_vrouter_app_and_restarting_member(self,networks = 5, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 925 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 926 | assert_equal(status, True) |
| 927 | master, standbys = self.get_cluster_current_master_standbys() |
| 928 | onos_names_ips = self.get_cluster_container_names_ips() |
| 929 | member_onos_name = onos_names_ips[standbys[1]] |
| 930 | self.vrouter.setUpClass() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 931 | log_test.info('Verifying vrouter traffic before cluster member restart') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 932 | res = self.vrouter.vrouter_network_verify(networks, peers = 1) |
| 933 | assert_equal(res, True) # Expecting vrouter should work properly |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 934 | cord_test_onos_restart(node = standbys[1]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 935 | log_test.info('Verifying vrouter traffic after cluster member restart') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 936 | self.vrouter.vrouter_traffic_verify()# Expecting vrouter should work properly if member of cluster restarts |
| 937 | |
| 938 | #tested on single onos setup. |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 939 | def test_cluster_for_vrouter_app_restarting_cluster(self,networks = 5, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 940 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 941 | assert_equal(status, True) |
| 942 | self.vrouter.setUpClass() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 943 | log_test.info('Verifying vrouter traffic before cluster restart') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 944 | res = self.vrouter.vrouter_network_verify(networks, peers = 1) |
| 945 | assert_equal(res, True) # Expecting vrouter should work properly |
| 946 | cord_test_onos_restart() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 947 | log_test.info('Verifying vrouter traffic after cluster restart') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 948 | self.vrouter.vrouter_traffic_verify()# Expecting vrouter should work properly if member of cluster restarts |
| 949 | |
| 950 | |
| 951 | #test fails because flow state is in pending_add in onos |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 952 | def test_cluster_for_flows_of_udp_port_and_making_master_down(self, onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 953 | status = self.verify_cluster_status(onos_instances = onos_instances) |
| 954 | assert_equal(status, True) |
| 955 | master, standbys = self.get_cluster_current_master_standbys() |
| 956 | onos_names_ips = self.get_cluster_container_names_ips() |
| 957 | master_onos_name = onos_names_ips[master] |
| 958 | self.flows.setUpClass() |
| 959 | egress = 1 |
| 960 | ingress = 2 |
| 961 | egress_map = { 'ip': '192.168.30.1', 'udp_port': 9500 } |
| 962 | ingress_map = { 'ip': '192.168.40.1', 'udp_port': 9000 } |
| 963 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 964 | egressPort = egress, |
| 965 | ingressPort = ingress, |
| 966 | udpSrc = ingress_map['udp_port'], |
| 967 | udpDst = egress_map['udp_port'], |
| 968 | controller=master |
| 969 | ) |
| 970 | result = flow.addFlow() |
| 971 | assert_equal(result, True) |
| 972 | time.sleep(1) |
| 973 | self.success = False |
| 974 | def mac_recv_task(): |
| 975 | def recv_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 976 | log_test.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport)) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 977 | self.success = True |
| 978 | sniff(timeout=2, |
| 979 | lfilter = lambda p: UDP in p and p[UDP].dport == egress_map['udp_port'] |
| 980 | and p[UDP].sport == ingress_map['udp_port'], prn = recv_cb, iface = self.flows.port_map[egress]) |
| 981 | |
| 982 | for i in [0,1]: |
| 983 | if i == 1: |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 984 | cord_test_onos_shutdown(node = master) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 985 | log_test.info('Verifying flows traffic after master killed') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 986 | time.sleep(45) |
| 987 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 988 | log_test.info('Verifying flows traffic before master killed') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 989 | t = threading.Thread(target = mac_recv_task) |
| 990 | t.start() |
| 991 | L2 = self.flows_eth #Ether(src = ingress_map['ether'], dst = egress_map['ether']) |
| 992 | L3 = IP(src = ingress_map['ip'], dst = egress_map['ip']) |
| 993 | L4 = UDP(sport = ingress_map['udp_port'], dport = egress_map['udp_port']) |
| 994 | pkt = L2/L3/L4 |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 995 | log_test.info('Sending packets to verify if flows are correct') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 996 | sendp(pkt, count=50, iface = self.flows.port_map[ingress]) |
| 997 | t.join() |
| 998 | assert_equal(self.success, True) |
| 999 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1000 | def test_cluster_state_changing_master_and_flows_of_ecn(self,onos_instances = ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1001 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1002 | assert_equal(status, True) |
| 1003 | master, standbys = self.get_cluster_current_master_standbys() |
| 1004 | self.flows.setUpClass() |
| 1005 | egress = 1 |
| 1006 | ingress = 2 |
| 1007 | egress_map = { 'ip': '192.168.30.1' } |
| 1008 | ingress_map = { 'ip': '192.168.40.1' } |
| 1009 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 1010 | egressPort = egress, |
| 1011 | ingressPort = ingress, |
| 1012 | ecn = 1, |
| 1013 | controller=master |
| 1014 | ) |
| 1015 | result = flow.addFlow() |
| 1016 | assert_equal(result, True) |
| 1017 | ##wait for flows to be added to ONOS |
| 1018 | time.sleep(1) |
| 1019 | self.success = False |
| 1020 | def mac_recv_task(): |
| 1021 | def recv_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1022 | log_test.info('Pkt seen with ingress ip %s, egress ip %s and Type of Service %s' %(pkt[IP].src, pkt[IP].dst, pkt[IP].tos)) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1023 | self.success = True |
| 1024 | sniff(count=2, timeout=5, |
| 1025 | lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip'] |
| 1026 | and int(bin(p[IP].tos).split('b')[1][-2:],2) == 1,prn = recv_cb, |
| 1027 | iface = self.flows.port_map[egress]) |
| 1028 | for i in [0,1]: |
| 1029 | if i == 1: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1030 | log_test.info('Changing cluster master to %s'%standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1031 | self.change_master_current_cluster(new_master=standbys[0]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1032 | log_test.info('Verifying flow traffic after cluster master chnaged') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1033 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1034 | log_test.info('Verifying flow traffic before cluster master changed') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1035 | t = threading.Thread(target = mac_recv_task) |
| 1036 | t.start() |
| 1037 | L2 = self.flows_eth # Ether(src = ingress_map['ether'], dst = egress_map['ether']) |
| 1038 | L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'], tos = 1) |
| 1039 | pkt = L2/L3 |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1040 | log_test.info('Sending a packet to verify if flows are correct') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1041 | sendp(pkt, count=50, iface = self.flows.port_map[ingress]) |
| 1042 | t.join() |
| 1043 | assert_equal(self.success, True) |
| 1044 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1045 | #pass |
| 1046 | def test_cluster_flow_for_ipv6_extension_header_and_master_restart(self,onos_instances = ONOS_INSTANCES): |
| 1047 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1048 | assert_equal(status, True) |
| 1049 | master,standbys = self.get_cluster_current_master_standbys() |
| 1050 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1051 | master_onos_name = onos_names_ips[master] |
| 1052 | self.flows.setUpClass() |
| 1053 | egress = 1 |
| 1054 | ingress = 2 |
| 1055 | egress_map = { 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1001' } |
| 1056 | ingress_map = { 'ipv6': '2001:db8:a0b:12f0:1010:1010:1010:1002' } |
| 1057 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 1058 | egressPort = egress, |
| 1059 | ingressPort = ingress, |
| 1060 | ipv6_extension = 0, |
| 1061 | controller=master |
| 1062 | ) |
| 1063 | |
| 1064 | result = flow.addFlow() |
| 1065 | assert_equal(result, True) |
| 1066 | ##wait for flows to be added to ONOS |
| 1067 | time.sleep(1) |
| 1068 | self.success = False |
| 1069 | def mac_recv_task(): |
| 1070 | def recv_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1071 | log_test.info('Pkt seen with ingress ip %s, egress ip %s, Extension Header Type %s'%(pkt[IPv6].src, pkt[IPv6].dst, pkt[IPv6].nh)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1072 | self.success = True |
| 1073 | sniff(timeout=2,count=5, |
| 1074 | lfilter = lambda p: IPv6 in p and p[IPv6].nh == 0, prn = recv_cb, iface = self.flows.port_map[egress]) |
| 1075 | for i in [0,1]: |
| 1076 | if i == 1: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1077 | log_test.info('Restart cluster current master %s'%master) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1078 | Container(master_onos_name,Onos.IMAGE).restart() |
| 1079 | time.sleep(45) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1080 | log_test.info('Verifying flow traffic after master restart') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1081 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1082 | log_test.info('Verifying flow traffic before master restart') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1083 | t = threading.Thread(target = mac_recv_task) |
| 1084 | t.start() |
| 1085 | L2 = self.flows_eth |
| 1086 | L3 = IPv6(src = ingress_map['ipv6'] , dst = egress_map['ipv6'], nh = 0) |
| 1087 | pkt = L2/L3 |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1088 | log_test.info('Sending packets to verify if flows are correct') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1089 | sendp(pkt, count=50, iface = self.flows.port_map[ingress]) |
| 1090 | t.join() |
| 1091 | assert_equal(self.success, True) |
| 1092 | |
| 1093 | def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'): |
| 1094 | dst_mac = self.igmp.iptomac(group) |
| 1095 | eth = Ether(dst= dst_mac) |
| 1096 | ip = IP(dst=group,src=source) |
| 1097 | data = repr(monotonic.monotonic()) |
| 1098 | sendp(eth/ip/data,count=20, iface = intf) |
| 1099 | pkt = (eth/ip/data) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1100 | log_test.info('multicast traffic packet %s'%pkt.show()) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1101 | |
| 1102 | def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1103 | log_test.info('verifying multicast traffic for group %s from source %s'%(group,source)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1104 | self.success = False |
| 1105 | def recv_task(): |
| 1106 | def igmp_recv_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1107 | log_test.info('multicast data received for group %s from source %s'%(group,source)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1108 | self.success = True |
| 1109 | sniff(prn = igmp_recv_cb,lfilter = lambda p: IP in p and p[IP].dst == group and p[IP].src == source, count=1,timeout = 2, iface='veth0') |
| 1110 | t = threading.Thread(target = recv_task) |
| 1111 | t.start() |
| 1112 | self.send_multicast_data_traffic(group,source=source) |
| 1113 | t.join() |
| 1114 | return self.success |
| 1115 | |
| 1116 | #pass |
| 1117 | def test_cluster_with_igmp_include_exclude_modes_and_restarting_master(self, onos_instances=ONOS_INSTANCES): |
| 1118 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1119 | assert_equal(status, True) |
| 1120 | master, standbys = self.get_cluster_current_master_standbys() |
| 1121 | assert_equal(len(standbys), (onos_instances-1)) |
| 1122 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1123 | master_onos_name = onos_names_ips[master] |
| 1124 | self.igmp.setUp(controller=master) |
| 1125 | groups = ['224.2.3.4','230.5.6.7'] |
| 1126 | src_list = ['2.2.2.2','3.3.3.3'] |
| 1127 | self.igmp.onos_ssm_table_load(groups, src_list=src_list, controller=master) |
| 1128 | self.igmp.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1129 | iface = self.V_INF1, delay = 2) |
| 1130 | self.igmp.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE, |
| 1131 | iface = self.V_INF1, delay = 2) |
| 1132 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1133 | assert_equal(status,True) |
| 1134 | status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1]) |
| 1135 | assert_equal(status,False) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1136 | log_test.info('restarting cluster master %s'%master) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1137 | Container(master_onos_name,Onos.IMAGE).restart() |
| 1138 | time.sleep(60) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1139 | log_test.info('verifying multicast data traffic after master restart') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1140 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1141 | assert_equal(status,True) |
| 1142 | status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1]) |
| 1143 | assert_equal(status,False) |
| 1144 | |
| 1145 | #pass |
| 1146 | def test_cluster_with_igmp_include_exclude_modes_and_making_master_down(self, onos_instances=ONOS_INSTANCES): |
| 1147 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1148 | assert_equal(status, True) |
| 1149 | master, standbys = self.get_cluster_current_master_standbys() |
| 1150 | assert_equal(len(standbys), (onos_instances-1)) |
| 1151 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1152 | master_onos_name = onos_names_ips[master] |
| 1153 | self.igmp.setUp(controller=master) |
| 1154 | groups = [self.igmp.random_mcast_ip(),self.igmp.random_mcast_ip()] |
| 1155 | src_list = [self.igmp.randomsourceip()] |
| 1156 | self.igmp.onos_ssm_table_load(groups, src_list=src_list,controller=master) |
| 1157 | self.igmp.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1158 | iface = self.V_INF1, delay = 2) |
| 1159 | self.igmp.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE, |
| 1160 | iface = self.V_INF1, delay = 2) |
| 1161 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1162 | assert_equal(status,True) |
| 1163 | status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[0]) |
| 1164 | assert_equal(status,False) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1165 | log_test.info('Killing cluster master %s'%master) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1166 | Container(master_onos_name,Onos.IMAGE).kill() |
| 1167 | time.sleep(60) |
| 1168 | status = self.verify_cluster_status(onos_instances=onos_instances-1,controller=standbys[0]) |
| 1169 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1170 | log_test.info('Verifying multicast data traffic after cluster master down') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1171 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1172 | assert_equal(status,True) |
| 1173 | status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[0]) |
| 1174 | assert_equal(status,False) |
| 1175 | |
| 1176 | def test_cluster_with_igmp_include_mode_checking_traffic_recovery_time_after_master_is_down(self, onos_instances=ONOS_INSTANCES): |
| 1177 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1178 | assert_equal(status, True) |
| 1179 | master, standbys = self.get_cluster_current_master_standbys() |
| 1180 | assert_equal(len(standbys), (onos_instances-1)) |
| 1181 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1182 | master_onos_name = onos_names_ips[master] |
| 1183 | self.igmp.setUp(controller=master) |
| 1184 | groups = [self.igmp.random_mcast_ip()] |
| 1185 | src_list = [self.igmp.randomsourceip()] |
| 1186 | self.igmp.onos_ssm_table_load(groups, src_list=src_list,controller=master) |
| 1187 | self.igmp.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1188 | iface = self.V_INF1, delay = 2) |
| 1189 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1190 | assert_equal(status,True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1191 | log_test.info('Killing clusters master %s'%master) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1192 | Container(master_onos_name,Onos.IMAGE).kill() |
| 1193 | count = 0 |
| 1194 | for i in range(60): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1195 | log_test.info('Verifying multicast data traffic after cluster master down') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1196 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1197 | if status: |
| 1198 | break |
| 1199 | else: |
| 1200 | count += 1 |
| 1201 | time.sleep(1) |
| 1202 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1203 | log_test.info('Time taken to recover traffic after clusters master down is %d seconds'%count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1204 | |
| 1205 | |
| 1206 | #pass |
| 1207 | def test_cluster_state_with_igmp_leave_group_after_master_change(self, onos_instances=ONOS_INSTANCES): |
| 1208 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1209 | assert_equal(status, True) |
| 1210 | master, standbys = self.get_cluster_current_master_standbys() |
| 1211 | assert_equal(len(standbys), (onos_instances-1)) |
| 1212 | self.igmp.setUp(controller=master) |
| 1213 | groups = [self.igmp.random_mcast_ip()] |
| 1214 | src_list = [self.igmp.randomsourceip()] |
| 1215 | self.igmp.onos_ssm_table_load(groups, src_list=src_list,controller=master) |
| 1216 | self.igmp.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1217 | iface = self.V_INF1, delay = 2) |
| 1218 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1219 | assert_equal(status,True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1220 | log_test.info('Changing cluster master %s to %s'%(master,standbys[0])) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1221 | self.change_cluster_current_master(new_master=standbys[0]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1222 | log_test.info('Verifying multicast traffic after cluster master change') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1223 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1224 | assert_equal(status,True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1225 | log_test.info('Sending igmp TO_EXCLUDE message to leave the group %s'%groups[0]) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1226 | self.igmp.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE, |
| 1227 | iface = self.V_INF1, delay = 1) |
| 1228 | time.sleep(10) |
| 1229 | status = self.verify_igmp_data_traffic(groups[0],intf = self.V_INF1,source= src_list[0]) |
| 1230 | assert_equal(status,False) |
| 1231 | |
| 1232 | #pass |
| 1233 | def test_cluster_state_with_igmp_join_before_and_after_master_change(self,onos_instances=ONOS_INSTANCES): |
| 1234 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1235 | assert_equal(status, True) |
| 1236 | master,standbys = self.get_cluster_current_master_standbys() |
| 1237 | assert_equal(len(standbys), (onos_instances-1)) |
| 1238 | self.igmp.setUp(controller=master) |
| 1239 | groups = [self.igmp.random_mcast_ip()] |
| 1240 | src_list = [self.igmp.randomsourceip()] |
| 1241 | self.igmp.onos_ssm_table_load(groups, src_list=src_list,controller=master) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1242 | log_test.info('Changing cluster master %s to %s'%(master,standbys[0])) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1243 | self.change_cluster_current_master(new_master = standbys[0]) |
| 1244 | self.igmp.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1245 | iface = self.V_INF1, delay = 2) |
| 1246 | time.sleep(1) |
| 1247 | self.change_cluster_current_master(new_master = master) |
| 1248 | status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0]) |
| 1249 | assert_equal(status,True) |
| 1250 | |
| 1251 | #pass |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1252 | @deferred(TLS_TIMEOUT) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1253 | def test_cluster_with_eap_tls_traffic(self,onos_instances=ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1254 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1255 | assert_equal(status, True) |
| 1256 | master, standbys = self.get_cluster_current_master_standbys() |
| 1257 | assert_equal(len(standbys), (onos_instances-1)) |
| 1258 | self.tls.setUp(controller=master) |
| 1259 | df = defer.Deferred() |
| 1260 | def eap_tls_verify(df): |
| 1261 | tls = TLSAuthTest() |
| 1262 | tls.runTest() |
| 1263 | df.callback(0) |
| 1264 | reactor.callLater(0, eap_tls_verify, df) |
| 1265 | return df |
| 1266 | |
| 1267 | @deferred(120) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1268 | def test_cluster_for_eap_tls_traffic_before_and_after_master_change(self,onos_instances=ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1269 | master, standbys = self.get_cluster_current_master_standbys() |
| 1270 | assert_equal(len(standbys), (onos_instances-1)) |
| 1271 | self.tls.setUp() |
| 1272 | df = defer.Deferred() |
| 1273 | def eap_tls_verify2(df2): |
| 1274 | tls = TLSAuthTest() |
| 1275 | tls.runTest() |
| 1276 | df.callback(0) |
| 1277 | for i in [0,1]: |
| 1278 | if i == 1: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1279 | log_test.info('Changing cluster master %s to %s'%(master, standbys[0])) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1280 | self.change_master_current_cluster(new_master=standbys[0]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1281 | log_test.info('Verifying tls authentication after cluster master changed to %s'%standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1282 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1283 | log_test.info('Verifying tls authentication before cluster master change') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1284 | reactor.callLater(0, eap_tls_verify, df) |
| 1285 | return df |
| 1286 | |
| 1287 | @deferred(TLS_TIMEOUT) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1288 | def test_cluster_for_eap_tls_traffic_before_and_after_making_master_down(self,onos_instances=ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1289 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1290 | assert_equal(status, True) |
| 1291 | master, standbys = self.get_cluster_current_master_standbys() |
| 1292 | assert_equal(len(standbys), (onos_instances-1)) |
| 1293 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1294 | master_onos_name = onos_names_ips[master] |
| 1295 | self.tls.setUp() |
| 1296 | df = defer.Deferred() |
| 1297 | def eap_tls_verify(df): |
| 1298 | tls = TLSAuthTest() |
| 1299 | tls.runTest() |
| 1300 | df.callback(0) |
| 1301 | for i in [0,1]: |
| 1302 | if i == 1: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1303 | log_test.info('Killing cluster current master %s'%master) |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 1304 | cord_test_onos_shutdown(node = master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1305 | time.sleep(20) |
| 1306 | status = self.verify_cluster_status(controller=standbys[0],onos_instances=onos_instances-1,verify=True) |
| 1307 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1308 | log_test.info('Cluster came up with %d instances after killing master'%(onos_instances-1)) |
| 1309 | log_test.info('Verifying tls authentication after killing cluster master') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1310 | reactor.callLater(0, eap_tls_verify, df) |
| 1311 | return df |
| 1312 | |
| 1313 | @deferred(TLS_TIMEOUT) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1314 | def test_cluster_for_eap_tls_with_no_cert_before_and_after_member_is_restarted(self,onos_instances=ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1315 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1316 | assert_equal(status, True) |
| 1317 | master, standbys = self.get_cluster_current_master_standbys() |
| 1318 | assert_equal(len(standbys), (onos_instances-1)) |
| 1319 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1320 | member_onos_name = onos_names_ips[standbys[0]] |
| 1321 | self.tls.setUp() |
| 1322 | df = defer.Deferred() |
| 1323 | def eap_tls_no_cert(df): |
| 1324 | def tls_no_cert_cb(): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1325 | log_test.info('TLS authentication failed with no certificate') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1326 | tls = TLSAuthTest(fail_cb = tls_no_cert_cb, client_cert = '') |
| 1327 | tls.runTest() |
| 1328 | assert_equal(tls.failTest, True) |
| 1329 | df.callback(0) |
| 1330 | for i in [0,1]: |
| 1331 | if i == 1: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1332 | log_test.info('Restart cluster member %s'%standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1333 | Container(member_onos_name,Onos.IMAGE).restart() |
| 1334 | time.sleep(20) |
| 1335 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1336 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1337 | log_test.info('Cluster came up with %d instances after member restart'%(onos_instances)) |
| 1338 | log_test.info('Verifying tls authentication after member restart') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1339 | reactor.callLater(0, eap_tls_no_cert, df) |
| 1340 | return df |
| 1341 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1342 | #pass |
| 1343 | def test_cluster_proxyarp_master_change_and_app_deactivation(self,onos_instances=ONOS_INSTANCES,hosts = 3): |
| 1344 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1345 | assert_equal(status,True) |
| 1346 | master,standbys = self.get_cluster_current_master_standbys() |
| 1347 | assert_equal(len(standbys),(onos_instances-1)) |
| 1348 | self.proxyarp.setUpClass() |
| 1349 | ports_map, egress_map,hosts_config = self.proxyarp.proxyarp_config(hosts = hosts,controller=master) |
| 1350 | ingress = hosts+1 |
| 1351 | for hostip, hostmac in hosts_config: |
| 1352 | self.proxyarp.proxyarp_arpreply_verify(ingress,hostip,hostmac,PositiveTest = True) |
| 1353 | time.sleep(1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1354 | log_test.info('changing cluster current master from %s to %s'%(master,standbys[0])) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1355 | self.change_cluster_current_master(new_master=standbys[0]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1356 | log_test.info('verifying proxyarp after master change') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1357 | for hostip, hostmac in hosts_config: |
| 1358 | self.proxyarp.proxyarp_arpreply_verify(ingress,hostip,hostmac,PositiveTest = True) |
| 1359 | time.sleep(1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1360 | log_test.info('Deactivating proxyarp app and expecting proxyarp functionality not to work') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1361 | self.proxyarp.proxyarp_activate(deactivate = True,controller=standbys[0]) |
| 1362 | time.sleep(3) |
| 1363 | for hostip, hostmac in hosts_config: |
| 1364 | self.proxyarp.proxyarp_arpreply_verify(ingress,hostip,hostmac,PositiveTest = False) |
| 1365 | time.sleep(1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1366 | log_test.info('activating proxyarp app and expecting to get arp reply from ONOS') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1367 | self.proxyarp.proxyarp_activate(deactivate = False,controller=standbys[0]) |
| 1368 | time.sleep(3) |
| 1369 | for hostip, hostmac in hosts_config: |
| 1370 | self.proxyarp.proxyarp_arpreply_verify(ingress,hostip,hostmac,PositiveTest = True) |
| 1371 | time.sleep(1) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1372 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1373 | #pass |
| 1374 | def test_cluster_with_proxyarp_and_one_member_down(self,hosts=3,onos_instances=ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1375 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1376 | assert_equal(status, True) |
| 1377 | master, standbys = self.get_cluster_current_master_standbys() |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1378 | assert_equal(len(standbys), (onos_instances-1)) |
| 1379 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1380 | member_onos_name = onos_names_ips[standbys[1]] |
| 1381 | self.proxyarp.setUpClass() |
| 1382 | ports_map, egress_map,hosts_config = self.proxyarp.proxyarp_config(hosts = hosts,controller=master) |
| 1383 | ingress = hosts+1 |
| 1384 | for hostip, hostmac in hosts_config: |
| 1385 | self.proxyarp.proxyarp_arpreply_verify(ingress,hostip,hostmac,PositiveTest = True) |
| 1386 | time.sleep(1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1387 | log_test.info('killing cluster member %s'%standbys[1]) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1388 | Container(member_onos_name,Onos.IMAGE).kill() |
| 1389 | time.sleep(20) |
| 1390 | status = self.verify_cluster_status(onos_instances=onos_instances-1,controller=master,verify=True) |
| 1391 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1392 | log_test.info('cluster came up with %d instances after member down'%(onos_instances-1)) |
| 1393 | log_test.info('verifying proxy arp functionality after cluster member down') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1394 | for hostip, hostmac in hosts_config: |
| 1395 | self.proxyarp.proxyarp_arpreply_verify(ingress,hostip,hostmac,PositiveTest = True) |
| 1396 | time.sleep(1) |
| 1397 | |
| 1398 | #pass |
| 1399 | def test_cluster_with_proxyarp_and_concurrent_requests_with_multiple_host_and_different_interfaces(self,hosts=10,onos_instances=ONOS_INSTANCES): |
| 1400 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1401 | assert_equal(status, True) |
| 1402 | self.proxyarp.setUpClass() |
| 1403 | master, standbys = self.get_cluster_current_master_standbys() |
| 1404 | assert_equal(len(standbys), (onos_instances-1)) |
| 1405 | ports_map, egress_map, hosts_config = self.proxyarp.proxyarp_config(hosts = hosts, controller=master) |
| 1406 | self.success = True |
| 1407 | ingress = hosts+1 |
| 1408 | ports = range(ingress,ingress+10) |
| 1409 | hostmac = [] |
| 1410 | hostip = [] |
| 1411 | for ip,mac in hosts_config: |
| 1412 | hostmac.append(mac) |
| 1413 | hostip.append(ip) |
| 1414 | success_dir = {} |
| 1415 | def verify_proxyarp(*r): |
| 1416 | ingress, hostmac, hostip = r[0],r[1],r[2] |
| 1417 | def mac_recv_task(): |
| 1418 | def recv_cb(pkt): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1419 | log_test.info('Arp Reply seen with source Mac is %s' %(pkt[ARP].hwsrc)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1420 | success_dir[current_thread().name] = True |
| 1421 | sniff(count=1, timeout=5,lfilter = lambda p: ARP in p and p[ARP].op == 2 and p[ARP].hwsrc == hostmac, |
| 1422 | prn = recv_cb, iface = self.proxyarp.port_map[ingress]) |
| 1423 | t = threading.Thread(target = mac_recv_task) |
| 1424 | t.start() |
| 1425 | pkt = (Ether(dst = 'ff:ff:ff:ff:ff:ff')/ARP(op=1,pdst= hostip)) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1426 | log_test.info('Sending arp request for dest ip %s on interface %s' % |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1427 | (hostip,self.proxyarp.port_map[ingress])) |
| 1428 | sendp(pkt, count = 10,iface = self.proxyarp.port_map[ingress]) |
| 1429 | t.join() |
| 1430 | t = [] |
| 1431 | for i in range(10): |
| 1432 | t.append(threading.Thread(target = verify_proxyarp, args = [ports[i],hostmac[i],hostip[i]])) |
| 1433 | for i in range(10): |
| 1434 | t[i].start() |
| 1435 | time.sleep(2) |
| 1436 | for i in range(10): |
| 1437 | t[i].join() |
| 1438 | if len(success_dir) != 10: |
| 1439 | self.success = False |
| 1440 | assert_equal(self.success, True) |
| 1441 | |
| 1442 | #pass |
| 1443 | def test_cluster_with_acl_rule_before_master_change_and_remove_acl_rule_after_master_change(self,onos_instances=ONOS_INSTANCES): |
| 1444 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1445 | assert_equal(status, True) |
| 1446 | master,standbys = self.get_cluster_current_master_standbys() |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1447 | assert_equal(len(standbys),(onos_instances-1)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1448 | self.acl.setUp() |
| 1449 | acl_rule = ACLTest() |
| 1450 | status,code = acl_rule.adding_acl_rule('v4', srcIp=self.acl.ACL_SRC_IP, dstIp =self.acl.ACL_DST_IP, action = 'allow',controller=master) |
| 1451 | if status is False: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1452 | log_test.info('JSON request returned status %d' %code) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1453 | assert_equal(status, True) |
| 1454 | result = acl_rule.get_acl_rules(controller=master) |
| 1455 | aclRules1 = result.json()['aclRules'] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1456 | log_test.info('Added acl rules is %s'%aclRules1) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1457 | acl_Id = map(lambda d: d['id'], aclRules1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1458 | log_test.info('Changing cluster current master from %s to %s'%(master,standbys[0])) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1459 | self.change_cluster_current_master(new_master=standbys[0]) |
| 1460 | status,code = acl_rule.remove_acl_rule(acl_Id[0],controller=standbys[0]) |
| 1461 | if status is False: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1462 | log_test.info('JSON request returned status %d' %code) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1463 | assert_equal(status, True) |
| 1464 | |
| 1465 | #pass |
| 1466 | def test_cluster_verifying_acl_rule_in_new_master_after_current_master_is_down(self,onos_instances=ONOS_INSTANCES): |
| 1467 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1468 | assert_equal(status, True) |
| 1469 | master,standbys = self.get_cluster_current_master_standbys() |
| 1470 | assert_equal(len(standbys),(onos_instances-1)) |
| 1471 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1472 | master_onos_name = onos_names_ips[master] |
| 1473 | self.acl.setUp() |
| 1474 | acl_rule = ACLTest() |
| 1475 | status,code = acl_rule.adding_acl_rule('v4', srcIp=self.acl.ACL_SRC_IP, dstIp =self.acl.ACL_DST_IP, action = 'allow',controller=master) |
| 1476 | if status is False: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1477 | log_test.info('JSON request returned status %d' %code) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1478 | assert_equal(status, True) |
| 1479 | result1 = acl_rule.get_acl_rules(controller=master) |
| 1480 | aclRules1 = result1.json()['aclRules'] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1481 | log_test.info('Added acl rules is %s'%aclRules1) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1482 | acl_Id1 = map(lambda d: d['id'], aclRules1) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1483 | log_test.info('Killing cluster current master %s'%master) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1484 | Container(master_onos_name,Onos.IMAGE).kill() |
| 1485 | time.sleep(45) |
| 1486 | status = self.verify_cluster_status(onos_instances=onos_instances,controller=standbys[0]) |
| 1487 | assert_equal(status, True) |
| 1488 | new_master,standbys = self.get_cluster_current_master_standbys(controller=standbys[0]) |
| 1489 | assert_equal(len(standbys),(onos_instances-2)) |
| 1490 | assert_not_equal(new_master,master) |
| 1491 | result2 = acl_rule.get_acl_rules(controller=new_master) |
| 1492 | aclRules2 = result2.json()['aclRules'] |
| 1493 | acl_Id2 = map(lambda d: d['id'], aclRules2) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1494 | log_test.info('Acl Ids before and after master down are %s and %s'%(acl_Id1,acl_Id2)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1495 | assert_equal(acl_Id2,acl_Id1) |
| 1496 | |
| 1497 | #acl traffic scenario not working as acl rule is not getting added to onos |
| 1498 | def test_cluster_with_acl_traffic_before_and_after_two_members_down(self,onos_instances=ONOS_INSTANCES): |
| 1499 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1500 | assert_equal(status, True) |
| 1501 | master,standbys = self.get_cluster_current_master_standbys() |
| 1502 | assert_equal(len(standbys),(onos_instances-1)) |
| 1503 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1504 | member1_onos_name = onos_names_ips[standbys[0]] |
| 1505 | member2_onos_name = onos_names_ips[standbys[1]] |
| 1506 | ingress = self.acl.ingress_iface |
| 1507 | egress = self.acl.CURRENT_PORT_NUM |
| 1508 | acl_rule = ACLTest() |
| 1509 | status, code, host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.acl.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.acl.HOST_DST_IP) |
| 1510 | self.acl.CURRENT_PORT_NUM += 1 |
| 1511 | time.sleep(5) |
| 1512 | if status is False: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1513 | log_test.info('JSON request returned status %d' %code) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1514 | assert_equal(status, True) |
| 1515 | srcMac = '00:00:00:00:00:11' |
| 1516 | dstMac = host_ip_mac[0][1] |
| 1517 | self.acl.acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress ) |
| 1518 | status, code = acl_rule.adding_acl_rule('v4', srcIp=self.acl.ACL_SRC_IP, dstIp =self.acl.ACL_DST_IP, action = 'deny',controller=master) |
| 1519 | time.sleep(10) |
| 1520 | if status is False: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1521 | log_test.info('JSON request returned status %d' %code) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1522 | assert_equal(status, True) |
| 1523 | self.acl.acl_rule_traffic_send_recv(srcMac = srcMac, dstMac = dstMac ,srcIp =self.acl.ACL_SRC_IP, dstIp = self.acl.ACL_DST_IP,ingress =ingress, egress = egress, ip_proto = 'UDP', positive_test = False) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1524 | log_test.info('killing cluster members %s and %s'%(standbys[0],standbys[1])) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1525 | Container(member1_onos_name, Onos.IMAGE).kill() |
| 1526 | Container(member2_onos_name, Onos.IMAGE).kill() |
| 1527 | time.sleep(40) |
| 1528 | status = self.verify_cluster_status(onos_instances=onos_instances-2,verify=True,controller=master) |
| 1529 | assert_equal(status, True) |
| 1530 | self.acl.acl_rule_traffic_send_recv(srcMac = srcMac, dstMac = dstMac ,srcIp =self.acl.ACL_SRC_IP, dstIp = self.acl.ACL_DST_IP,ingress =ingress, egress = egress, ip_proto = 'UDP', positive_test = False) |
| 1531 | self.acl.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress) |
| 1532 | |
| 1533 | #pass |
| 1534 | def test_cluster_with_dhcpRelay_releasing_dhcp_ip_after_master_change(self, iface = 'veth0',onos_instances=ONOS_INSTANCES): |
| 1535 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1536 | assert_equal(status, True) |
| 1537 | master,standbys = self.get_cluster_current_master_standbys() |
| 1538 | assert_equal(len(standbys),(onos_instances-1)) |
| 1539 | self.dhcprelay.setUpClass(controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1540 | mac = self.dhcprelay.get_mac(iface) |
| 1541 | self.dhcprelay.host_load(iface) |
| 1542 | ##we use the defaults for this test that serves as an example for others |
| 1543 | ##You don't need to restart dhcpd server if retaining default config |
| 1544 | config = self.dhcprelay.default_config |
| 1545 | options = self.dhcprelay.default_options |
| 1546 | subnet = self.dhcprelay.default_subnet_config |
| 1547 | dhcpd_interface_list = self.dhcprelay.relay_interfaces |
| 1548 | self.dhcprelay.dhcpd_start(intf_list = dhcpd_interface_list, |
| 1549 | config = config, |
| 1550 | options = options, |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1551 | subnet = subnet, |
| 1552 | controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1553 | self.dhcprelay.dhcp = DHCPTest(seed_ip = '10.10.100.10', iface = iface) |
| 1554 | cip, sip = self.dhcprelay.send_recv(mac) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1555 | log_test.info('Changing cluster current master from %s to %s'%(master, standbys[0])) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1556 | self.change_master_current_cluster(new_master=standbys[0]) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1557 | log_test.info('Releasing ip %s to server %s' %(cip, sip)) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1558 | assert_equal(self.dhcprelay.dhcp.release(cip), True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1559 | log_test.info('Triggering DHCP discover again after release') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1560 | cip2, sip2 = self.dhcprelay.send_recv(mac) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1561 | log_test.info('Verifying released IP was given back on rediscover') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1562 | assert_equal(cip, cip2) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1563 | log_test.info('Test done. Releasing ip %s to server %s' %(cip2, sip2)) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1564 | assert_equal(self.dhcprelay.dhcp.release(cip2), True) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1565 | self.dhcprelay.tearDownClass(controller=standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1566 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1567 | |
| 1568 | def test_cluster_with_dhcpRelay_and_verify_dhcp_ip_after_master_down(self, iface = 'veth0',onos_instances=ONOS_INSTANCES): |
| 1569 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1570 | assert_equal(status, True) |
| 1571 | master,standbys = self.get_cluster_current_master_standbys() |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1572 | assert_equal(len(standbys),(onos_instances-1)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1573 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1574 | master_onos_name = onos_names_ips[master] |
| 1575 | self.dhcprelay.setUpClass(controller=master) |
| 1576 | mac = self.dhcprelay.get_mac(iface) |
| 1577 | self.dhcprelay.host_load(iface) |
| 1578 | ##we use the defaults for this test that serves as an example for others |
| 1579 | ##You don't need to restart dhcpd server if retaining default config |
| 1580 | config = self.dhcprelay.default_config |
| 1581 | options = self.dhcprelay.default_options |
| 1582 | subnet = self.dhcprelay.default_subnet_config |
| 1583 | dhcpd_interface_list = self.dhcprelay.relay_interfaces |
| 1584 | self.dhcprelay.dhcpd_start(intf_list = dhcpd_interface_list, |
| 1585 | config = config, |
| 1586 | options = options, |
| 1587 | subnet = subnet, |
| 1588 | controller=master) |
| 1589 | self.dhcprelay.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1590 | log_test.info('Initiating dhcp process from client %s'%mac) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1591 | cip, sip = self.dhcprelay.send_recv(mac) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1592 | log_test.info('Killing cluster current master %s'%master) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1593 | Container(master_onos_name, Onos.IMAGE).kill() |
| 1594 | time.sleep(60) |
| 1595 | status = self.verify_cluster_status(onos_instances=onos_instances-1,verify=True,controller=standbys[0]) |
| 1596 | assert_equal(status, True) |
| 1597 | mac = self.dhcprelay.dhcp.get_mac(cip)[0] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1598 | log_test.info("Verifying dhcp clients gets same IP after cluster master restarts") |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1599 | new_cip, new_sip = self.dhcprelay.dhcp.only_request(cip, mac) |
| 1600 | assert_equal(new_cip, cip) |
| 1601 | self.dhcprelay.tearDownClass(controller=standbys[0]) |
| 1602 | |
| 1603 | #pass |
| 1604 | def test_cluster_with_dhcpRelay_and_simulate_client_by_changing_master(self, iface = 'veth0',onos_instances=ONOS_INSTANCES): |
| 1605 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1606 | assert_equal(status, True) |
| 1607 | master,standbys = self.get_cluster_current_master_standbys() |
| 1608 | assert_equal(len(standbys),(onos_instances-1)) |
| 1609 | self.dhcprelay.setUpClass(controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1610 | macs = ['e4:90:5e:a3:82:c1','e4:90:5e:a3:82:c2','e4:90:5e:a3:82:c3'] |
| 1611 | self.dhcprelay.host_load(iface) |
| 1612 | ##we use the defaults for this test that serves as an example for others |
| 1613 | ##You don't need to restart dhcpd server if retaining default config |
| 1614 | config = self.dhcprelay.default_config |
| 1615 | options = self.dhcprelay.default_options |
| 1616 | subnet = self.dhcprelay.default_subnet_config |
| 1617 | dhcpd_interface_list = self.dhcprelay.relay_interfaces |
| 1618 | self.dhcprelay.dhcpd_start(intf_list = dhcpd_interface_list, |
| 1619 | config = config, |
| 1620 | options = options, |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1621 | subnet = subnet, |
| 1622 | controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1623 | self.dhcprelay.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface) |
| 1624 | cip1, sip1 = self.dhcprelay.send_recv(macs[0]) |
| 1625 | assert_not_equal(cip1,None) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1626 | log_test.info('Got dhcp client IP %s for mac %s when cluster master is %s'%(cip1,macs[0],master)) |
| 1627 | log_test.info('Changing cluster master from %s to %s'%(master, standbys[0])) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1628 | self.change_master_current_cluster(new_master=standbys[0]) |
| 1629 | cip2, sip2 = self.dhcprelay.send_recv(macs[1]) |
| 1630 | assert_not_equal(cip2,None) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1631 | log_test.info('Got dhcp client IP %s for mac %s when cluster master is %s'%(cip2,macs[1],standbys[0])) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1632 | self.change_master_current_cluster(new_master=master) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1633 | log_test.info('Changing cluster master from %s to %s'%(standbys[0],master)) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1634 | cip3, sip3 = self.dhcprelay.send_recv(macs[2]) |
| 1635 | assert_not_equal(cip3,None) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1636 | log_test.info('Got dhcp client IP %s for mac %s when cluster master is %s'%(cip2,macs[2],master)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1637 | self.dhcprelay.tearDownClass(controller=standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1638 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1639 | def test_cluster_with_cord_subscriber_joining_next_channel_before_and_after_cluster_restart(self,onos_instances=ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1640 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1641 | assert_equal(status, True) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1642 | self.subscriber.setUpClass(controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1643 | self.subscriber.num_subscribers = 5 |
| 1644 | self.subscriber.num_channels = 10 |
| 1645 | for i in [0,1]: |
| 1646 | if i == 1: |
| 1647 | cord_test_onos_restart() |
| 1648 | time.sleep(45) |
| 1649 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1650 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1651 | log_test.info('Verifying cord subscriber functionality after cluster restart') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1652 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1653 | log_test.info('Verifying cord subscriber functionality before cluster restart') |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1654 | test_status = self.subscriber.subscriber_join_verify(num_subscribers = self.subscriber.num_subscribers, |
| 1655 | num_channels = self.subscriber.num_channels, |
| 1656 | cbs = (self.subscriber.tls_verify, self.subscriber.dhcp_next_verify, |
| 1657 | self.subscriber.igmp_next_verify, self.subscriber.traffic_verify), |
| 1658 | port_list = self.subscriber.generate_port_list(self.subscriber.num_subscribers, |
| 1659 | self.subscriber.num_channels)) |
| 1660 | assert_equal(test_status, True) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1661 | self.subscriber.tearDownClass(controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1662 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1663 | #not validated on cluster setup because ciena-cordigmp-multitable-2.0 app installation fails on cluster |
| 1664 | def test_cluster_with_cord_subscriber_join_next_channel_before_and_after_cluster_mastership_is_withdrawn(self,onos_instances=ONOS_INSTANCES): |
| 1665 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1666 | assert_equal(status, True) |
| 1667 | master,standbys = self.get_cluster_current_master_standbys() |
| 1668 | assert_equal(len(standbys),(onos_instances-1)) |
| 1669 | self.subscriber.setUpClass(controller=master) |
| 1670 | self.subscriber.num_subscribers = 5 |
| 1671 | self.subscriber.num_channels = 10 |
| 1672 | for i in [0,1]: |
| 1673 | if i == 1: |
| 1674 | status=self.withdraw_cluster_current_mastership(master_ip=master) |
| 1675 | asser_equal(status, True) |
| 1676 | master,standbys = self.get_cluster_current_master_standbys() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1677 | log_test.info('verifying cord subscriber functionality after cluster current master withdraw mastership') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1678 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1679 | log_test.info('verifying cord subscriber functionality before cluster master withdraw mastership') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1680 | test_status = self.subscriber.subscriber_join_verify(num_subscribers = self.subscriber.num_subscribers, |
| 1681 | num_channels = self.subscriber.num_channels, |
| 1682 | cbs = (self.subscriber.tls_verify, self.subscriber.dhcp_next_verify, |
| 1683 | self.subscriber.igmp_next_verify, self.subscriber.traffic_verify), |
| 1684 | port_list = self.subscriber.generate_port_list(self.subscriber.num_subscribers, |
| 1685 | self.subscriber.num_channels),controller=master) |
| 1686 | assert_equal(test_status, True) |
| 1687 | self.subscriber.tearDownClass(controller=master) |
| 1688 | |
| 1689 | #not validated on cluster setup because ciena-cordigmp-multitable-2.0 app installation fails on cluster |
| 1690 | def test_cluster_with_cord_subscriber_join_recv_traffic_from_10channels_and_making_one_cluster_member_down(self,onos_instances=ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1691 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1692 | assert_equal(status, True) |
| 1693 | master, standbys = self.get_cluster_current_master_standbys() |
| 1694 | assert_equal(len(standbys),(onos_instances-1)) |
| 1695 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1696 | member_onos_name = onos_names_ips[standbys[0]] |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1697 | self.subscriber.setUpClass(controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1698 | num_subscribers = 1 |
| 1699 | num_channels = 10 |
| 1700 | for i in [0,1]: |
| 1701 | if i == 1: |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 1702 | cord_test_onos_shutdown(node = standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1703 | time.sleep(30) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1704 | status = self.verify_cluster_status(onos_instances=onos_instances-1,verify=True,controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1705 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1706 | log_test.info('Verifying cord subscriber functionality after cluster member %s is down'%standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1707 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1708 | log_test.info('Verifying cord subscriber functionality before cluster member %s is down'%standbys[0]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1709 | test_status = self.subscriber.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1710 | num_channels = num_channels, |
| 1711 | cbs = (self.subscriber.tls_verify, self.subscriber.dhcp_verify, |
| 1712 | self.subscriber.igmp_verify, self.subscriber.traffic_verify), |
| 1713 | port_list = self.subscriber.generate_port_list(num_subscribers, num_channels), |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1714 | negative_subscriber_auth = 'all',controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1715 | assert_equal(test_status, True) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1716 | self.subscriber.tearDownClass(controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1717 | |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1718 | def test_cluster_with_cord_subscriber_joining_next_10channels_making_two_cluster_members_down(self,onos_instances=ONOS_INSTANCES): |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1719 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1720 | assert_equal(status, True) |
| 1721 | master, standbys = self.get_cluster_current_master_standbys() |
| 1722 | assert_equal(len(standbys),(onos_instances-1)) |
| 1723 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1724 | member1_onos_name = onos_names_ips[standbys[0]] |
| 1725 | member2_onos_name = onos_names_ips[standbys[1]] |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1726 | self.subscriber.setUpClass(controller=master) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1727 | num_subscribers = 1 |
| 1728 | num_channels = 10 |
| 1729 | for i in [0,1]: |
| 1730 | if i == 1: |
A R Karthick | 3b2e037 | 2016-12-14 17:37:43 -0800 | [diff] [blame] | 1731 | cord_test_onos_shutdown(node = standbys[0]) |
| 1732 | cord_test_onos_shutdown(node = standbys[1]) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1733 | time.sleep(60) |
| 1734 | status = self.verify_cluster_status(onos_instances=onos_instances-2) |
| 1735 | assert_equal(status, True) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1736 | log_test.info('Verifying cord subscriber funtionality after cluster two members %s and %s down'%(standbys[0],standbys[1])) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1737 | else: |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1738 | log_test.info('Verifying cord subscriber funtionality before cluster two members %s and %s down'%(standbys[0],standbys[1])) |
ChetanGaonker | 2099d72 | 2016-10-07 15:16:58 -0700 | [diff] [blame] | 1739 | test_status = self.subscriber.subscriber_join_verify(num_subscribers = num_subscribers, |
| 1740 | num_channels = num_channels, |
| 1741 | cbs = (self.subscriber.tls_verify, self.subscriber.dhcp_next_verify, |
| 1742 | self.subscriber.igmp_next_verify, self.subscriber.traffic_verify), |
| 1743 | port_list = self.subscriber.generate_port_list(num_subscribers, num_channels), |
| 1744 | negative_subscriber_auth = 'all') |
| 1745 | assert_equal(test_status, True) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1746 | self.subscriber.tearDownClass(controller=master) |
| 1747 | |
| 1748 | #pass |
| 1749 | def test_cluster_with_multiple_ovs_switches(self,onos_instances = ONOS_INSTANCES): |
| 1750 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1751 | assert_equal(status, True) |
| 1752 | device_dict = self.get_cluster_current_master_standbys_of_connected_devices() |
| 1753 | for device in device_dict.keys(): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1754 | log_test.info("Device is %s"%device_dict[device]) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1755 | assert_not_equal(device_dict[device]['master'],'none') |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1756 | log_test.info('Master and standbys for device %s are %s and %s'%(device,device_dict[device]['master'],device_dict[device]['standbys'])) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1757 | assert_equal(len(device_dict[device]['standbys']), onos_instances-1) |
| 1758 | |
| 1759 | #pass |
| 1760 | def test_cluster_state_in_multiple_ovs_switches(self,onos_instances = ONOS_INSTANCES): |
| 1761 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1762 | assert_equal(status, True) |
| 1763 | device_dict = self.get_cluster_current_master_standbys_of_connected_devices() |
| 1764 | cluster_ips = self.get_cluster_current_member_ips() |
| 1765 | for ip in cluster_ips: |
| 1766 | device_dict= self.get_cluster_current_master_standbys_of_connected_devices(controller = ip) |
| 1767 | assert_equal(len(device_dict.keys()),onos_instances) |
| 1768 | for device in device_dict.keys(): |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1769 | log_test.info("Device is %s"%device_dict[device]) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1770 | assert_not_equal(device_dict[device]['master'],'none') |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1771 | log_test.info('Master and standbys for device %s are %s and %s'%(device,device_dict[device]['master'],device_dict[device]['standbys'])) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1772 | assert_equal(len(device_dict[device]['standbys']), onos_instances-1) |
| 1773 | |
| 1774 | #pass |
| 1775 | def test_cluster_verifying_multiple_ovs_switches_after_master_is_restarted(self,onos_instances = ONOS_INSTANCES): |
| 1776 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1777 | assert_equal(status, True) |
| 1778 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1779 | master_count = self.get_number_of_devices_of_master() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1780 | log_test.info('Master count information is %s'%master_count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1781 | total_devices = 0 |
| 1782 | for master in master_count.keys(): |
| 1783 | total_devices += master_count[master]['size'] |
| 1784 | if master_count[master]['size'] != 0: |
| 1785 | restart_ip = master |
| 1786 | assert_equal(total_devices,onos_instances) |
| 1787 | member_onos_name = onos_names_ips[restart_ip] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1788 | log_test.info('Restarting cluster member %s having ip %s'%(member_onos_name,restart_ip)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1789 | Container(member_onos_name, Onos.IMAGE).restart() |
| 1790 | time.sleep(40) |
| 1791 | master_count = self.get_number_of_devices_of_master() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1792 | log_test.info('Master count information after restart is %s'%master_count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1793 | total_devices = 0 |
| 1794 | for master in master_count.keys(): |
| 1795 | total_devices += master_count[master]['size'] |
| 1796 | if master == restart_ip: |
| 1797 | assert_equal(master_count[master]['size'], 0) |
| 1798 | assert_equal(total_devices,onos_instances) |
| 1799 | |
| 1800 | #pass |
| 1801 | def test_cluster_verifying_multiple_ovs_switches_with_one_master_down(self,onos_instances = ONOS_INSTANCES): |
| 1802 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1803 | assert_equal(status, True) |
| 1804 | onos_names_ips = self.get_cluster_container_names_ips() |
| 1805 | master_count = self.get_number_of_devices_of_master() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1806 | log_test.info('Master count information is %s'%master_count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1807 | total_devices = 0 |
| 1808 | for master in master_count.keys(): |
| 1809 | total_devices += master_count[master]['size'] |
| 1810 | if master_count[master]['size'] != 0: |
| 1811 | restart_ip = master |
| 1812 | assert_equal(total_devices,onos_instances) |
| 1813 | master_onos_name = onos_names_ips[restart_ip] |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1814 | log_test.info('Shutting down cluster member %s having ip %s'%(master_onos_name,restart_ip)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1815 | Container(master_onos_name, Onos.IMAGE).kill() |
| 1816 | time.sleep(40) |
| 1817 | for ip in onos_names_ips.keys(): |
| 1818 | if ip != restart_ip: |
| 1819 | controller_ip = ip |
| 1820 | status = self.verify_cluster_status(onos_instances=onos_instances-1,controller=controller_ip) |
| 1821 | assert_equal(status, True) |
| 1822 | master_count = self.get_number_of_devices_of_master(controller=controller_ip) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1823 | log_test.info('Master count information after restart is %s'%master_count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1824 | total_devices = 0 |
| 1825 | for master in master_count.keys(): |
| 1826 | total_devices += master_count[master]['size'] |
| 1827 | if master == restart_ip: |
| 1828 | assert_equal(master_count[master]['size'], 0) |
| 1829 | assert_equal(total_devices,onos_instances) |
| 1830 | |
| 1831 | #pass |
| 1832 | def test_cluster_verifying_multiple_ovs_switches_with_current_master_withdrawing_mastership(self,onos_instances = ONOS_INSTANCES): |
| 1833 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1834 | assert_equal(status, True) |
| 1835 | master_count = self.get_number_of_devices_of_master() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1836 | log_test.info('Master count information is %s'%master_count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1837 | total_devices = 0 |
| 1838 | for master in master_count.keys(): |
| 1839 | total_devices += int(master_count[master]['size']) |
| 1840 | if master_count[master]['size'] != 0: |
| 1841 | master_ip = master |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1842 | log_test.info('Devices of master %s are %s'%(master_count[master]['devices'],master)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1843 | device_id = str(master_count[master]['devices'][0]) |
| 1844 | device_count = master_count[master]['size'] |
| 1845 | assert_equal(total_devices,onos_instances) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1846 | log_test.info('Withdrawing mastership of device %s for controller %s'%(device_id,master_ip)) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1847 | status=self.withdraw_cluster_current_mastership(master_ip=master_ip,device_id = device_id) |
| 1848 | assert_equal(status, True) |
| 1849 | master_count = self.get_number_of_devices_of_master() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1850 | log_test.info('Master count information after cluster mastership withdraw is %s'%master_count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1851 | total_devices = 0 |
| 1852 | for master in master_count.keys(): |
| 1853 | total_devices += int(master_count[master]['size']) |
| 1854 | if master == master_ip: |
| 1855 | assert_equal(master_count[master]['size'], device_count-1) |
| 1856 | assert_equal(total_devices,onos_instances) |
| 1857 | |
| 1858 | #pass |
| 1859 | def test_cluster_verifying_multiple_ovs_switches_and_restarting_cluster(self,onos_instances = ONOS_INSTANCES): |
| 1860 | status = self.verify_cluster_status(onos_instances=onos_instances) |
| 1861 | assert_equal(status, True) |
| 1862 | master_count = self.get_number_of_devices_of_master() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1863 | log_test.info('Master count information is %s'%master_count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1864 | total_devices = 0 |
| 1865 | for master in master_count.keys(): |
| 1866 | total_devices += master_count[master]['size'] |
| 1867 | assert_equal(total_devices,onos_instances) |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1868 | log_test.info('Restarting cluster') |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1869 | cord_test_onos_restart() |
| 1870 | time.sleep(60) |
| 1871 | master_count = self.get_number_of_devices_of_master() |
A R Karthick | 76a497a | 2017-04-12 10:59:39 -0700 | [diff] [blame] | 1872 | log_test.info('Master count information after restart is %s'%master_count) |
ChetanGaonker | 689b386 | 2016-10-17 16:25:01 -0700 | [diff] [blame] | 1873 | total_devices = 0 |
| 1874 | for master in master_count.keys(): |
| 1875 | total_devices += master_count[master]['size'] |
| 1876 | assert_equal(total_devices,onos_instances) |