kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1 | # Intent Performance Test for ONOS-next |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 2 | # |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 3 | # andrew@onlab.us |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 4 | # |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 5 | # November 5, 2014 |
| 6 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 7 | |
| 8 | class IntentPerfNext: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 9 | |
| 10 | def __init__( self ): |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 11 | self.default = "" |
| 12 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 13 | def CASE1( self, main ): |
| 14 | """ |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 15 | ONOS startup sequence |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 16 | """ |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 17 | import time |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 18 | global cluster_count |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 19 | cluster_count = 1 |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 20 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 21 | cell_name = main.params[ 'ENV' ][ 'cellName' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 22 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 23 | git_pull = main.params[ 'GIT' ][ 'autoPull' ] |
| 24 | checkout_branch = main.params[ 'GIT' ][ 'checkout' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 25 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 26 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 27 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 28 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 29 | ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 30 | ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 31 | ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 32 | ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 33 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 34 | main.ONOSbench.onos_uninstall( node_ip=ONOS1_ip ) |
| 35 | main.ONOSbench.onos_uninstall( node_ip=ONOS2_ip ) |
| 36 | main.ONOSbench.onos_uninstall( node_ip=ONOS3_ip ) |
| 37 | main.ONOSbench.onos_uninstall( node_ip=ONOS4_ip ) |
| 38 | main.ONOSbench.onos_uninstall( node_ip=ONOS5_ip ) |
| 39 | main.ONOSbench.onos_uninstall( node_ip=ONOS6_ip ) |
| 40 | main.ONOSbench.onos_uninstall( node_ip=ONOS7_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 41 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 42 | MN1_ip = main.params[ 'MN' ][ 'ip1' ] |
| 43 | BENCH_ip = main.params[ 'BENCH' ][ 'ip' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 44 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 45 | main.case( "Setting up test environment" ) |
| 46 | |
| 47 | main.step( "Creating cell file" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 48 | cell_file_result = main.ONOSbench.create_cell_file( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 49 | BENCH_ip, cell_name, MN1_ip, |
| 50 | "onos-core,onos-app-metrics,onos-gui", |
| 51 | # ONOS1_ip, ONOS2_ip, ONOS3_ip ) |
| 52 | ONOS1_ip ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 53 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 54 | main.step( "Applying cell file to environment" ) |
| 55 | cell_apply_result = main.ONOSbench.set_cell( cell_name ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 56 | verify_cell_result = main.ONOSbench.verify_cell() |
| 57 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 58 | main.step( "Removing raft logs" ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 59 | main.ONOSbench.onos_remove_raft_logs() |
| 60 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 61 | main.step( "Git checkout and pull " + checkout_branch ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 62 | if git_pull == 'on': |
| 63 | checkout_result = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 64 | main.ONOSbench.git_checkout( checkout_branch ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 65 | pull_result = main.ONOSbench.git_pull() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 66 | |
| 67 | # If you used git pull, auto compile |
| 68 | main.step( "Using onos-build to compile ONOS" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 69 | build_result = main.ONOSbench.onos_build() |
| 70 | else: |
| 71 | checkout_result = main.TRUE |
| 72 | pull_result = main.TRUE |
| 73 | build_result = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 74 | main.log.info( "Git pull skipped by configuration" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 75 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 76 | main.log.report( "Commit information - " ) |
| 77 | main.ONOSbench.get_version( report=True ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 78 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 79 | main.step( "Creating ONOS package" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 80 | package_result = main.ONOSbench.onos_package() |
| 81 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 82 | main.step( "Installing ONOS package" ) |
| 83 | install1_result = main.ONOSbench.onos_install( node=ONOS1_ip ) |
| 84 | #install2_result = main.ONOSbench.onos_install( node=ONOS2_ip ) |
| 85 | #install3_result = main.ONOSbench.onos_install( node=ONOS3_ip ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 86 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 87 | main.step( "Set cell for ONOScli env" ) |
| 88 | main.ONOS1cli.set_cell( cell_name ) |
| 89 | # main.ONOS2cli.set_cell( cell_name ) |
| 90 | # main.ONOS3cli.set_cell( cell_name ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 91 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 92 | time.sleep( 5 ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 93 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 94 | main.step( "Start onos cli" ) |
| 95 | cli1 = main.ONOS1cli.start_onos_cli( ONOS1_ip ) |
| 96 | #cli2 = main.ONOS2cli.start_onos_cli( ONOS2_ip ) |
| 97 | #cli3 = main.ONOS3cli.start_onos_cli( ONOS3_ip ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 98 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 99 | utilities.assert_equals( expect=main.TRUE, |
| 100 | actual=cell_file_result and cell_apply_result and |
| 101 | verify_cell_result and checkout_result and |
| 102 | pull_result and build_result and |
| 103 | install1_result, # and install2_result and |
| 104 | # install3_result, |
| 105 | onpass="ONOS started successfully", |
| 106 | onfail="Failed to start ONOS" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 107 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 108 | def CASE2( self, main ): |
| 109 | """ |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 110 | Single intent add latency |
| 111 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 112 | """ |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 113 | import time |
| 114 | import json |
| 115 | import requests |
| 116 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 117 | import numpy |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 118 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 119 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 120 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 121 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 122 | ONOS_user = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 123 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 124 | default_sw_port = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 125 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 126 | # number of iterations of case |
| 127 | num_iter = main.params[ 'TEST' ][ 'numIter' ] |
| 128 | num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 129 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 130 | # Timestamp keys for json metrics output |
| 131 | submit_time = main.params[ 'JSON' ][ 'submittedTime' ] |
| 132 | install_time = main.params[ 'JSON' ][ 'installedTime' ] |
| 133 | wdRequest_time = main.params[ 'JSON' ][ 'wdRequestTime' ] |
| 134 | withdrawn_time = main.params[ 'JSON' ][ 'withdrawnTime' ] |
| 135 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 136 | intent_add_lat_list = [] |
| 137 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 138 | # Assign 'linear' switch format for basic intent testing |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 139 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 140 | sw="1", ip1=ONOS1_ip, port1=default_sw_port ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 141 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 142 | sw="2", ip1=ONOS2_ip, port1=default_sw_port ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 143 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 144 | sw="3", ip1=ONOS2_ip, port1=default_sw_port ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 145 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 146 | sw="4", ip1=ONOS2_ip, port1=default_sw_port ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 147 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 148 | sw="5", ip1=ONOS3_ip, port1=default_sw_port ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 149 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 150 | time.sleep( 10 ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 151 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 152 | main.log.report( "Single intent add latency test" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 153 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 154 | devices_json_str = main.ONOS1cli.devices() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 155 | devices_json_obj = json.loads( devices_json_str ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 156 | device_id_list = [] |
| 157 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 158 | # Obtain device id list in ONOS format. |
| 159 | # They should already be in order ( 1,2,3,10,11,12,13, etc ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 160 | for device in devices_json_obj: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 161 | device_id_list.append( device[ 'id' ] ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 162 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 163 | for i in range( 0, int( num_iter ) ): |
| 164 | # add_point_intent( ingr_device, egr_device, |
| 165 | # ingr_port, egr_port ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 166 | main.ONOS1cli.add_point_intent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 167 | device_id_list[ 0 ] + "/1", device_id_list[ 4 ] + "/1" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 168 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 169 | # Allow some time for intents to propagate |
| 170 | time.sleep( 5 ) |
| 171 | |
| 172 | # Obtain metrics from ONOS 1, 2, 3 |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 173 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 174 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 175 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 176 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 177 | intents_json_obj_1 = json.loads( intents_json_str_1 ) |
| 178 | intents_json_obj_2 = json.loads( intents_json_str_2 ) |
| 179 | intents_json_obj_3 = json.loads( intents_json_str_3 ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 180 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 181 | # Parse values from the json object |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 182 | intent_submit_1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 183 | intents_json_obj_1[ submit_time ][ 'value' ] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 184 | intent_submit_2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 185 | intents_json_obj_2[ submit_time ][ 'value' ] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 186 | intent_submit_3 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 187 | intents_json_obj_3[ submit_time ][ 'value' ] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 188 | |
| 189 | intent_install_1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 190 | intents_json_obj_1[ install_time ][ 'value' ] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 191 | intent_install_2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 192 | intents_json_obj_2[ install_time ][ 'value' ] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 193 | intent_install_3 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 194 | intents_json_obj_3[ install_time ][ 'value' ] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 195 | |
| 196 | intent_install_lat_1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 197 | int( intent_install_1 ) - int( intent_submit_1 ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 198 | intent_install_lat_2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 199 | int( intent_install_2 ) - int( intent_submit_2 ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 200 | intent_install_lat_3 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 201 | int( intent_install_3 ) - int( intent_submit_3 ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 202 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 203 | intent_install_lat_avg = \ |
| 204 | ( intent_install_lat_1 + |
| 205 | intent_install_lat_2 + |
| 206 | intent_install_lat_3 ) / 3 |
| 207 | |
| 208 | main.log.info( "Intent add latency avg for iteration " + str( i ) + |
| 209 | ": " + str( intent_install_lat_avg ) + " ms" ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 210 | |
| 211 | if intent_install_lat_avg > 0.0 and \ |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 212 | intent_install_lat_avg < 1000 and i > num_ignore: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 213 | intent_add_lat_list.append( intent_install_lat_avg ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 214 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 215 | main.log.info( "Intent add latency exceeded " + |
| 216 | "threshold. Skipping iteration " + str( i ) ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 217 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 218 | time.sleep( 3 ) |
| 219 | |
| 220 | # TODO: Possibly put this in the driver function |
| 221 | main.log.info( "Removing intents for next iteration" ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 222 | json_temp = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 223 | main.ONOS1cli.intents( json_format=True ) |
| 224 | json_obj_intents = json.loads( json_temp ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 225 | if json_obj_intents: |
| 226 | for intents in json_obj_intents: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 227 | temp_id = intents[ 'id' ] |
| 228 | main.ONOS1cli.remove_intent( temp_id ) |
| 229 | main.log.info( "Removing intent id: " + |
| 230 | str( temp_id ) ) |
| 231 | main.ONOS1cli.remove_intent( temp_id ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 232 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 233 | main.log.info( "Intents were not installed correctly" ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 234 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 235 | time.sleep( 5 ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 236 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 237 | intent_add_lat_avg = sum( intent_add_lat_list ) /\ |
| 238 | len( intent_add_lat_list ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 239 | intent_add_lat_std = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 240 | round( numpy.std( intent_add_lat_list ), 1 ) |
| 241 | # END ITERATION FOR LOOP |
| 242 | main.log.report( "Single intent add latency - " ) |
| 243 | main.log.report( "Avg: " + str( intent_add_lat_avg ) + " ms" ) |
| 244 | main.log.report( |
| 245 | "Std Deviation: " + |
| 246 | str( intent_add_lat_std ) + |
| 247 | " ms" ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 248 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 249 | def CASE3( self, main ): |
| 250 | """ |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 251 | Intent Reroute latency |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 252 | """ |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 253 | import time |
| 254 | import json |
| 255 | import requests |
| 256 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 257 | import numpy |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 258 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 259 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 260 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 261 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 262 | ONOS_user = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 263 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 264 | default_sw_port = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 265 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 266 | # number of iterations of case |
| 267 | num_iter = main.params[ 'TEST' ][ 'numIter' ] |
| 268 | num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 269 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 270 | # Timestamp keys for json metrics output |
| 271 | submit_time = main.params[ 'JSON' ][ 'submittedTime' ] |
| 272 | install_time = main.params[ 'JSON' ][ 'installedTime' ] |
| 273 | wdRequest_time = main.params[ 'JSON' ][ 'wdRequestTime' ] |
| 274 | withdrawn_time = main.params[ 'JSON' ][ 'withdrawnTime' ] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 275 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 276 | devices_json_str = main.ONOS1cli.devices() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 277 | devices_json_obj = json.loads( devices_json_str ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 278 | |
| 279 | device_id_list = [] |
| 280 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 281 | # Obtain device id list in ONOS format. |
| 282 | # They should already be in order ( 1,2,3,10,11,12,13, etc ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 283 | for device in devices_json_obj: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 284 | device_id_list.append( device[ 'id' ] ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 285 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 286 | intent_reroute_lat_list = [] |
| 287 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 288 | for i in range( 0, int( num_iter ) ): |
| 289 | # add_point_intent( ingr_device, ingr_port, |
| 290 | # egr_device, egr_port ) |
| 291 | if len( device_id_list ) > 0: |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 292 | main.ONOS1cli.add_point_intent( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 293 | device_id_list[ 0 ] + "/2", device_id_list[ 4 ] + "/1" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 294 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 295 | main.log.info( "Failed to fetch devices from ONOS" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 296 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 297 | time.sleep( 5 ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 298 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 299 | intents_str = main.ONOS1cli.intents( json_format=True ) |
| 300 | intents_obj = json.loads( intents_str ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 301 | for intent in intents_obj: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 302 | if intent[ 'state' ] == "INSTALLED": |
| 303 | main.log.info( "Intent installed successfully" ) |
| 304 | intent_id = intent[ 'id' ] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 305 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 306 | # TODO: Add error handling |
| 307 | main.log.info( "Intent installation failed" ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 308 | intent_id = "" |
| 309 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 310 | # NOTE: this interface is specific to |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 311 | # topo-intentFlower.py topology |
| 312 | # reroute case. |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 313 | main.log.info( "Disabling interface s2-eth3" ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 314 | main.Mininet1.handle.sendline( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 315 | "sh ifconfig s2-eth3 down" ) |
| 316 | t0_system = time.time() * 1000 |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 317 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 318 | # TODO: Check for correct intent reroute |
| 319 | time.sleep( 5 ) |
| 320 | |
| 321 | # Obtain metrics from ONOS 1, 2, 3 |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 322 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 323 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 324 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 325 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 326 | intents_json_obj_1 = json.loads( intents_json_str_1 ) |
| 327 | intents_json_obj_2 = json.loads( intents_json_str_2 ) |
| 328 | intents_json_obj_3 = json.loads( intents_json_str_3 ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 329 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 330 | # Parse values from the json object |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 331 | intent_install_1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 332 | intents_json_obj_1[ install_time ][ 'value' ] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 333 | intent_install_2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 334 | intents_json_obj_2[ install_time ][ 'value' ] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 335 | intent_install_3 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 336 | intents_json_obj_3[ install_time ][ 'value' ] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 337 | |
| 338 | intent_reroute_lat_1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 339 | int( intent_install_1 ) - int( t0_system ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 340 | intent_reroute_lat_2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 341 | int( intent_install_2 ) - int( t0_system ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 342 | intent_reroute_lat_3 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 343 | int( intent_install_3 ) - int( t0_system ) |
| 344 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 345 | intent_reroute_lat_avg = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 346 | ( intent_reroute_lat_1 + |
| 347 | intent_reroute_lat_2 + |
| 348 | intent_reroute_lat_3 ) / 3 |
| 349 | |
| 350 | main.log.info( "Intent reroute latency avg for iteration " + |
| 351 | str( i ) + ": " + str( intent_reroute_lat_avg ) ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 352 | |
| 353 | if intent_reroute_lat_avg > 0.0 and \ |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 354 | intent_reroute_lat_avg < 1000 and i > num_ignore: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 355 | intent_reroute_lat_list.append( intent_reroute_lat_avg ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 356 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 357 | main.log.info( "Intent reroute latency exceeded " + |
| 358 | "threshold. Skipping iteration " + str( i ) ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 359 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 360 | main.log.info( "Removing intents for next iteration" ) |
| 361 | main.ONOS1cli.remove_intent( intent_id ) |
| 362 | |
| 363 | main.log.info( "Bringing Mininet interface up for next " + |
| 364 | "iteration" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 365 | main.Mininet1.handle.sendline( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 366 | "sh ifconfig s2-eth3 up" ) |
| 367 | |
| 368 | intent_reroute_lat_avg = sum( intent_reroute_lat_list ) /\ |
| 369 | len( intent_reroute_lat_list ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 370 | intent_reroute_lat_std = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 371 | round( numpy.std( intent_reroute_lat_list ), 1 ) |
| 372 | # END ITERATION FOR LOOP |
| 373 | main.log.report( "Single intent reroute latency - " ) |
| 374 | main.log.report( "Avg: " + str( intent_reroute_lat_avg ) + " ms" ) |
| 375 | main.log.report( |
| 376 | "Std Deviation: " + |
| 377 | str( intent_reroute_lat_std ) + |
| 378 | " ms" ) |
| 379 | |
| 380 | def CASE7( self, main ): |
| 381 | """ |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 382 | Batch intent reroute latency |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 383 | """ |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 384 | import time |
| 385 | import json |
| 386 | import requests |
| 387 | import os |
| 388 | import numpy |
| 389 | |
| 390 | ONOS_ip_list = [] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 391 | for i in range( 1, 8 ): |
| 392 | ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 393 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 394 | ONOS_user = main.params[ 'CTRL' ][ 'user' ] |
| 395 | default_sw_port = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 396 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 397 | batch_intent_size = main.params[ 'TEST' ][ 'batchIntentSize' ] |
| 398 | batch_thresh_min = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] ) |
| 399 | batch_thresh_max = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] ) |
| 400 | install_time = main.params[ 'JSON' ][ 'installedTime' ] |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 401 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 402 | # number of iterations of case |
| 403 | num_iter = main.params[ 'TEST' ][ 'numIter' ] |
| 404 | num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] ) |
| 405 | num_switch = int( main.params[ 'TEST' ][ 'numSwitch' ] ) |
| 406 | n_thread = main.params[ 'TEST' ][ 'numMult' ] |
| 407 | |
| 408 | main.log.report( "Batch intent installation test of " + |
| 409 | batch_intent_size + " intents" ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 410 | |
| 411 | batch_result_list = [] |
| 412 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 413 | # Assign 'linear' switch format for basic intent testing |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 414 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 415 | sw="1", ip1=ONOS1_ip, port1=default_sw_port ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 416 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 417 | sw="2", ip1=ONOS2_ip, port1=default_sw_port ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 418 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 419 | sw="3", ip1=ONOS2_ip, port1=default_sw_port ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 420 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 421 | sw="4", ip1=ONOS2_ip, port1=default_sw_port ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 422 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 423 | sw="5", ip1=ONOS3_ip, port1=default_sw_port ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 424 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 425 | time.sleep( 10 ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 426 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 427 | main.log.info( "Getting list of available devices" ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 428 | device_id_list = [] |
| 429 | json_str = main.ONOS1cli.devices() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 430 | json_obj = json.loads( json_str ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 431 | for device in json_obj: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 432 | device_id_list.append( device[ 'id' ] ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 433 | |
| 434 | batch_install_lat = [] |
| 435 | batch_withdraw_lat = [] |
| 436 | sleep_time = 10 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 437 | |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 438 | base_dir = "/tmp/" |
| 439 | max_install_lat = [] |
| 440 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 441 | for i in range( 0, int( num_iter ) ): |
| 442 | main.log.info( "Pushing " + |
| 443 | str( int( batch_intent_size ) * int( n_thread ) ) + |
| 444 | " intents. Iteration " + str( i ) ) |
| 445 | |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 446 | main.ONOS1cli.push_test_intents( |
| 447 | "of:0000000000000001/1", |
| 448 | "of:0000000000000005/1", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 449 | 1000, num_mult="1", app_id="1" ) |
| 450 | |
| 451 | # TODO: Check for installation success then proceed |
| 452 | time.sleep( 30 ) |
| 453 | |
| 454 | # NOTE: this interface is specific to |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 455 | # topo-intentFlower.py topology |
| 456 | # reroute case. |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 457 | main.log.info( "Disabling interface s2-eth3" ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 458 | main.Mininet1.handle.sendline( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 459 | "sh ifconfig s2-eth3 down" ) |
| 460 | t0_system = time.time() * 1000 |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 461 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 462 | # TODO: Wait sufficient time for intents to install |
| 463 | time.sleep( 10 ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 464 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 465 | # TODO: get intent installation time |
| 466 | |
| 467 | # Obtain metrics from ONOS 1, 2, 3 |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 468 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 469 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 470 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 471 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 472 | intents_json_obj_1 = json.loads( intents_json_str_1 ) |
| 473 | intents_json_obj_2 = json.loads( intents_json_str_2 ) |
| 474 | intents_json_obj_3 = json.loads( intents_json_str_3 ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 475 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 476 | # Parse values from the json object |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 477 | intent_install_1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 478 | intents_json_obj_1[ install_time ][ 'value' ] |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 479 | intent_install_2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 480 | intents_json_obj_2[ install_time ][ 'value' ] |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 481 | intent_install_3 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 482 | intents_json_obj_3[ install_time ][ 'value' ] |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 483 | |
| 484 | intent_reroute_lat_1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 485 | int( intent_install_1 ) - int( t0_system ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 486 | intent_reroute_lat_2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 487 | int( intent_install_2 ) - int( t0_system ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 488 | intent_reroute_lat_3 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 489 | int( intent_install_3 ) - int( t0_system ) |
| 490 | |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 491 | intent_reroute_lat_avg = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 492 | ( intent_reroute_lat_1 + |
| 493 | intent_reroute_lat_2 + |
| 494 | intent_reroute_lat_3 ) / 3 |
| 495 | |
| 496 | main.log.info( "Intent reroute latency avg for iteration " + |
| 497 | str( i ) + ": " + str( intent_reroute_lat_avg ) ) |
| 498 | # TODO: Remove intents for next iteration |
| 499 | |
| 500 | time.sleep( 5 ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 501 | |
| 502 | intents_str = main.ONOS1cli.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 503 | intents_json = json.loads( intents_str ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 504 | for intents in intents_json: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 505 | intent_id = intents[ 'id' ] |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 506 | if intent_id: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 507 | main.ONOS1cli.remove_intent( intent_id ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 508 | |
| 509 | main.Mininet1.handle.sendline( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 510 | "sh ifconfig s2-eth3 up" ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 511 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 512 | main.log.info( "Intents removed and port back up" ) |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 513 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 514 | def CASE4( self, main ): |
| 515 | """ |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 516 | Batch intent install |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 517 | """ |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 518 | import time |
| 519 | import json |
| 520 | import requests |
| 521 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 522 | import numpy |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 523 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 524 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 525 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 526 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 527 | ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 528 | ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 529 | ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 530 | ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ] |
| 531 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 532 | ONOS_ip_list = [] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 533 | for i in range( 1, 8 ): |
| 534 | ONOS_ip_list.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 535 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 536 | ONOS_user = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 537 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 538 | default_sw_port = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 539 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 540 | batch_intent_size = main.params[ 'TEST' ][ 'batchIntentSize' ] |
| 541 | batch_thresh_min = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] ) |
| 542 | batch_thresh_max = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] ) |
| 543 | |
| 544 | # number of iterations of case |
| 545 | num_iter = main.params[ 'TEST' ][ 'numIter' ] |
| 546 | num_ignore = int( main.params[ 'TEST' ][ 'numIgnore' ] ) |
| 547 | num_switch = int( main.params[ 'TEST' ][ 'numSwitch' ] ) |
| 548 | n_thread = main.params[ 'TEST' ][ 'numMult' ] |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 549 | #n_thread = 105 |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 550 | |
| 551 | #***** |
| 552 | global cluster_count |
| 553 | #***** |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 554 | |
| 555 | # Switch assignment NOTE: hardcoded |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 556 | if cluster_count == 1: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 557 | for i in range( 1, num_switch + 1 ): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 558 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 559 | sw=str( i ), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 560 | ip1=ONOS1_ip, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 561 | port1=default_sw_port ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 562 | if cluster_count == 3: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 563 | for i in range( 1, 3 ): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 564 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 565 | sw=str( i ), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 566 | ip1=ONOS1_ip, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 567 | port1=default_sw_port ) |
| 568 | for i in range( 3, 6 ): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 569 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 570 | sw=str( i ), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 571 | ip1=ONOS2_ip, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 572 | port1=default_sw_port ) |
| 573 | for i in range( 6, 9 ): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 574 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 575 | sw=str( i ), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 576 | ip1=ONOS3_ip, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 577 | port1=default_sw_port ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 578 | if cluster_count == 5: |
| 579 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 580 | sw="1", |
| 581 | ip1=ONOS1_ip, |
| 582 | port1=default_sw_port ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 583 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 584 | sw="2", |
| 585 | ip1=ONOS2_ip, |
| 586 | port1=default_sw_port ) |
| 587 | for i in range( 3, 6 ): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 588 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 589 | sw=str( i ), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 590 | ip1=ONOS3_ip, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 591 | port1=default_sw_port ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 592 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 593 | sw="6", |
| 594 | ip1=ONOS4_ip, |
| 595 | port1=default_sw_port ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 596 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 597 | sw="7", |
| 598 | ip1=ONOS5_ip, |
| 599 | port1=default_sw_port ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 600 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 601 | sw="8", |
| 602 | ip1=ONOS5_ip, |
| 603 | port1=default_sw_port ) |
| 604 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 605 | if cluster_count == 7: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 606 | for i in range( 1, 9 ): |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 607 | if i < 8: |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 608 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 609 | sw=str( i ), |
| 610 | ip1=ONOS_ip_list[ i - 1 ], |
| 611 | port1=default_sw_port ) |
| 612 | elif i >= 8: |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 613 | main.Mininet1.assign_sw_controller( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 614 | sw=str( i ), |
| 615 | ip1=ONOS_ip_list[ 6 ], |
| 616 | port1=default_sw_port ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 617 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 618 | time.sleep( 30 ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 619 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 620 | main.log.report( "Batch intent installation test of " + |
| 621 | batch_intent_size + " intents" ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 622 | |
| 623 | batch_result_list = [] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 624 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 625 | main.log.info( "Getting list of available devices" ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 626 | device_id_list = [] |
| 627 | json_str = main.ONOS1cli.devices() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 628 | json_obj = json.loads( json_str ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 629 | for device in json_obj: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 630 | device_id_list.append( device[ 'id' ] ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 631 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 632 | batch_install_lat = [] |
| 633 | batch_withdraw_lat = [] |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 634 | sleep_time = 10 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 635 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 636 | base_dir = "/tmp/" |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 637 | max_install_lat = [] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 638 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 639 | for i in range( 0, int( num_iter ) ): |
| 640 | main.log.info( "Pushing " + |
| 641 | str( int( batch_intent_size ) * int( n_thread ) ) + |
| 642 | " intents. Iteration " + str( i ) ) |
| 643 | |
| 644 | for node in range( 1, cluster_count + 1 ): |
| 645 | save_dir = base_dir + "batch_intent_" + str( node ) + ".txt" |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 646 | main.ONOSbench.push_test_intents_shell( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 647 | "of:0000000000000001/" + str( node ), |
| 648 | "of:0000000000000008/" + str( node ), |
| 649 | int( batch_intent_size ), |
| 650 | save_dir, ONOS_ip_list[ node - 1 ], |
| 651 | num_mult=n_thread, app_id=node ) |
| 652 | |
| 653 | # Wait sufficient time for intents to start |
| 654 | # installing |
| 655 | |
| 656 | time.sleep( sleep_time ) |
| 657 | print sleep_time |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 658 | |
| 659 | intent = "" |
| 660 | counter = 300 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 661 | while len( intent ) > 0 and counter > 0: |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 662 | main.ONOS1cli.handle.sendline( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 663 | "intents | wc -l" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 664 | main.ONOS1cli.handle.expect( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 665 | "intents | wc -l" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 666 | main.ONOS1cli.handle.expect( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 667 | "onos>" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 668 | intent_temp = main.ONOS1cli.handle.before() |
| 669 | print intent_temp |
| 670 | |
| 671 | intent = main.ONOS1cli.intents() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 672 | intent = json.loads( intent ) |
| 673 | counter = counter - 1 |
| 674 | time.sleep( 1 ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 675 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 676 | time.sleep( 5 ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 677 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 678 | for node in range( 1, cluster_count + 1 ): |
| 679 | save_dir = base_dir + "batch_intent_" + str( node ) + ".txt" |
| 680 | with open( save_dir ) as f_onos: |
andrewonlab | 28b84eb | 2014-12-02 15:53:35 -0500 | [diff] [blame] | 681 | line_count = 0 |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 682 | for line in f_onos: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 683 | line = line[ 1: ] |
| 684 | line = line.split( ": " ) |
| 685 | result = line[ 1 ].split( " " )[ 0 ] |
| 686 | # TODO: add parameters before appending latency |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 687 | if line_count == 0: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 688 | batch_install_lat.append( int( result ) ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 689 | elif line_count == 1: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 690 | batch_withdraw_lat.append( int( result ) ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 691 | line_count += 1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 692 | main.log.info( "Batch install latency for ONOS" + |
| 693 | str( node ) + " with " + |
| 694 | str( batch_intent_size ) + "intents: " + |
| 695 | str( batch_install_lat ) ) |
| 696 | |
| 697 | if len( batch_install_lat ) > 0 and int( i ) > num_ignore: |
| 698 | max_install_lat.append( max( batch_install_lat ) ) |
| 699 | elif len( batch_install_lat ) == 0: |
| 700 | # If I failed to read anything from the file, |
| 701 | # increase the wait time before checking intents |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 702 | sleep_time += 30 |
| 703 | batch_install_lat = [] |
| 704 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 705 | # Sleep in between iterations |
| 706 | time.sleep( 5 ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 707 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 708 | main.log.report( "Avg of batch installation latency " + |
| 709 | ": " + |
| 710 | str( sum( max_install_lat ) / |
| 711 | len( max_install_lat ) ) ) |
| 712 | main.log.report( "Std Deviation of batch installation latency " + |
| 713 | ": " + |
| 714 | str( numpy.std( max_install_lat ) ) ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 715 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 716 | def CASE5( self, main ): |
| 717 | """ |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 718 | Increase number of nodes and initiate CLI |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 719 | """ |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 720 | import time |
| 721 | import json |
| 722 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 723 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 724 | ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 725 | ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 726 | ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 727 | ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 728 | ONOS6_ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 729 | ONOS7_ip = main.params[ 'CTRL' ][ 'ip7' ] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 730 | |
| 731 | global cluster_count |
| 732 | cluster_count += 2 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 733 | main.log.report( "Increasing cluster size to " + |
| 734 | str( cluster_count ) ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 735 | |
| 736 | install_result = main.FALSE |
| 737 | |
| 738 | if cluster_count == 3: |
| 739 | install_result1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 740 | main.ONOSbench.onos_install( node=ONOS2_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 741 | install_result2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 742 | main.ONOSbench.onos_install( node=ONOS3_ip ) |
| 743 | time.sleep( 5 ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 744 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 745 | main.log.info( "Starting ONOS CLI" ) |
| 746 | main.ONOS2cli.start_onos_cli( ONOS2_ip ) |
| 747 | main.ONOS3cli.start_onos_cli( ONOS3_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 748 | |
| 749 | install_result = install_result1 and install_result2 |
| 750 | |
| 751 | if cluster_count == 5: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 752 | main.log.info( "Installing ONOS on node 4 and 5" ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 753 | install_result1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 754 | main.ONOSbench.onos_install( node=ONOS4_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 755 | install_result2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 756 | main.ONOSbench.onos_install( node=ONOS5_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 757 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 758 | main.log.info( "Starting ONOS CLI" ) |
| 759 | main.ONOS4cli.start_onos_cli( ONOS4_ip ) |
| 760 | main.ONOS5cli.start_onos_cli( ONOS5_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 761 | |
| 762 | install_result = install_result1 and install_result2 |
| 763 | |
| 764 | if cluster_count == 7: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 765 | main.log.info( "Installing ONOS on node 6 and 7" ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 766 | install_result1 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 767 | main.ONOSbench.onos_install( node=ONOS6_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 768 | install_result2 = \ |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 769 | main.ONOSbench.onos_install( node=ONOS7_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 770 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 771 | main.log.info( "Starting ONOS CLI" ) |
| 772 | main.ONOS6cli.start_onos_cli( ONOS6_ip ) |
| 773 | main.ONOS7cli.start_onos_cli( ONOS7_ip ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 774 | |
| 775 | install_result = install_result1 and install_result2 |
| 776 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 777 | time.sleep( 5 ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 778 | |
| 779 | if install_result == main.TRUE: |
| 780 | assertion = main.TRUE |
| 781 | else: |
| 782 | assertion = main.FALSE |
| 783 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 784 | utilities.assert_equals( |
| 785 | expect=main.TRUE, |
| 786 | actual=assertion, |
| 787 | onpass="Scale out to " + |
| 788 | str( cluster_count ) + |
| 789 | " nodes successful", |
| 790 | onfail="Scale out to " + |
| 791 | str( cluster_count ) + |
| 792 | " nodes failed" ) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 793 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 794 | def CASE9( self, main ): |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 795 | count = 0 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 796 | sw_num1 = 1 |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 797 | sw_num2 = 1 |
| 798 | appid = 0 |
| 799 | port_num1 = 1 |
| 800 | port_num2 = 1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 801 | |
| 802 | time.sleep( 30 ) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 803 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 804 | while True: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 805 | # main.ONOS1cli.push_test_intents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 806 | #"of:0000000000001001/1", |
| 807 | #"of:0000000000002001/1", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 808 | # 100, num_mult="10", app_id="1" ) |
| 809 | # main.ONOS2cli.push_test_intents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 810 | # "of:0000000000001002/1", |
| 811 | # "of:0000000000002002/1", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 812 | # 100, num_mult="10", app_id="2" ) |
| 813 | # main.ONOS2cli.push_test_intents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 814 | # "of:0000000000001003/1", |
| 815 | # "of:0000000000002003/1", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 816 | # 100, num_mult="10", app_id="3" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 817 | count += 1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 818 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 819 | if count >= 100: |
| 820 | main.ONOSbench.handle.sendline( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 821 | "onos 10.128.174.1 intents-events-metrics >>" + |
| 822 | " /tmp/metrics_intents_temp.txt &" ) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 823 | count = 0 |
| 824 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 825 | arg1 = "of:000000000000100" + \ |
| 826 | str( sw_num1 ) + "/" + str( port_num1 ) |
| 827 | arg2 = "of:000000000000200" + \ |
| 828 | str( sw_num2 ) + "/" + str( port_num2 ) |
| 829 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 830 | sw_num1 += 1 |
| 831 | |
| 832 | if sw_num1 > 7: |
| 833 | sw_num1 = 1 |
| 834 | sw_num2 += 1 |
| 835 | if sw_num2 > 7: |
| 836 | appid += 1 |
| 837 | |
| 838 | if sw_num2 > 7: |
| 839 | sw_num2 = 1 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 840 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 841 | main.ONOSbench.push_test_intents_shell( |
| 842 | arg1, |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 843 | arg2, |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 844 | 100, "/tmp/temp.txt", "10.128.174.1", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 845 | num_mult="10", app_id=appid, report=False ) |
| 846 | # main.ONOSbench.push_test_intents_shell( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 847 | # "of:0000000000001002/1", |
| 848 | # "of:0000000000002002/1", |
| 849 | # 133, "/tmp/temp2.txt", "10.128.174.2", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 850 | # num_mult="6", app_id="2",report=False ) |
| 851 | # main.ONOSbench.push_test_intents_shell( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 852 | # "of:0000000000001003/1", |
| 853 | # "of:0000000000002003/1", |
| 854 | # 133, "/tmp/temp3.txt", "10.128.174.3", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 855 | # num_mult="6", app_id="3",report=False ) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 856 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 857 | time.sleep( 0.2 ) |