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