cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 1 | |
| 2 | # Testing the basic functionality of ONOS Next |
| 3 | # For sanity and driver functionality excercises only. |
| 4 | |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 5 | class SAMPstartTemplate: |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 6 | |
| 7 | def __init__( self ): |
| 8 | self.default = '' |
| 9 | |
| 10 | def CASE10( self, main ): |
| 11 | import time |
| 12 | import os |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 13 | import imp |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 14 | """ |
| 15 | Startup sequence: |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 16 | git pull |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 17 | cell <name> |
| 18 | onos-verify-cell |
| 19 | onos-remove-raft-log |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 20 | mvn clean install |
| 21 | onos-package |
| 22 | onos-install -f |
| 23 | onos-wait-for-start |
| 24 | """ |
| 25 | global init |
| 26 | global globalONOSip |
| 27 | try: |
| 28 | if type(init) is not bool: |
| 29 | init = False |
| 30 | except NameError: |
| 31 | init = False |
| 32 | |
| 33 | #Local variables |
| 34 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 35 | apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 36 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 37 | benchIp = os.environ[ 'OCN' ] |
| 38 | benchUser = main.params[ 'BENCH' ][ 'user' ] |
| 39 | topology = main.params[ 'MININET' ][ 'topo' ] |
| 40 | main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] ) |
| 41 | main.numLinks = int( main.params[ 'MININET' ][ 'links' ] ) |
| 42 | main.numCtrls = main.params[ 'CTRL' ][ 'num' ] |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 43 | main.ONOSport = [] |
| 44 | main.hostsData = {} |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 45 | PULLCODE = False |
| 46 | if main.params[ 'GIT' ][ 'pull' ] == 'True': |
| 47 | PULLCODE = True |
| 48 | main.case( "Setting up test environment" ) |
| 49 | main.CLIs = [] |
| 50 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 51 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 52 | main.ONOSport.append( main.params[ 'CTRL' ][ 'port' + str( i ) ] ) |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 53 | |
| 54 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 55 | if init == False: |
| 56 | init = True |
| 57 | |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 58 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
| 59 | main.numCtrls = int( main.scale[ 0 ] ) |
| 60 | |
| 61 | if PULLCODE: |
| 62 | main.step( "Git checkout and pull " + gitBranch ) |
| 63 | main.ONOSbench.gitCheckout( gitBranch ) |
| 64 | gitPullResult = main.ONOSbench.gitPull() |
| 65 | if gitPullResult == main.ERROR: |
| 66 | main.log.error( "Error pulling git branch" ) |
| 67 | main.step( "Using mvn clean & install" ) |
| 68 | cleanInstallResult = main.ONOSbench.cleanInstall() |
| 69 | stepResult = cleanInstallResult |
| 70 | utilities.assert_equals( expect=main.TRUE, |
| 71 | actual=stepResult, |
| 72 | onpass="Successfully compiled " + |
| 73 | "latest ONOS", |
| 74 | onfail="Failed to compile " + |
| 75 | "latest ONOS" ) |
| 76 | else: |
| 77 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 78 | "clean install" ) |
| 79 | |
| 80 | globalONOSip = main.ONOSbench.getOnosIps() |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 81 | |
kelvin-onlab | 6ff9cdb | 2015-06-23 15:00:36 -0700 | [diff] [blame] | 82 | maxNodes = ( len( globalONOSip ) - 2 ) |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 83 | |
| 84 | main.numCtrls = int( main.scale[ 0 ] ) |
| 85 | main.scale.remove( main.scale[ 0 ] ) |
| 86 | |
| 87 | main.ONOSip = [] |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 88 | for i in range( maxNodes ): |
| 89 | main.ONOSip.append( globalONOSip[ i ] ) |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 90 | |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 91 | #kill off all onos processes |
| 92 | main.log.info( "Safety check, killing all ONOS processes" + |
| 93 | " before initiating enviornment setup" ) |
kelvin-onlab | 6ff9cdb | 2015-06-23 15:00:36 -0700 | [diff] [blame] | 94 | for i in range( maxNodes ): |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 95 | main.ONOSbench.onosDie( globalONOSip[ i ] ) |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 96 | |
| 97 | print "NODE COUNT = ", main.numCtrls |
| 98 | main.log.info( "Creating cell file" ) |
| 99 | cellIp = [] |
| 100 | for i in range( main.numCtrls ): |
| 101 | cellIp.append( str( main.ONOSip[ i ] ) ) |
| 102 | print cellIp |
| 103 | main.ONOSbench.createCellFile( benchIp, cellName, "", |
| 104 | str( apps ), *cellIp ) |
| 105 | |
| 106 | main.step( "Apply cell to environment" ) |
| 107 | cellResult = main.ONOSbench.setCell( cellName ) |
| 108 | verifyResult = main.ONOSbench.verifyCell() |
| 109 | stepResult = cellResult and verifyResult |
| 110 | utilities.assert_equals( expect=main.TRUE, |
| 111 | actual=stepResult, |
| 112 | onpass="Successfully applied cell to " + \ |
| 113 | "environment", |
| 114 | onfail="Failed to apply cell to environment " ) |
| 115 | |
| 116 | main.step( "Creating ONOS package" ) |
| 117 | packageResult = main.ONOSbench.onosPackage() |
| 118 | stepResult = packageResult |
| 119 | utilities.assert_equals( expect=main.TRUE, |
| 120 | actual=stepResult, |
| 121 | onpass="Successfully created ONOS package", |
| 122 | onfail="Failed to create ONOS package" ) |
| 123 | |
| 124 | main.step( "Uninstalling ONOS package" ) |
| 125 | onosUninstallResult = main.TRUE |
| 126 | for i in range( main.numCtrls ): |
| 127 | onosUninstallResult = onosUninstallResult and \ |
| 128 | main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] ) |
| 129 | stepResult = onosUninstallResult |
| 130 | utilities.assert_equals( expect=main.TRUE, |
| 131 | actual=stepResult, |
| 132 | onpass="Successfully uninstalled ONOS package", |
| 133 | onfail="Failed to uninstall ONOS package" ) |
| 134 | time.sleep( 5 ) |
| 135 | main.step( "Installing ONOS package" ) |
| 136 | onosInstallResult = main.TRUE |
| 137 | for i in range( main.numCtrls ): |
| 138 | onosInstallResult = onosInstallResult and \ |
| 139 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 140 | stepResult = onosInstallResult |
| 141 | utilities.assert_equals( expect=main.TRUE, |
| 142 | actual=stepResult, |
| 143 | onpass="Successfully installed ONOS package", |
| 144 | onfail="Failed to install ONOS package" ) |
| 145 | |
| 146 | time.sleep( 20 ) |
| 147 | main.step( "Starting ONOS service" ) |
| 148 | stopResult = main.TRUE |
| 149 | startResult = main.TRUE |
| 150 | onosIsUp = main.TRUE |
| 151 | for i in range( main.numCtrls ): |
| 152 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 153 | if onosIsUp == main.TRUE: |
| 154 | main.log.report( "ONOS instance is up and ready" ) |
| 155 | else: |
| 156 | main.log.report( "ONOS instance may not be up, stop and " + |
| 157 | "start ONOS again " ) |
| 158 | for i in range( main.numCtrls ): |
| 159 | stopResult = stopResult and \ |
| 160 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 161 | for i in range( main.numCtrls ): |
| 162 | startResult = startResult and \ |
| 163 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 164 | stepResult = onosIsUp and stopResult and startResult |
| 165 | utilities.assert_equals( expect=main.TRUE, |
| 166 | actual=stepResult, |
| 167 | onpass="ONOS service is ready", |
| 168 | onfail="ONOS service did not start properly" ) |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 169 | |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 170 | main.step( "Start ONOS cli" ) |
| 171 | cliResult = main.TRUE |
| 172 | for i in range( main.numCtrls ): |
| 173 | cliResult = cliResult and \ |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 174 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 175 | stepResult = cliResult |
| 176 | utilities.assert_equals( expect=main.TRUE, |
| 177 | actual=stepResult, |
| 178 | onpass="Successfully start ONOS cli", |
| 179 | onfail="Failed to start ONOS cli" ) |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 180 | |
| 181 | def CASE9( self, main ): |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 182 | ''' |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 183 | Report errors/warnings/exceptions |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 184 | ''' |
kelvin-onlab | bf45682 | 2015-06-22 16:53:06 -0700 | [diff] [blame] | 185 | main.log.info("Error report: \n" ) |
| 186 | main.ONOSbench.logReport( globalONOSip[ 0 ], |
| 187 | [ "INFO", |
| 188 | "FOLLOWER", |
| 189 | "WARN", |
| 190 | "flow", |
| 191 | "ERROR", |
| 192 | "Except" ], |
| 193 | "s" ) |
cameron@onlab.us | 966d1be | 2015-05-15 14:54:09 -0700 | [diff] [blame] | 194 | #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" ) |
| 195 | |
| 196 | def CASE11( self, main ): |
| 197 | """ |
| 198 | Start mininet |
| 199 | """ |
| 200 | main.log.report( "Start Mininet topology" ) |
| 201 | main.log.case( "Start Mininet topology" ) |
| 202 | |
| 203 | main.step( "Starting Mininet Topology" ) |
| 204 | topoResult = main.Mininet1.startNet( topoFile=topology ) |
| 205 | stepResult = topoResult |
| 206 | utilities.assert_equals( expect=main.TRUE, |
| 207 | actual=stepResult, |
| 208 | onpass="Successfully loaded topology", |
| 209 | onfail="Failed to load topology" ) |
| 210 | # Exit if topology did not load properly |
| 211 | if not topoResult: |
| 212 | main.cleanup() |
| 213 | main.exit() |
| 214 | |