andrew@onlab.us | 98eab87 | 2015-01-22 14:41:34 -0800 | [diff] [blame] | 1 | # ScaleOutTemplate --> NetworkTP |
| 2 | # |
| 3 | # CASE1 starts number of nodes specified in param file |
| 4 | # |
| 5 | # cameron@onlab.us |
| 6 | |
| 7 | import sys |
| 8 | import os |
| 9 | |
| 10 | |
| 11 | class NetworkTP: |
| 12 | |
| 13 | def __init__( self ): |
| 14 | self.default = '' |
| 15 | |
| 16 | def CASE1( self, main ): |
| 17 | |
| 18 | global clusterCount |
| 19 | clusterCount = 1 |
| 20 | |
| 21 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
| 22 | gitPull = main.params[ 'GIT' ][ 'autopull' ] |
| 23 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 24 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 25 | BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 26 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 27 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 28 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 29 | |
| 30 | |
| 31 | main.log.step( "Cleaning Enviornment..." ) |
| 32 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 33 | main.ONOSbench.onosUninstall( ONOS2Ip ) |
| 34 | main.ONOSbench.onosUninstall( ONOS3Ip ) |
| 35 | |
| 36 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 37 | if gitPull == 'on': |
| 38 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 39 | pullResult = main.ONOSbench.gitPull() |
| 40 | |
| 41 | else: |
| 42 | checkoutResult = main.TRUE |
| 43 | pullResult = main.TRUE |
| 44 | main.log.info( "Skipped git checkout and pull" ) |
| 45 | |
| 46 | #mvnResult = main.ONOSbench.cleanInstall() |
| 47 | |
| 48 | main.step( "Set cell for ONOS cli env" ) |
| 49 | main.ONOS1cli.setCell( cellName ) |
| 50 | main.ONOS2cli.setCell( cellName ) |
| 51 | main.ONOS3cli.setCell( cellName ) |
| 52 | |
| 53 | main.step( "Creating ONOS package" ) |
| 54 | packageResult = main.ONOSbench.onosPackage() # no file or directory |
| 55 | |
| 56 | main.step( "Installing ONOS package" ) |
| 57 | install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip ) |
| 58 | |
| 59 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 60 | main.step( "Applying cell file to environment" ) |
| 61 | cellApplyResult = main.ONOSbench.setCell( cellName ) |
| 62 | main.step( "verify cells" ) |
| 63 | verifyCellResult = main.ONOSbench.verifyCell() |
| 64 | |
| 65 | main.step( "Set cell for ONOS cli env" ) |
| 66 | main.ONOS1cli.setCell( cellName ) |
| 67 | |
| 68 | cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip ) |
| 69 | |
| 70 | def CASE2( self, main ): |
| 71 | """ |
| 72 | Increase number of nodes and initiate CLI |
| 73 | """ |
| 74 | import time |
| 75 | |
| 76 | global clusterCount |
| 77 | |
| 78 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 79 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 80 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 81 | #ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 82 | #ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 83 | #ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 84 | #ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
| 85 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 86 | scale = int( main.params[ 'SCALE' ] ) |
| 87 | |
| 88 | # Cluster size increased everytime the case is defined |
| 89 | clusterCount += scale |
| 90 | |
| 91 | main.log.report( "Increasing cluster size to " + |
| 92 | str( clusterCount ) ) |
| 93 | installResult = main.FALSE |
| 94 | |
| 95 | if scale == 2: |
| 96 | if clusterCount == 3: |
| 97 | main.log.info( "Installing nodes 2 and 3" ) |
| 98 | install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 99 | install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip ) |
| 100 | cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip ) |
| 101 | cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip ) |
| 102 | |
| 103 | if scale == 1: |
| 104 | if clusterCount == 2: |
| 105 | main.log.info( "Installing node 2" ) |
| 106 | install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 107 | cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip ) |
| 108 | |
| 109 | if clusterCount == 3: |
| 110 | main.log.info( "Installing node 3" ) |
| 111 | install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip ) |
| 112 | cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip ) |
| 113 | |
| 114 | |
| 115 | def CASE3( self, main ): |
| 116 | import time |
| 117 | import json |
| 118 | import string |
| 119 | |
| 120 | testDelay = main.params[ 'TEST' ][ 'wait'] |
| 121 | time.sleep( float( testDelay ) ) |
| 122 | |
| 123 | getMetric = main.params[ 'TEST' ][ 'metric1' ] |
| 124 | testDuration = main.params[ 'TEST' ][ 'duration' ] |
| 125 | stop = time.time() + float( testDuration ) |
| 126 | |
| 127 | main.ONOS1cli.featureInstall("onos-null") |
| 128 | |
| 129 | msg = ( "Starting test loop for " + str(testDuration) + " seconds" ) |
| 130 | main.log.info( msg ) |
| 131 | logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| 132 | |
| 133 | while time.time() < stop: |
| 134 | time.sleep( float( logInterval ) ) |
| 135 | |
| 136 | intentsJsonStr1 = main.ONOS1cli.topologyEventsMetrics() |
| 137 | intentsJsonObj1 = json.loads( intentsJsonStr1 ) |
| 138 | msg = ( "Node 1 TP: " + str( intentsJsonObj1[ getMetric ][ 'm1_rate' ] ) ) |
| 139 | main.log.info( msg ) |
| 140 | lastRate1 = intentsJsonObj1[ getMetric ][ 'm1_rate' ] |
| 141 | |
| 142 | msg = ( "Final TP on node 1: " + str( lastRate1 ) ) |
| 143 | main.log.report( msg ) |
| 144 | |
| 145 | |
| 146 | def CASE4( self, main ): |
| 147 | import time |
| 148 | import json |
| 149 | import string |
| 150 | |
| 151 | testDelay = main.params[ 'TEST' ][ 'wait'] |
| 152 | time.sleep( float( testDelay ) ) |
| 153 | |
| 154 | getMetric = main.params[ 'TEST' ][ 'metric1' ] |
| 155 | testDuration = main.params[ 'TEST' ][ 'duration' ] |
| 156 | stop = time.time() + float( testDuration ) |
| 157 | |
| 158 | main.ONOS2cli.featureInstall("onos-null") |
| 159 | |
| 160 | msg = ( "Starting test loop for " + str(testDuration) + " seconds" ) |
| 161 | main.log.info( msg ) |
| 162 | logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| 163 | |
| 164 | while time.time() < stop: |
| 165 | time.sleep( float( logInterval ) ) |
| 166 | |
| 167 | intentsJsonStr1 = main.ONOS1cli.topologyEventsMetrics() |
| 168 | intentsJsonObj1 = json.loads( intentsJsonStr1 ) |
| 169 | msg = ( "Node 1 TP: " + str( intentsJsonObj1[ getMetric ][ 'm1_rate' ] ) ) |
| 170 | main.log.info( msg ) |
| 171 | lastRate1 = intentsJsonObj1[ getMetric ][ 'm1_rate' ] |
| 172 | |
| 173 | |
| 174 | intentsJsonStr2 = main.ONOS2cli.topologyEventsMetrics() |
| 175 | intentsJsonObj2 = json.loads( intentsJsonStr2 ) |
| 176 | msg = ( "Node 2 TP: " + str( intentsJsonObj2[ getMetric ][ 'm1_rate' ] ) ) |
| 177 | main.log.info( msg ) |
| 178 | lastRate2 = intentsJsonObj2[ getMetric ][ 'm1_rate' ] |
| 179 | |
| 180 | |
| 181 | msg = ( "Final TP on node 1: " + str( lastRate1 ) ) |
| 182 | main.log.report( msg ) |
| 183 | |
| 184 | msg = ( "Final TP on node 2: " + str( lastRate2 ) ) |
| 185 | main.log.report( msg ) |
| 186 | |
| 187 | def CASE5( self, main ): |
| 188 | import time |
| 189 | import json |
| 190 | import string |
| 191 | |
| 192 | testDelay = main.params[ 'TEST' ][ 'wait'] |
| 193 | time.sleep( float( testDelay ) ) |
| 194 | |
| 195 | getMetric = main.params[ 'TEST' ][ 'metric1' ] |
| 196 | testDuration = main.params[ 'TEST' ][ 'duration' ] |
| 197 | stop = time.time() + float( testDuration ) |
| 198 | |
| 199 | main.ONOS3cli.featureInstall("onos-null") |
| 200 | |
| 201 | msg = ( "Starting test loop for " + str(testDuration) + " seconds" ) |
| 202 | main.log.info( msg ) |
| 203 | logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| 204 | |
| 205 | while time.time() < stop: |
| 206 | time.sleep( float( logInterval ) ) |
| 207 | |
| 208 | intentsJsonStr1 = main.ONOS1cli.topologyEventsMetrics() |
| 209 | intentsJsonObj1 = json.loads( intentsJsonStr1 ) |
| 210 | msg = ( "Node 1 TP: " + str( intentsJsonObj1[ getMetric ][ 'm1_rate' ] ) ) |
| 211 | main.log.info( msg ) |
| 212 | lastRate1 = intentsJsonObj1[ getMetric ][ 'm1_rate' ] |
| 213 | |
| 214 | |
| 215 | intentsJsonStr2 = main.ONOS2cli.topologyEventsMetrics() |
| 216 | intentsJsonObj2 = json.loads( intentsJsonStr2 ) |
| 217 | msg = ( "Node 2 TP: " + str( intentsJsonObj2[ getMetric ][ 'm1_rate' ] ) ) |
| 218 | main.log.info( msg ) |
| 219 | lastRate2 = intentsJsonObj2[ getMetric ][ 'm1_rate' ] |
| 220 | |
| 221 | intentsJsonStr3 = main.ONOS3cli.topologyEventsMetrics() |
| 222 | intentsJsonObj3 = json.loads( intentsJsonStr3 ) |
| 223 | msg = ( "Node 3 TP: " + str( intentsJsonObj3[ getMetric ][ 'm1_rate' ] ) ) |
| 224 | main.log.info( msg ) |
| 225 | lastRate3 = intentsJsonObj3[ getMetric ][ 'm1_rate' ] |
| 226 | |
| 227 | msg = ( "Final TP on node 1: " + str( lastRate1 ) ) |
| 228 | main.log.report( msg ) |
| 229 | |
| 230 | msg = ( "Final TP on node 2: " + str( lastRate2 ) ) |
| 231 | main.log.report( msg ) |
| 232 | |
| 233 | msg = ( "Final TP on node 3: " + str( lastRate3 ) ) |
| 234 | main.log.report( msg ) |
| 235 | |
| 236 | |
| 237 | |