GlennRC | 5147a42 | 2015-10-06 17:26:17 -0700 | [diff] [blame] | 1 | class FUNCflow: |
| 2 | |
| 3 | def __init__( self ): |
| 4 | self.default = '' |
| 5 | |
| 6 | def CASE1( self, main ): |
| 7 | import time |
| 8 | import os |
| 9 | import imp |
| 10 | |
| 11 | """ |
| 12 | - Construct tests variables |
| 13 | - GIT ( optional ) |
| 14 | - Checkout ONOS master branch |
| 15 | - Pull latest ONOS code |
| 16 | - Building ONOS ( optional ) |
| 17 | - Install ONOS package |
| 18 | - Build ONOS package |
| 19 | """ |
| 20 | |
| 21 | main.case( "Constructing test variables and building ONOS package" ) |
| 22 | main.step( "Constructing test variables" ) |
| 23 | stepResult = main.FALSE |
| 24 | |
| 25 | # Test variables |
| 26 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 27 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 28 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 29 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 30 | main.dependencyPath = main.testOnDirectory + \ |
| 31 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 32 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 33 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 34 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 35 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 36 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 37 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 38 | main.cellData = {} # for creating cell file |
| 39 | main.CLIs = [] |
| 40 | main.ONOSip = [] |
| 41 | |
| 42 | main.ONOSip = main.ONOSbench.getOnosIps() |
| 43 | print main.ONOSip |
| 44 | |
| 45 | # Assigning ONOS cli handles to a list |
| 46 | for i in range( 1, main.maxNodes + 1 ): |
| 47 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 48 | |
| 49 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 50 | main.startUp = imp.load_source( wrapperFile1, |
| 51 | main.dependencyPath + |
| 52 | wrapperFile1 + |
| 53 | ".py" ) |
| 54 | |
| 55 | if main.CLIs: |
| 56 | stepResult = main.TRUE |
| 57 | else: |
| 58 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 59 | stepResult = main.FALSE |
| 60 | |
| 61 | utilities.assert_equals( expect=main.TRUE, |
| 62 | actual=stepResult, |
| 63 | onpass="Successfully construct " + |
| 64 | "test variables ", |
| 65 | onfail="Failed to construct test variables" ) |
| 66 | |
| 67 | if gitPull == 'True': |
| 68 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 69 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 70 | stepResult = onosBuildResult |
| 71 | utilities.assert_equals( expect=main.TRUE, |
| 72 | actual=stepResult, |
| 73 | onpass="Successfully compiled " + |
| 74 | "latest ONOS", |
| 75 | onfail="Failed to compile " + |
| 76 | "latest ONOS" ) |
| 77 | else: |
| 78 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 79 | "clean install" ) |
| 80 | |
| 81 | def CASE2( self, main ): |
| 82 | """ |
| 83 | - Set up cell |
| 84 | - Create cell file |
| 85 | - Set cell file |
| 86 | - Verify cell file |
| 87 | - Kill ONOS process |
| 88 | - Uninstall ONOS cluster |
| 89 | - Verify ONOS start up |
| 90 | - Install ONOS cluster |
| 91 | - Connect to cli |
| 92 | """ |
| 93 | |
| 94 | main.numCtrls = int( main.maxNodes ) |
| 95 | |
| 96 | main.case( "Starting up " + str( main.numCtrls ) + |
| 97 | " node(s) ONOS cluster" ) |
| 98 | |
| 99 | #kill off all onos processes |
| 100 | main.log.info( "Safety check, killing all ONOS processes" + |
| 101 | " before initiating enviornment setup" ) |
| 102 | |
| 103 | for i in range( main.maxNodes ): |
| 104 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 105 | |
| 106 | print "NODE COUNT = ", main.numCtrls |
| 107 | |
| 108 | tempOnosIp = [] |
| 109 | for i in range( main.numCtrls ): |
| 110 | tempOnosIp.append( main.ONOSip[i] ) |
| 111 | |
| 112 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "temp", main.Mininet1.ip_address, main.apps, tempOnosIp ) |
| 113 | |
| 114 | main.step( "Apply cell to environment" ) |
| 115 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 116 | verifyResult = main.ONOSbench.verifyCell() |
| 117 | stepResult = cellResult and verifyResult |
| 118 | utilities.assert_equals( expect=main.TRUE, |
| 119 | actual=stepResult, |
| 120 | onpass="Successfully applied cell to " + \ |
| 121 | "environment", |
| 122 | onfail="Failed to apply cell to environment " ) |
| 123 | |
| 124 | main.step( "Creating ONOS package" ) |
| 125 | packageResult = main.ONOSbench.onosPackage() |
| 126 | stepResult = packageResult |
| 127 | utilities.assert_equals( expect=main.TRUE, |
| 128 | actual=stepResult, |
| 129 | onpass="Successfully created ONOS package", |
| 130 | onfail="Failed to create ONOS package" ) |
| 131 | |
| 132 | time.sleep( main.startUpSleep ) |
| 133 | main.step( "Uninstalling ONOS package" ) |
| 134 | onosUninstallResult = main.TRUE |
| 135 | for i in range( main.numCtrls ): |
| 136 | onosUninstallResult = onosUninstallResult and \ |
| 137 | main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] ) |
| 138 | stepResult = onosUninstallResult |
| 139 | utilities.assert_equals( expect=main.TRUE, |
| 140 | actual=stepResult, |
| 141 | onpass="Successfully uninstalled ONOS package", |
| 142 | onfail="Failed to uninstall ONOS package" ) |
| 143 | |
| 144 | time.sleep( main.startUpSleep ) |
| 145 | main.step( "Installing ONOS package" ) |
| 146 | onosInstallResult = main.TRUE |
| 147 | for i in range( main.numCtrls ): |
| 148 | onosInstallResult = onosInstallResult and \ |
| 149 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 150 | stepResult = onosInstallResult |
| 151 | utilities.assert_equals( expect=main.TRUE, |
| 152 | actual=stepResult, |
| 153 | onpass="Successfully installed ONOS package", |
| 154 | onfail="Failed to install ONOS package" ) |
| 155 | |
| 156 | time.sleep( main.startUpSleep ) |
| 157 | main.step( "Starting ONOS service" ) |
| 158 | stopResult = main.TRUE |
| 159 | startResult = main.TRUE |
| 160 | onosIsUp = main.TRUE |
| 161 | |
| 162 | for i in range( main.numCtrls ): |
| 163 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 164 | if onosIsUp == main.TRUE: |
| 165 | main.log.report( "ONOS instance is up and ready" ) |
| 166 | else: |
| 167 | main.log.report( "ONOS instance may not be up, stop and " + |
| 168 | "start ONOS again " ) |
| 169 | for i in range( main.numCtrls ): |
| 170 | stopResult = stopResult and \ |
| 171 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 172 | for i in range( main.numCtrls ): |
| 173 | startResult = startResult and \ |
| 174 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 175 | stepResult = onosIsUp and stopResult and startResult |
| 176 | utilities.assert_equals( expect=main.TRUE, |
| 177 | actual=stepResult, |
| 178 | onpass="ONOS service is ready", |
| 179 | onfail="ONOS service did not start properly" ) |
| 180 | |
| 181 | main.step( "Start ONOS cli" ) |
| 182 | cliResult = main.TRUE |
| 183 | for i in range( main.numCtrls ): |
| 184 | cliResult = cliResult and \ |
| 185 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 186 | stepResult = cliResult |
| 187 | utilities.assert_equals( expect=main.TRUE, |
| 188 | actual=stepResult, |
| 189 | onpass="Successfully start ONOS cli", |
| 190 | onfail="Failed to start ONOS cli" ) |
| 191 | |
| 192 | def CASE8( self, main ): |
| 193 | ''' |
| 194 | Compare topology |
| 195 | ''' |
| 196 | |
| 197 | def CASE9( self, main ): |
| 198 | ''' |
| 199 | Report errors/warnings/exceptions |
| 200 | ''' |
| 201 | main.log.info("Error report: \n" ) |
| 202 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 203 | [ "INFO", |
| 204 | "FOLLOWER", |
| 205 | "WARN", |
| 206 | "flow", |
| 207 | "ERROR", |
| 208 | "Except" ], |
| 209 | "s" ) |
| 210 | |
| 211 | def CASE10( self, main ): |
| 212 | ''' |
| 213 | Start Mininet with Openflow 1.3 |
| 214 | ''' |
| 215 | |
| 216 | def CASE11( self, main ): |
| 217 | ''' |
| 218 | Assign switches to controller |
| 219 | ''' |
| 220 | |
| 221 | def CASE1000( self, main ): |
| 222 | ''' |
| 223 | Add flows |
| 224 | ''' |
| 225 | |
| 226 | def CASE2000( self, main ): |
| 227 | ''' |
| 228 | Delete flows |
| 229 | ''' |
| 230 | |
| 231 | def CASE3000( self, main ): |
| 232 | ''' |
| 233 | Modify flow rule selectors |
| 234 | ''' |
| 235 | |
| 236 | def CASE4000( self, main ): |
| 237 | ''' |
| 238 | Modify flow rule treatment |
| 239 | ''' |
| 240 | |
| 241 | def CASE5000( self, main ): |
| 242 | ''' |
| 243 | Modify flow rule controller |
| 244 | ''' |
| 245 | |
| 246 | def CASE100( self, main ): |
| 247 | ''' |
| 248 | Compare switch flow table with ONOS |
| 249 | ''' |
| 250 | |