andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1 | #TopoPerfNext |
| 2 | # |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 3 | #Topology Convergence scale-out test for ONOS-next |
| 4 | #NOTE: This test supports up to 7 nodes scale-out scenario |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 5 | # |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 6 | #NOTE: Ensure that you have 'tablet.json' file |
| 7 | # in the onos/tools/package/config directory |
| 8 | #NOTE: You must start this test initially with 3 nodes |
| 9 | # |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 10 | #andrew@onlab.us |
| 11 | |
| 12 | import time |
| 13 | import sys |
| 14 | import os |
| 15 | import re |
| 16 | |
| 17 | class TopoConvNext: |
| 18 | def __init__(self): |
| 19 | self.default = '' |
| 20 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 21 | def CASE1(self, main): |
| 22 | ''' |
| 23 | ONOS startup sequence |
| 24 | ''' |
| 25 | import time |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 26 | |
| 27 | #****** |
| 28 | #Global cluster count for scale-out purposes |
| 29 | global cluster_count |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 30 | global topo_iteration |
| 31 | topo_iteration = 1 |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 32 | cluster_count = 3 |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 33 | #****** |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 34 | cell_name = main.params['ENV']['cellName'] |
| 35 | |
| 36 | git_pull = main.params['GIT']['autoPull'] |
| 37 | checkout_branch = main.params['GIT']['checkout'] |
| 38 | |
| 39 | ONOS1_ip = main.params['CTRL']['ip1'] |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 40 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 41 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 42 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 43 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 44 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 45 | ONOS7_ip = main.params['CTRL']['ip7'] |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 46 | MN1_ip = main.params['MN']['ip1'] |
| 47 | BENCH_ip = main.params['BENCH']['ip'] |
| 48 | |
| 49 | main.case("Setting up test environment") |
andrewonlab | c185052 | 2014-11-21 12:07:33 -0500 | [diff] [blame] | 50 | main.log.info("copying topology event accumulator config file"+\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 51 | " to ONOS package/etc/ directory") |
| 52 | topo_config_name = main.params['TEST']['topo_config_name'] |
| 53 | topo_config =\ |
| 54 | main.params['TEST']['topo_accumulator_config'] |
andrewonlab | c185052 | 2014-11-21 12:07:33 -0500 | [diff] [blame] | 55 | main.ONOSbench.handle.sendline("cp ~/"+topo_config+\ |
| 56 | " ~/ONOS/tools/package/etc/"+\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 57 | topo_config_name) |
| 58 | main.ONOSbench.handle.expect("\$") |
| 59 | |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 60 | main.log.info("Uninstalling previous instances") |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 61 | #main.ONOSbench.onos_uninstall(node_ip = ONOS1_ip) |
| 62 | #main.ONOSbench.onos_uninstall(node_ip = ONOS2_ip) |
| 63 | #main.ONOSbench.onos_uninstall(node_ip = ONOS3_ip) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 64 | main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip) |
| 65 | main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip) |
| 66 | main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip) |
| 67 | main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip) |
| 68 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 69 | main.log.report("Setting up test environment") |
| 70 | |
| 71 | main.step("Creating cell file") |
| 72 | cell_file_result = main.ONOSbench.create_cell_file( |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 73 | BENCH_ip, cell_name, MN1_ip, |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 74 | "onos-core,onos-app-metrics", |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 75 | ONOS1_ip, ONOS2_ip, ONOS3_ip) |
| 76 | #ONOS1_ip) |
| 77 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 78 | main.step("Applying cell file to environment") |
| 79 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
| 80 | verify_cell_result = main.ONOSbench.verify_cell() |
| 81 | |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 82 | main.step("Removing raft logs") |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 83 | main.ONOSbench.onos_remove_raft_logs() |
| 84 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 85 | main.step("Git checkout and pull "+checkout_branch) |
| 86 | if git_pull == 'on': |
| 87 | checkout_result = \ |
| 88 | main.ONOSbench.git_checkout(checkout_branch) |
| 89 | pull_result = main.ONOSbench.git_pull() |
| 90 | else: |
| 91 | checkout_result = main.TRUE |
| 92 | pull_result = main.TRUE |
| 93 | main.log.info("Skipped git checkout and pull") |
| 94 | |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 95 | main.log.report("Commit information - ") |
| 96 | main.ONOSbench.get_version() |
| 97 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 98 | main.step("Using mvn clean & install") |
| 99 | #mvn_result = main.ONOSbench.clean_install() |
| 100 | mvn_result = main.TRUE |
| 101 | |
| 102 | main.step("Set cell for ONOS cli env") |
| 103 | main.ONOS1cli.set_cell(cell_name) |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 104 | main.ONOS2cli.set_cell(cell_name) |
| 105 | main.ONOS3cli.set_cell(cell_name) |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 106 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 107 | main.step("Creating ONOS package") |
| 108 | package_result = main.ONOSbench.onos_package() |
| 109 | |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 110 | #Start test with single node only |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 111 | main.step("Installing ONOS package") |
| 112 | install1_result = main.ONOSbench.onos_install(node=ONOS1_ip) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 113 | install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 114 | install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 115 | |
| 116 | time.sleep(10) |
| 117 | |
| 118 | main.step("Start onos cli") |
| 119 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 120 | cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 121 | cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 122 | |
| 123 | main.step("Enable metrics feature") |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 124 | #main.ONOS1cli.feature_install("onos-app-metrics") |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 125 | |
| 126 | utilities.assert_equals(expect=main.TRUE, |
| 127 | actual= cell_file_result and cell_apply_result and\ |
| 128 | verify_cell_result and checkout_result and\ |
| 129 | pull_result and mvn_result and\ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 130 | install1_result and install2_result and\ |
| 131 | install3_result, |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 132 | onpass="Test Environment setup successful", |
| 133 | onfail="Failed to setup test environment") |
| 134 | |
| 135 | def CASE2(self, main): |
| 136 | ''' |
| 137 | 100 Switch discovery latency |
| 138 | |
| 139 | Important: |
| 140 | This test case can be potentially dangerous if |
| 141 | your machine has previously set iptables rules. |
| 142 | One of the steps of the test case will flush |
| 143 | all existing iptables rules. |
| 144 | Note: |
| 145 | You can specify the number of switches in the |
| 146 | params file to adjust the switch discovery size |
| 147 | (and specify the corresponding topology in Mininet1 |
| 148 | .topo file) |
| 149 | ''' |
| 150 | import time |
| 151 | import subprocess |
| 152 | import os |
| 153 | import requests |
| 154 | import json |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 155 | import numpy |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 156 | |
| 157 | ONOS_ip_list = [] |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 158 | ONOS_ip_list.append('0') |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 159 | ONOS_ip_list.append(main.params['CTRL']['ip1']) |
| 160 | ONOS_ip_list.append(main.params['CTRL']['ip2']) |
| 161 | ONOS_ip_list.append(main.params['CTRL']['ip3']) |
| 162 | ONOS_ip_list.append(main.params['CTRL']['ip4']) |
| 163 | ONOS_ip_list.append(main.params['CTRL']['ip5']) |
| 164 | ONOS_ip_list.append(main.params['CTRL']['ip6']) |
| 165 | ONOS_ip_list.append(main.params['CTRL']['ip7']) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 166 | MN1_ip = main.params['MN']['ip1'] |
| 167 | ONOS_user = main.params['CTRL']['user'] |
| 168 | |
| 169 | default_sw_port = main.params['CTRL']['port1'] |
| 170 | |
| 171 | #Number of iterations of case |
| 172 | num_iter = main.params['TEST']['numIter'] |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 173 | iter_ignore = int(main.params['TEST']['iterIgnore']) |
| 174 | |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 175 | #*********** |
| 176 | #Global number of switches that change |
| 177 | #throughout the test |
| 178 | global num_sw |
| 179 | global topo_iteration |
| 180 | if topo_iteration == 1: |
| 181 | num_sw = main.params['TEST']['numSwitch1'] |
| 182 | elif topo_iteration == 2: |
| 183 | num_sw = main.params['TEST']['numSwitch2'] |
| 184 | elif topo_iteration == 3: |
| 185 | num_sw = main.params['TEST']['numSwitch3'] |
| 186 | #*********** |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 187 | |
| 188 | #Timestamp 'keys' for json metrics output. |
| 189 | #These are subject to change, hence moved into params |
| 190 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
| 191 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
| 192 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 193 | #Threshold for this test case |
| 194 | sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold'] |
| 195 | sw_disc_threshold_obj = sw_disc_threshold_str.split(",") |
| 196 | sw_disc_threshold_min = int(sw_disc_threshold_obj[0]) |
| 197 | sw_disc_threshold_max = int(sw_disc_threshold_obj[1]) |
| 198 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 199 | assertion = main.TRUE |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 200 | sw_discovery_lat_list = [] |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 201 | syn_ack_delta_list = [] |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 202 | |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 203 | main.case(str(num_sw)+" switches distributed across "+ |
| 204 | str(cluster_count)+" nodes convergence latency") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 205 | |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 206 | main.log.report("Large topology convergence and scale-out test") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 207 | main.log.report("Currently active ONOS node(s): ") |
| 208 | report_str = "Node " |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 209 | for node in range(1, cluster_count+1): |
| 210 | report_str += (str(node) + " ") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 211 | main.log.report(report_str) |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 212 | main.log.report("Topology size: "+str(num_sw)+" switches") |
| 213 | |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 214 | main.step("Distributing "+num_sw+" switches to each ONOS") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 215 | index = 1 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 216 | for node in range(1, cluster_count+1): |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 217 | for i in range(index, (int(num_sw)/cluster_count)+index): |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 218 | main.Mininet1.assign_sw_controller( |
| 219 | sw=str(i), |
| 220 | ip1=ONOS_ip_list[node], |
| 221 | port1=default_sw_port) |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 222 | index = i+1 |
| 223 | |
| 224 | main.log.info("Please check ptpd configuration to ensure "+\ |
| 225 | "all nodes' system times are in sync") |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 226 | |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 227 | time.sleep(10) |
| 228 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 229 | for i in range(0, int(num_iter)): |
| 230 | main.step("Set iptables rule to block sw connections") |
| 231 | |
| 232 | #INPUT rules |
| 233 | main.ONOS1.handle.sendline( |
| 234 | "sudo iptables -A INPUT -p tcp -s "+ |
| 235 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 236 | main.ONOS2.handle.sendline( |
| 237 | "sudo iptables -A INPUT -p tcp -s "+ |
| 238 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 239 | main.ONOS3.handle.sendline( |
| 240 | "sudo iptables -A INPUT -p tcp -s "+ |
| 241 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 242 | main.ONOS4.handle.sendline( |
| 243 | "sudo iptables -A INPUT -p tcp -s "+ |
| 244 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 245 | main.ONOS5.handle.sendline( |
| 246 | "sudo iptables -A INPUT -p tcp -s "+ |
| 247 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 248 | main.ONOS6.handle.sendline( |
| 249 | "sudo iptables -A INPUT -p tcp -s "+ |
| 250 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 251 | main.ONOS7.handle.sendline( |
| 252 | "sudo iptables -A INPUT -p tcp -s "+ |
| 253 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 254 | |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 255 | #OUTPUT rules |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 256 | main.ONOS1.handle.sendline( |
| 257 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 258 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 259 | main.ONOS2.handle.sendline( |
| 260 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 261 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 262 | main.ONOS3.handle.sendline( |
| 263 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 264 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 265 | main.ONOS4.handle.sendline( |
| 266 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 267 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 268 | main.ONOS5.handle.sendline( |
| 269 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 270 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 271 | main.ONOS6.handle.sendline( |
| 272 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 273 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 274 | main.ONOS7.handle.sendline( |
| 275 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 276 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 277 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 278 | main.log.info("Please wait for switch connection to timeout") |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 279 | |
| 280 | |
| 281 | #time.sleep(60) |
| 282 | #if cluster_count >= 3: |
| 283 | # time.sleep(60) |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 284 | #if cluster_count >= 5: |
| 285 | # time.sleep(30) |
| 286 | #if cluster_count >= 6: |
| 287 | # time.sleep(30) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 288 | |
| 289 | if cluster_count >= 3: |
| 290 | main.ONOS1.tshark_grep("SYN, ACK", |
| 291 | "/tmp/syn_ack_onos1_iter"+str(i)+".txt") |
| 292 | main.ONOS2.tshark_grep("SYN, ACK", |
| 293 | "/tmp/syn_ack_onos2_iter"+str(i)+".txt") |
| 294 | main.ONOS3.tshark_grep("SYN, ACK", |
| 295 | "/tmp/syn_ack_onos3_iter"+str(i)+".txt") |
| 296 | if cluster_count >= 4: |
| 297 | main.ONOS4.tshark_grep("SYN, ACK", |
| 298 | "/tmp/syn_ack_onos4_iter"+str(i)+".txt") |
| 299 | if cluster_count >= 5: |
| 300 | main.ONOS5.tshark_grep("SYN, ACK", |
| 301 | "/tmp/syn_ack_onos5_iter"+str(i)+".txt") |
| 302 | if cluster_count >= 6: |
| 303 | main.ONOS6.tshark_grep("SYN, ACK", |
| 304 | "/tmp/syn_ack_onos6_iter"+str(i)+".txt") |
| 305 | if cluster_count == 7: |
| 306 | main.ONOS7.tshark_grep("SYN, ACK", |
| 307 | "/tmp/syn_ack_onos7_iter"+str(i)+".txt") |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 308 | |
| 309 | loop_count = 0 |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 310 | device_count1 = 0 |
| 311 | device_count2 = 0 |
| 312 | device_count3 = 0 |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 313 | while loop_count < 60: |
| 314 | main.log.info("Checking devices for device down") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 315 | device_str1 = main.ONOS1cli.devices( |
| 316 | node_ip=ONOS_ip_list[1]) |
| 317 | device_json1 = json.loads(device_str1) |
| 318 | |
| 319 | #TODO: Modular check of all nodes for |
| 320 | # device down discovery |
| 321 | |
| 322 | #device_str2 = main.ONOS2cli.devices( |
| 323 | # node_ip=ONOS_ip_list[2]) |
| 324 | #device_json2 = json.loads(device_str2) |
| 325 | #device_str3 = main.ONOS3cli.devices( |
| 326 | # node_ip=ONOS_ip_list[3]) |
| 327 | #device_json3 = json.loads(device_str3) |
| 328 | for device1 in device_json1: |
| 329 | if device1['available'] == False: |
| 330 | device_count1 += 1 |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 331 | else: |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 332 | device_count1 = 0 |
| 333 | #for device2 in device_json2: |
| 334 | # if device2['available'] == False: |
| 335 | # print device_count2 |
| 336 | # device_count2 += 1 |
| 337 | # else: |
| 338 | # device_count2 = 0 |
| 339 | #for device3 in device_json3: |
| 340 | # if device3['available'] == False: |
| 341 | # print device_count3 |
| 342 | # device_count3 += 1 |
| 343 | # else: |
| 344 | # device_count3 = 0 |
| 345 | |
| 346 | if device_count1\ |
| 347 | >= int(num_sw)*int(cluster_count): |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 348 | main.step("Flushing iptables and obtaining t0") |
| 349 | t0_system = time.time()*1000 |
| 350 | main.ONOS1.handle.sendline("sudo iptables -F") |
| 351 | main.ONOS2.handle.sendline("sudo iptables -F") |
| 352 | main.ONOS3.handle.sendline("sudo iptables -F") |
| 353 | main.ONOS4.handle.sendline("sudo iptables -F") |
| 354 | main.ONOS5.handle.sendline("sudo iptables -F") |
| 355 | main.ONOS6.handle.sendline("sudo iptables -F") |
| 356 | main.ONOS7.handle.sendline("sudo iptables -F") |
| 357 | |
| 358 | break |
| 359 | |
| 360 | time.sleep(1) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 361 | |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 362 | main.log.info("System time t0: "+str(t0_system)) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 363 | |
| 364 | counter_loop = 0 |
| 365 | counter_avail1 = 0 |
| 366 | counter_avail2 = 0 |
| 367 | counter_avail3 = 0 |
| 368 | counter_avail4 = 0 |
| 369 | counter_avail5 = 0 |
| 370 | counter_avail6 = 0 |
| 371 | counter_avail7 = 0 |
| 372 | onos1_dev = False |
| 373 | onos2_dev = False |
| 374 | onos3_dev = False |
| 375 | onos4_dev = False |
| 376 | onos5_dev = False |
| 377 | onos6_dev = False |
| 378 | onos7_dev = False |
| 379 | |
| 380 | #TODO: Think of a more elegant way to check all |
| 381 | # switches across all nodes |
| 382 | #Goodluck debugging this loop |
| 383 | while counter_loop < 60: |
| 384 | for node in range(1, cluster_count+1): |
| 385 | if node == 1 and not onos1_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 386 | main.log.info("Checking node 1 for device "+ |
| 387 | "discovery") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 388 | device_str_obj1 = main.ONOS1cli.devices( |
| 389 | node_ip=ONOS_ip_list[1]) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 390 | device_json1 = json.loads(device_str_obj1) |
| 391 | for device1 in device_json1: |
| 392 | if device1['available'] == True: |
| 393 | counter_avail1 += 1 |
| 394 | if counter_avail1 == int(num_sw): |
| 395 | onos1_dev = True |
| 396 | main.log.info("All devices have been"+ |
| 397 | " discovered on ONOS1") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 398 | else: |
| 399 | counter_avail1 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 400 | if node == 2 and not onos2_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 401 | main.log.info("Checking node 2 for device "+ |
| 402 | "discovery") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 403 | device_str_obj2 = main.ONOS2cli.devices( |
| 404 | node_ip=ONOS_ip_list[2]) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 405 | device_json2 = json.loads(device_str_obj2) |
| 406 | for device2 in device_json2: |
| 407 | if device2['available'] == True: |
| 408 | counter_avail2 += 1 |
| 409 | if counter_avail2 == int(num_sw): |
| 410 | onos2_dev = True |
| 411 | main.log.info("All devices have been"+ |
| 412 | " discovered on ONOS2") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 413 | else: |
| 414 | counter_avail2 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 415 | if node == 3 and not onos3_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 416 | main.log.info("Checking node 3 for device "+ |
| 417 | "discovery") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 418 | device_str_obj3 = main.ONOS3cli.devices( |
| 419 | node_ip=ONOS_ip_list[3]) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 420 | device_json3 = json.loads(device_str_obj3) |
| 421 | for device3 in device_json3: |
| 422 | if device3['available'] == True: |
| 423 | counter_avail3 += 1 |
| 424 | if counter_avail3 == int(num_sw): |
| 425 | onos3_dev = True |
| 426 | main.log.info("All devices have been"+ |
| 427 | " discovered on ONOS3") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 428 | else: |
| 429 | counter_avail3 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 430 | if node == 4 and not onos4_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 431 | main.log.info("Checking node 4 for device "+ |
| 432 | "discovery") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 433 | device_str_obj4 = main.ONOS4cli.devices( |
| 434 | node_ip=ONOS_ip_list[4]) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 435 | device_json4 = json.loads(device_str_obj4) |
| 436 | for device4 in device_json4: |
| 437 | if device4['available'] == True: |
| 438 | counter_avail4 += 1 |
| 439 | if counter_avail4 == int(num_sw): |
| 440 | onos4_dev = True |
| 441 | main.log.info("All devices have been"+ |
| 442 | " discovered on ONOS4") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 443 | else: |
| 444 | counter_avail4 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 445 | if node == 5 and not onos5_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 446 | main.log.info("Checking node 5 for device "+ |
| 447 | "discovery") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 448 | device_str_obj5 = main.ONOS5cli.devices( |
| 449 | node_ip=ONOS_ip_list[5]) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 450 | device_json5 = json.loads(device_str_obj5) |
| 451 | for device5 in device_json5: |
| 452 | if device5['available'] == True: |
| 453 | counter_avail5 += 1 |
| 454 | if counter_avail5 == int(num_sw): |
| 455 | onos5_dev = True |
| 456 | main.log.info("All devices have been"+ |
| 457 | " discovered on ONOS5") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 458 | else: |
| 459 | counter_avail5 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 460 | if node == 6 and not onos6_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 461 | main.log.info("Checking node 6 for device "+ |
| 462 | "discovery") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 463 | device_str_obj6 = main.ONOS6cli.devices( |
| 464 | node_ip=ONOS_ip_list[6]) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 465 | device_json6 = json.loads(device_str_obj6) |
| 466 | for device6 in device_json6: |
| 467 | if device6['available'] == True: |
| 468 | counter_avail6 += 1 |
| 469 | if counter_avail6 == int(num_sw): |
| 470 | onos6_dev = True |
| 471 | main.log.info("All devices have been"+ |
| 472 | " discovered on ONOS6") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 473 | else: |
| 474 | counter_avail6 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 475 | if node == 7 and not onos7_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 476 | main.log.info("Checking node 7 for device "+ |
| 477 | "discovery") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 478 | device_str_obj7 = main.ONOS7cli.devices( |
| 479 | node_ip=ONOS_ip_list[7]) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 480 | device_json7 = json.loads(device_str_obj7) |
| 481 | for device7 in device_json7: |
| 482 | if device7['available'] == True: |
| 483 | counter_avail7 += 1 |
| 484 | if counter_avail7 == int(num_sw): |
| 485 | onos7_dev = True |
| 486 | main.log.info("All devices have been"+ |
| 487 | " discovered on ONOS7") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 488 | else: |
| 489 | counter_avail7 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 490 | #END node loop |
| 491 | |
| 492 | #TODO: clean up this mess of an if statements if possible |
| 493 | #Treat each if as a separate test case with the given |
| 494 | # cluster count. Hence when the cluster count changes |
| 495 | # the desired calculations will be made |
| 496 | if cluster_count == 1: |
| 497 | if onos1_dev: |
| 498 | main.log.info("All devices have been discovered"+ |
| 499 | " on all ONOS instances") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 500 | time.sleep(5) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 501 | json_str_metrics_1 =\ |
| 502 | main.ONOS1cli.topology_events_metrics() |
| 503 | json_obj_1 = json.loads(json_str_metrics_1) |
| 504 | graph_timestamp_1 =\ |
| 505 | json_obj_1[graphTimestamp]['value'] |
| 506 | |
| 507 | graph_lat_1 = \ |
| 508 | int(graph_timestamp_1) - int(t0_system) |
| 509 | |
| 510 | if graph_lat_1 > sw_disc_threshold_min\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 511 | and graph_lat_1 < sw_disc_threshold_max\ |
| 512 | and int(i) > iter_ignore: |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 513 | sw_discovery_lat_list.append( |
| 514 | graph_lat_1) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 515 | main.log.info("Sw discovery latency of "+ |
| 516 | str(cluster_count)+" node(s): "+ |
| 517 | str(graph_lat_1)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 518 | else: |
| 519 | main.log.info("Switch discovery latency "+ |
| 520 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 521 | main.log.info(graph_lat_1) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 522 | #Break while loop |
| 523 | break |
| 524 | if cluster_count == 2: |
| 525 | if onos1_dev and onos2_dev: |
| 526 | main.log.info("All devices have been discovered"+ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 527 | " on all "+str(cluster_count)+ |
| 528 | " ONOS instances") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 529 | time.sleep(5) |
| 530 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 531 | json_str_metrics_1 =\ |
| 532 | main.ONOS1cli.topology_events_metrics() |
| 533 | json_str_metrics_2 =\ |
| 534 | main.ONOS2cli.topology_events_metrics() |
| 535 | json_obj_1 = json.loads(json_str_metrics_1) |
| 536 | json_obj_2 = json.loads(json_str_metrics_2) |
| 537 | graph_timestamp_1 =\ |
| 538 | json_obj_1[graphTimestamp]['value'] |
| 539 | graph_timestamp_2 =\ |
| 540 | json_obj_2[graphTimestamp]['value'] |
| 541 | |
| 542 | graph_lat_1 = \ |
| 543 | int(graph_timestamp_1) - int(t0_system) |
| 544 | graph_lat_2 = \ |
| 545 | int(graph_timestamp_2) - int(t0_system) |
| 546 | |
| 547 | avg_graph_lat = \ |
| 548 | (int(graph_lat_1) +\ |
| 549 | int(graph_lat_2)) / 2 |
| 550 | |
| 551 | if avg_graph_lat > sw_disc_threshold_min\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 552 | and avg_graph_lat < sw_disc_threshold_max\ |
| 553 | and int(i) > iter_ignore: |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 554 | sw_discovery_lat_list.append( |
| 555 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 556 | main.log.info("Sw discovery latency of "+ |
| 557 | str(cluster_count)+" node(s): "+ |
| 558 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 559 | else: |
| 560 | main.log.info("Switch discovery latency "+ |
| 561 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 562 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 563 | break |
| 564 | if cluster_count == 3: |
| 565 | if onos1_dev and onos2_dev and onos3_dev: |
| 566 | main.log.info("All devices have been discovered"+ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 567 | " on all "+str(cluster_count)+ |
| 568 | " ONOS instances") |
| 569 | |
| 570 | #TODO: Investigate this sleep |
| 571 | # added to 'pad' the results with |
| 572 | # plenty of time to 'catch up' |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 573 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 574 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 575 | json_str_metrics_1 =\ |
| 576 | main.ONOS1cli.topology_events_metrics() |
| 577 | json_str_metrics_2 =\ |
| 578 | main.ONOS2cli.topology_events_metrics() |
| 579 | json_str_metrics_3 =\ |
| 580 | main.ONOS3cli.topology_events_metrics() |
| 581 | json_obj_1 = json.loads(json_str_metrics_1) |
| 582 | json_obj_2 = json.loads(json_str_metrics_2) |
| 583 | json_obj_3 = json.loads(json_str_metrics_3) |
| 584 | graph_timestamp_1 =\ |
| 585 | json_obj_1[graphTimestamp]['value'] |
| 586 | graph_timestamp_2 =\ |
| 587 | json_obj_2[graphTimestamp]['value'] |
| 588 | graph_timestamp_3 =\ |
| 589 | json_obj_3[graphTimestamp]['value'] |
| 590 | |
| 591 | graph_lat_1 = \ |
| 592 | int(graph_timestamp_1) - int(t0_system) |
| 593 | graph_lat_2 = \ |
| 594 | int(graph_timestamp_2) - int(t0_system) |
| 595 | graph_lat_3 = \ |
| 596 | int(graph_timestamp_3) - int(t0_system) |
| 597 | |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 598 | main.log.info("DEBUG: graph_timestamp_1: "+ |
| 599 | str(graph_timestamp_1)) |
| 600 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 601 | avg_graph_lat = \ |
| 602 | (int(graph_lat_1) +\ |
| 603 | int(graph_lat_2) +\ |
| 604 | int(graph_lat_3)) / 3 |
| 605 | |
| 606 | if avg_graph_lat > sw_disc_threshold_min\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 607 | and avg_graph_lat < sw_disc_threshold_max\ |
| 608 | and int(i) > iter_ignore: |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 609 | sw_discovery_lat_list.append( |
| 610 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 611 | main.log.info("Sw discovery latency of "+ |
| 612 | str(cluster_count)+" node(s): "+ |
| 613 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 614 | else: |
| 615 | main.log.info("Switch discovery latency "+ |
| 616 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 617 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 618 | |
| 619 | break |
| 620 | if cluster_count == 4: |
| 621 | if onos1_dev and onos2_dev and onos3_dev and\ |
| 622 | onos4_dev: |
| 623 | main.log.info("All devices have been discovered"+ |
| 624 | " on all ONOS instances") |
| 625 | json_str_metrics_1 =\ |
| 626 | main.ONOS1cli.topology_events_metrics() |
| 627 | json_str_metrics_2 =\ |
| 628 | main.ONOS2cli.topology_events_metrics() |
| 629 | json_str_metrics_3 =\ |
| 630 | main.ONOS3cli.topology_events_metrics() |
| 631 | json_str_metrics_4 =\ |
| 632 | main.ONOS4cli.topology_events_metrics() |
| 633 | json_obj_1 = json.loads(json_str_metrics_1) |
| 634 | json_obj_2 = json.loads(json_str_metrics_2) |
| 635 | json_obj_3 = json.loads(json_str_metrics_3) |
| 636 | json_obj_4 = json.loads(json_str_metrics_4) |
| 637 | graph_timestamp_1 =\ |
| 638 | json_obj_1[graphTimestamp]['value'] |
| 639 | graph_timestamp_2 =\ |
| 640 | json_obj_2[graphTimestamp]['value'] |
| 641 | graph_timestamp_3 =\ |
| 642 | json_obj_3[graphTimestamp]['value'] |
| 643 | graph_timestamp_4 =\ |
| 644 | json_obj_4[graphTimestamp]['value'] |
| 645 | |
| 646 | graph_lat_1 = \ |
| 647 | int(graph_timestamp_1) - int(t0_system) |
| 648 | graph_lat_2 = \ |
| 649 | int(graph_timestamp_2) - int(t0_system) |
| 650 | graph_lat_3 = \ |
| 651 | int(graph_timestamp_3) - int(t0_system) |
| 652 | graph_lat_4 = \ |
| 653 | int(graph_timestamp_4) - int(t0_system) |
| 654 | |
| 655 | avg_graph_lat = \ |
| 656 | (int(graph_lat_1) +\ |
| 657 | int(graph_lat_2) +\ |
| 658 | int(graph_lat_3) +\ |
| 659 | int(graph_lat_4)) / 4 |
| 660 | |
| 661 | if avg_graph_lat > sw_disc_threshold_min\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 662 | and avg_graph_lat < sw_disc_threshold_max\ |
| 663 | and int(i) > iter_ignore: |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 664 | sw_discovery_lat_list.append( |
| 665 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 666 | main.log.info("Sw discovery latency of "+ |
| 667 | str(cluster_count)+" node(s): "+ |
| 668 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 669 | else: |
| 670 | main.log.info("Switch discovery latency "+ |
| 671 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 672 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 673 | |
| 674 | break |
| 675 | if cluster_count == 5: |
| 676 | if onos1_dev and onos2_dev and onos3_dev and\ |
| 677 | onos4_dev and onos5_dev: |
| 678 | main.log.info("All devices have been discovered"+ |
| 679 | " on all ONOS instances") |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 680 | |
| 681 | #TODO: Investigate this sleep |
| 682 | # added to 'pad' the results with |
| 683 | # plenty of time to 'catch up' |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 684 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 685 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 686 | json_str_metrics_1 =\ |
| 687 | main.ONOS1cli.topology_events_metrics() |
| 688 | json_str_metrics_2 =\ |
| 689 | main.ONOS2cli.topology_events_metrics() |
| 690 | json_str_metrics_3 =\ |
| 691 | main.ONOS3cli.topology_events_metrics() |
| 692 | json_str_metrics_4 =\ |
| 693 | main.ONOS4cli.topology_events_metrics() |
| 694 | json_str_metrics_5 =\ |
| 695 | main.ONOS5cli.topology_events_metrics() |
| 696 | json_obj_1 = json.loads(json_str_metrics_1) |
| 697 | json_obj_2 = json.loads(json_str_metrics_2) |
| 698 | json_obj_3 = json.loads(json_str_metrics_3) |
| 699 | json_obj_4 = json.loads(json_str_metrics_4) |
| 700 | json_obj_5 = json.loads(json_str_metrics_5) |
| 701 | graph_timestamp_1 =\ |
| 702 | json_obj_1[graphTimestamp]['value'] |
| 703 | graph_timestamp_2 =\ |
| 704 | json_obj_2[graphTimestamp]['value'] |
| 705 | graph_timestamp_3 =\ |
| 706 | json_obj_3[graphTimestamp]['value'] |
| 707 | graph_timestamp_4 =\ |
| 708 | json_obj_4[graphTimestamp]['value'] |
| 709 | graph_timestamp_5 =\ |
| 710 | json_obj_5[graphTimestamp]['value'] |
| 711 | |
| 712 | graph_lat_1 = \ |
| 713 | int(graph_timestamp_1) - int(t0_system) |
| 714 | graph_lat_2 = \ |
| 715 | int(graph_timestamp_2) - int(t0_system) |
| 716 | graph_lat_3 = \ |
| 717 | int(graph_timestamp_3) - int(t0_system) |
| 718 | graph_lat_4 = \ |
| 719 | int(graph_timestamp_4) - int(t0_system) |
| 720 | graph_lat_5 = \ |
| 721 | int(graph_timestamp_5) - int(t0_system) |
| 722 | |
| 723 | avg_graph_lat = \ |
| 724 | (int(graph_lat_1) +\ |
| 725 | int(graph_lat_2) +\ |
| 726 | int(graph_lat_3) +\ |
| 727 | int(graph_lat_4) +\ |
| 728 | int(graph_lat_5)) / 5 |
| 729 | |
| 730 | if avg_graph_lat > sw_disc_threshold_min\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 731 | and avg_graph_lat < sw_disc_threshold_max\ |
| 732 | and int(i) > iter_ignore: |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 733 | sw_discovery_lat_list.append( |
| 734 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 735 | main.log.info("Sw discovery latency of "+ |
| 736 | str(cluster_count)+" node(s): "+ |
| 737 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 738 | else: |
| 739 | main.log.info("Switch discovery latency "+ |
| 740 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 741 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 742 | |
| 743 | break |
| 744 | if cluster_count == 6: |
| 745 | if onos1_dev and onos2_dev and onos3_dev and\ |
| 746 | onos4_dev and onos5_dev and onos6_dev: |
| 747 | main.log.info("All devices have been discovered"+ |
| 748 | " on all ONOS instances") |
| 749 | json_str_metrics_1 =\ |
| 750 | main.ONOS1cli.topology_events_metrics() |
| 751 | json_str_metrics_2 =\ |
| 752 | main.ONOS2cli.topology_events_metrics() |
| 753 | json_str_metrics_3 =\ |
| 754 | main.ONOS3cli.topology_events_metrics() |
| 755 | json_str_metrics_4 =\ |
| 756 | main.ONOS4cli.topology_events_metrics() |
| 757 | json_str_metrics_5 =\ |
| 758 | main.ONOS5cli.topology_events_metrics() |
| 759 | json_str_metrics_6 =\ |
| 760 | main.ONOS6cli.topology_events_metrics() |
| 761 | json_obj_1 = json.loads(json_str_metrics_1) |
| 762 | json_obj_2 = json.loads(json_str_metrics_2) |
| 763 | json_obj_3 = json.loads(json_str_metrics_3) |
| 764 | json_obj_4 = json.loads(json_str_metrics_4) |
| 765 | json_obj_5 = json.loads(json_str_metrics_5) |
| 766 | json_obj_6 = json.loads(json_str_metrics_6) |
| 767 | graph_timestamp_1 =\ |
| 768 | json_obj_1[graphTimestamp]['value'] |
| 769 | graph_timestamp_2 =\ |
| 770 | json_obj_2[graphTimestamp]['value'] |
| 771 | graph_timestamp_3 =\ |
| 772 | json_obj_3[graphTimestamp]['value'] |
| 773 | graph_timestamp_4 =\ |
| 774 | json_obj_4[graphTimestamp]['value'] |
| 775 | graph_timestamp_5 =\ |
| 776 | json_obj_5[graphTimestamp]['value'] |
| 777 | graph_timestamp_6 =\ |
| 778 | json_obj_6[graphTimestamp]['value'] |
| 779 | |
| 780 | graph_lat_1 = \ |
| 781 | int(graph_timestamp_1) - int(t0_system) |
| 782 | graph_lat_2 = \ |
| 783 | int(graph_timestamp_2) - int(t0_system) |
| 784 | graph_lat_3 = \ |
| 785 | int(graph_timestamp_3) - int(t0_system) |
| 786 | graph_lat_4 = \ |
| 787 | int(graph_timestamp_4) - int(t0_system) |
| 788 | graph_lat_5 = \ |
| 789 | int(graph_timestamp_5) - int(t0_system) |
| 790 | graph_lat_6 = \ |
| 791 | int(graph_timestamp_6) - int(t0_system) |
| 792 | |
| 793 | avg_graph_lat = \ |
| 794 | (int(graph_lat_1) +\ |
| 795 | int(graph_lat_2) +\ |
| 796 | int(graph_lat_3) +\ |
| 797 | int(graph_lat_4) +\ |
| 798 | int(graph_lat_5) +\ |
| 799 | int(graph_lat_6)) / 6 |
| 800 | |
| 801 | if avg_graph_lat > sw_disc_threshold_min\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 802 | and avg_graph_lat < sw_disc_threshold_max\ |
| 803 | and int(i) > iter_ignore: |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 804 | sw_discovery_lat_list.append( |
| 805 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 806 | main.log.info("Sw discovery latency of "+ |
| 807 | str(cluster_count)+" node(s): "+ |
| 808 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 809 | else: |
| 810 | main.log.info("Switch discovery latency "+ |
| 811 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 812 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 813 | |
| 814 | break |
| 815 | if cluster_count == 7: |
| 816 | if onos1_dev and onos2_dev and onos3_dev and\ |
| 817 | onos4_dev and onos5_dev and onos6_dev and\ |
| 818 | onos7_dev: |
| 819 | main.log.info("All devices have been discovered"+ |
| 820 | " on all ONOS instances") |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 821 | |
| 822 | #TODO: Investigate this sleep |
| 823 | # added to 'pad' the results with |
| 824 | # plenty of time to 'catch up' |
andrewonlab | 6274902 | 2014-11-19 19:19:58 -0500 | [diff] [blame] | 825 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 826 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 827 | json_str_metrics_1 =\ |
| 828 | main.ONOS1cli.topology_events_metrics() |
| 829 | json_str_metrics_2 =\ |
| 830 | main.ONOS2cli.topology_events_metrics() |
| 831 | json_str_metrics_3 =\ |
| 832 | main.ONOS3cli.topology_events_metrics() |
| 833 | json_str_metrics_4 =\ |
| 834 | main.ONOS4cli.topology_events_metrics() |
| 835 | json_str_metrics_5 =\ |
| 836 | main.ONOS5cli.topology_events_metrics() |
| 837 | json_str_metrics_6 =\ |
| 838 | main.ONOS6cli.topology_events_metrics() |
| 839 | json_str_metrics_7 =\ |
| 840 | main.ONOS7cli.topology_events_metrics() |
| 841 | json_obj_1 = json.loads(json_str_metrics_1) |
| 842 | json_obj_2 = json.loads(json_str_metrics_2) |
| 843 | json_obj_3 = json.loads(json_str_metrics_3) |
| 844 | json_obj_4 = json.loads(json_str_metrics_4) |
| 845 | json_obj_5 = json.loads(json_str_metrics_5) |
| 846 | json_obj_6 = json.loads(json_str_metrics_6) |
| 847 | json_obj_7 = json.loads(json_str_metrics_7) |
| 848 | graph_timestamp_1 =\ |
| 849 | json_obj_1[graphTimestamp]['value'] |
| 850 | graph_timestamp_2 =\ |
| 851 | json_obj_2[graphTimestamp]['value'] |
| 852 | graph_timestamp_3 =\ |
| 853 | json_obj_3[graphTimestamp]['value'] |
| 854 | graph_timestamp_4 =\ |
| 855 | json_obj_4[graphTimestamp]['value'] |
| 856 | graph_timestamp_5 =\ |
| 857 | json_obj_5[graphTimestamp]['value'] |
| 858 | graph_timestamp_6 =\ |
| 859 | json_obj_6[graphTimestamp]['value'] |
| 860 | graph_timestamp_7 =\ |
| 861 | json_obj_7[graphTimestamp]['value'] |
| 862 | |
| 863 | graph_lat_1 = \ |
| 864 | int(graph_timestamp_1) - int(t0_system) |
| 865 | graph_lat_2 = \ |
| 866 | int(graph_timestamp_2) - int(t0_system) |
| 867 | graph_lat_3 = \ |
| 868 | int(graph_timestamp_3) - int(t0_system) |
| 869 | graph_lat_4 = \ |
| 870 | int(graph_timestamp_4) - int(t0_system) |
| 871 | graph_lat_5 = \ |
| 872 | int(graph_timestamp_5) - int(t0_system) |
| 873 | graph_lat_6 = \ |
| 874 | int(graph_timestamp_6) - int(t0_system) |
| 875 | graph_lat_7 = \ |
| 876 | int(graph_timestamp_7) - int(t0_system) |
| 877 | |
| 878 | avg_graph_lat = \ |
| 879 | (int(graph_lat_1) +\ |
| 880 | int(graph_lat_2) +\ |
| 881 | int(graph_lat_3) +\ |
| 882 | int(graph_lat_4) +\ |
| 883 | int(graph_lat_5) +\ |
| 884 | int(graph_lat_6) +\ |
| 885 | int(graph_lat_7)) / 7 |
| 886 | |
| 887 | if avg_graph_lat > sw_disc_threshold_min\ |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 888 | and avg_graph_lat < sw_disc_threshold_max\ |
| 889 | and int(i) > iter_ignore: |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 890 | sw_discovery_lat_list.append( |
| 891 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 892 | main.log.info("Sw discovery latency of "+ |
| 893 | str(cluster_count)+" node(s): "+ |
| 894 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 895 | else: |
| 896 | main.log.info("Switch discovery latency "+ |
| 897 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 898 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 899 | |
| 900 | break |
| 901 | |
| 902 | counter_loop += 1 |
| 903 | time.sleep(3) |
| 904 | #END WHILE LOOP |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 905 | |
| 906 | main.ONOS1.tshark_stop() |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 907 | syn_ack_timestamp_list = [] |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 908 | |
| 909 | if cluster_count >= 3: |
| 910 | main.ONOS2.tshark_stop() |
| 911 | main.ONOS3.tshark_stop() |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 912 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 913 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 914 | "/tmp/syn_ack_onos1_iter"+str(i)+".txt /tmp/") |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 915 | os.system("scp "+ONOS_user+"@"+ONOS2_ip+":"+ |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 916 | "/tmp/syn_ack_onos2_iter"+str(i)+".txt /tmp/") |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 917 | os.system("scp "+ONOS_user+"@"+ONOS3_ip+":"+ |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 918 | "/tmp/syn_ack_onos3_iter"+str(i)+".txt /tmp/") |
| 919 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 920 | #Read each of the files and append all |
| 921 | #SYN / ACK timestamps to the list |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 922 | with open("/tmp/syn_ack_onos1_iter"+str(i)+".txt") as\ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 923 | f_onos1: |
| 924 | for line in f_onos1: |
| 925 | line = line.split(" ") |
| 926 | syn_ack_timestamp_list.append(line[1]) |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 927 | with open("/tmp/syn_ack_onos2_iter"+str(i)+".txt") as\ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 928 | f_onos2: |
| 929 | for line in f_onos2: |
| 930 | line = line.split(" ") |
| 931 | syn_ack_timestamp_list.append(line[1]) |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 932 | with open("/tmp/syn_ack_onos3_iter"+str(i)+".txt") as\ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 933 | f_onos3: |
| 934 | for line in f_onos3: |
| 935 | line = line.split(" ") |
| 936 | syn_ack_timestamp_list.append(line[1]) |
| 937 | if cluster_count >= 4: |
| 938 | main.ONOS4.tshark_stop() |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 939 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 940 | os.system("scp "+ONOS_user+"@"+ONOS4_ip+":"+ |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 941 | "/tmp/syn_ack_onos4_iter"+str(i)+".txt /tmp/") |
| 942 | time.sleep(5) |
| 943 | with open("/tmp/syn_ack_onos4_iter"+str(i)+".txt") as\ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 944 | f_onos4: |
| 945 | for line in f_onos4: |
| 946 | line = line.split(" ") |
| 947 | syn_ack_timestamp_list.append(line[1]) |
| 948 | if cluster_count >= 5: |
| 949 | main.ONOS5.tshark_stop() |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 950 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 951 | os.system("scp "+ONOS_user+"@"+ONOS5_ip+":"+ |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 952 | "/tmp/syn_ack_onos5_iter"+str(i)+".txt /tmp/") |
| 953 | time.sleep(5) |
| 954 | with open("/tmp/syn_ack_onos5_iter"+str(i)+".txt") as\ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 955 | f_onos5: |
| 956 | for line in f_onos5: |
| 957 | line = line.split(" ") |
| 958 | syn_ack_timestamp_list.append(line[1]) |
| 959 | if cluster_count >= 6: |
| 960 | main.ONOS6.tshark_stop() |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 961 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 962 | os.system("scp "+ONOS_user+"@"+ONOS6_ip+":"+ |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 963 | "/tmp/syn_ack_onos6_iter"+str(i)+".txt /tmp/") |
| 964 | time.sleep(5) |
| 965 | with open("/tmp/syn_ack_onos6_iter"+str(i)+".txt") as\ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 966 | f_onos6: |
| 967 | for line in f_onos6: |
| 968 | line = line.split(" ") |
| 969 | syn_ack_timestamp_list.append(line[1]) |
| 970 | if cluster_count == 7: |
| 971 | main.ONOS7.tshark_stop() |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 972 | time.sleep(5) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 973 | os.system("scp "+ONOS_user+"@"+ONOS7_ip+":"+ |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 974 | "/tmp/syn_ack_onos7_iter"+str(i)+".txt /tmp/") |
| 975 | time.sleep(5) |
| 976 | with open("/tmp/syn_ack_onos7_iter"+str(i)+".txt") as\ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 977 | f_onos7: |
| 978 | for line in f_onos7: |
| 979 | line = line.split(" ") |
| 980 | syn_ack_timestamp_list.append(line[1]) |
| 981 | |
| 982 | #Sort the list by timestamp |
| 983 | syn_ack_timestamp_list = sorted(syn_ack_timestamp_list) |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 984 | |
| 985 | syn_ack_delta =\ |
| 986 | int(float(syn_ack_timestamp_list[-1])*1000) -\ |
| 987 | int(float(syn_ack_timestamp_list[0])*1000) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 988 | |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 989 | main.log.info("Switch connection attempt delta iteration "+ |
| 990 | str(i)+": "+str(syn_ack_delta)) |
| 991 | syn_ack_delta_list.append(syn_ack_delta) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 992 | #END ITERATION LOOP |
| 993 | #REPORT HERE |
| 994 | |
| 995 | if len(sw_discovery_lat_list) > 0: |
| 996 | sw_lat_avg = sum(sw_discovery_lat_list) / \ |
| 997 | len(sw_discovery_lat_list) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 998 | sw_lat_dev = numpy.std(sw_discovery_lat_list) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 999 | else: |
| 1000 | assertion = main.FALSE |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 1001 | |
| 1002 | main.log.report("Switch connection attempt time avg "+ |
andrewonlab | d784d4f | 2014-11-17 17:47:32 -0500 | [diff] [blame] | 1003 | "(last sw SYN/ACK time - first sw SYN/ACK time) "+ |
andrewonlab | a127217 | 2014-11-17 17:30:35 -0500 | [diff] [blame] | 1004 | str(sum(syn_ack_delta_list)/len(syn_ack_delta_list)) + |
| 1005 | " ms") |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 1006 | main.log.report(str(num_sw)+" Switch discovery lat for "+\ |
| 1007 | str(cluster_count)+" instance(s): ") |
| 1008 | main.log.report("Avg: "+str(sw_lat_avg)+" ms "+ |
| 1009 | "Std Deviation: "+str(round(sw_lat_dev,1))+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 1010 | |
| 1011 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 1012 | onpass="Switch discovery convergence latency" +\ |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 1013 | " for "+str(cluster_count)+" nodes successful", |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 1014 | onfail="Switch discovery convergence latency" +\ |
| 1015 | " test failed") |
| 1016 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1017 | def CASE3(self, main): |
| 1018 | ''' |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 1019 | Increase number of nodes and initiate CLI |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1020 | ''' |
| 1021 | import time |
| 1022 | import subprocess |
| 1023 | import os |
| 1024 | import requests |
| 1025 | import json |
| 1026 | |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 1027 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 1028 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 1029 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 1030 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 1031 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 1032 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 1033 | ONOS7_ip = main.params['CTRL']['ip7'] |
| 1034 | |
| 1035 | cell_name = main.params['ENV']['cellName'] |
| 1036 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1037 | MN1_ip = main.params['MN']['ip1'] |
| 1038 | BENCH_ip = main.params['BENCH']['ip'] |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 1039 | |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1040 | #NOTE:We start with cluster_count at 3. The first |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1041 | #case already initialized ONOS1. Increase the |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1042 | #cluster count and start from 3. |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1043 | #You can optionally change the increment to |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1044 | #test steps of node sizes, such as 3,5,7 |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 1045 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1046 | global cluster_count |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 1047 | cluster_count += 2 |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 1048 | main.log.report("Increasing cluster size to "+ |
| 1049 | str(cluster_count)) |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1050 | |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1051 | install_result = main.FALSE |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1052 | #Supports up to 7 node configuration |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1053 | #TODO: Cleanup this ridiculous repetitive code |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 1054 | if cluster_count == 3: |
| 1055 | install_result = \ |
| 1056 | main.ONOSbench.onos_install(node=ONOS3_ip) |
| 1057 | time.sleep(5) |
| 1058 | main.log.info("Starting CLI") |
| 1059 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 1060 | main.ONOS1cli.add_node(ONOS3_ip, ONOS3_ip) |
| 1061 | |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1062 | if cluster_count == 4: |
| 1063 | main.log.info("Installing ONOS on node 4") |
| 1064 | install_result = \ |
| 1065 | main.ONOSbench.onos_install(node=ONOS4_ip) |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1066 | time.sleep(5) |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1067 | main.log.info("Starting CLI") |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1068 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1069 | main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip) |
| 1070 | |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1071 | elif cluster_count == 5: |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1072 | main.log.info("Installing ONOS on nodes 4 and 5") |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1073 | install_result1 = \ |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 1074 | main.ONOSbench.onos_install(node=ONOS3_ip) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1075 | install_result2 = \ |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 1076 | main.ONOSbench.onos_install(node=ONOS4_ip) |
| 1077 | install_result3 = \ |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1078 | main.ONOSbench.onos_install(node=ONOS5_ip) |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1079 | time.sleep(5) |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1080 | main.log.info("Starting CLI") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 1081 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1082 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 1083 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 1084 | main.ONOS1cli.add_node(ONOS3_ip, ONOS3_ip) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1085 | main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip) |
| 1086 | main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip) |
| 1087 | install_result = install_result1 and install_result2 |
| 1088 | |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1089 | elif cluster_count == 6: |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1090 | main.log.info("Installing ONOS on nodes 4, 5,and 6") |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1091 | install_result1 = \ |
| 1092 | main.ONOSbench.onos_install(options="",node=ONOS4_ip) |
| 1093 | install_result2 = \ |
| 1094 | main.ONOSbench.onos_install(options="",node=ONOS5_ip) |
| 1095 | install_result3 = \ |
| 1096 | main.ONOSbench.onos_install(node=ONOS6_ip) |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1097 | time.sleep(5) |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1098 | main.log.info("Starting CLI") |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1099 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 1100 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
| 1101 | main.ONOS6cli.start_onos_cli(ONOS6_ip) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1102 | main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip) |
| 1103 | main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip) |
| 1104 | main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip) |
| 1105 | install_result = install_result1 and install_result2 and\ |
| 1106 | install_result3 |
| 1107 | |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1108 | elif cluster_count == 7: |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1109 | main.log.info("Installing ONOS on nodes 4, 5, 6,and 7") |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1110 | install_result1 = \ |
| 1111 | main.ONOSbench.onos_install(options="",node=ONOS4_ip) |
| 1112 | install_result2 = \ |
| 1113 | main.ONOSbench.onos_install(options="",node=ONOS5_ip) |
| 1114 | install_result3 = \ |
| 1115 | main.ONOSbench.onos_install(options="",node=ONOS6_ip) |
| 1116 | install_result4 = \ |
| 1117 | main.ONOSbench.onos_install(node=ONOS7_ip) |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1118 | main.log.info("Starting CLI") |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1119 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 1120 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
| 1121 | main.ONOS6cli.start_onos_cli(ONOS6_ip) |
| 1122 | main.ONOS7cli.start_onos_cli(ONOS7_ip) |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1123 | main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip) |
| 1124 | main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip) |
| 1125 | main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip) |
| 1126 | main.ONOS1cli.add_node(ONOS7_ip, ONOS7_ip) |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1127 | |
andrewonlab | a036b40 | 2014-11-17 13:47:46 -0500 | [diff] [blame] | 1128 | install_result = install_result1 and install_result2 and\ |
| 1129 | install_result3 and install_result4 |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 1130 | |
| 1131 | time.sleep(5) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1132 | |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 1133 | if install_result == main.TRUE: |
| 1134 | assertion = main.TRUE |
| 1135 | else: |
| 1136 | assertion = main.FALSE |
| 1137 | |
| 1138 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 1139 | onpass="Scale out to "+str(cluster_count)+\ |
| 1140 | " nodes successful", |
| 1141 | onfail="Scale out to "+str(cluster_count)+\ |
| 1142 | " nodes failed") |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1143 | |
| 1144 | |
| 1145 | def CASE4(self, main): |
| 1146 | ''' |
| 1147 | Cleanup ONOS nodes and Increase topology size |
| 1148 | ''' |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 1149 | #TODO: use meaningful assertion |
| 1150 | assertion=main.TRUE |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1151 | |
| 1152 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 1153 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 1154 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 1155 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 1156 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 1157 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 1158 | ONOS7_ip = main.params['CTRL']['ip7'] |
| 1159 | MN1_ip = main.params['MN']['ip1'] |
| 1160 | BENCH_ip = main.params['BENCH']['ip'] |
| 1161 | |
| 1162 | main.log.info("Uninstalling previous instances") |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 1163 | main.ONOSbench.onos_uninstall(node_ip = ONOS2_ip) |
| 1164 | main.ONOSbench.onos_uninstall(node_ip = ONOS3_ip) |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1165 | main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip) |
| 1166 | main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip) |
| 1167 | main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip) |
| 1168 | main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip) |
| 1169 | |
| 1170 | global topo_iteration |
| 1171 | global cluster_count |
| 1172 | cluster_count = 3 |
andrewonlab | 5b8c02f | 2014-11-21 17:56:10 -0500 | [diff] [blame^] | 1173 | #cluster_count = 1 |
andrewonlab | 7b4e8ba | 2014-11-20 17:45:04 -0500 | [diff] [blame] | 1174 | topo_iteration += 1 |
| 1175 | |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 1176 | main.log.report("Increasing topology size") |
| 1177 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 1178 | onpass="Topology size increased successfully", |
| 1179 | onfail="Topology size was not increased") |