kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 1 | # LincOETest |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 2 | # |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 3 | # Packet-Optical Intent Testing |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 4 | # |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 5 | # andrew@onlab.us |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 6 | |
| 7 | |
| 8 | import time |
| 9 | import sys |
| 10 | import os |
| 11 | import re |
| 12 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 13 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 14 | class LincOETest: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 15 | |
| 16 | def __init__( self ): |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 17 | self.default = '' |
| 18 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 19 | def CASE1( self, main ): |
| 20 | """ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 21 | Startup sequence: |
| 22 | git pull |
| 23 | mvn clean install |
| 24 | onos-package |
| 25 | cell <name> |
| 26 | onos-verify-cell |
| 27 | onos-install -f |
| 28 | onos-wait-for-start |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 29 | """ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 30 | import time |
| 31 | |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 32 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 33 | |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 34 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 35 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 36 | |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 37 | gitPullTrigger = main.params[ 'GIT' ][ 'autoPull' ] |
| 38 | gitCheckoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 39 | |
| 40 | main.case( "Setting up test environment" ) |
| 41 | |
| 42 | main.step( "Creating cell file" ) |
| 43 | # params: ( bench ip, cell name, mininet ip, *onos ips ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 44 | cellFileResult = main.ONOSbench.createCellFile( |
| 45 | "10.128.20.10", cellName, "10.128.10.90", |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 46 | "onos-core-trivial,onos-app-fwd", |
| 47 | "10.128.174.1" ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 48 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 49 | main.step( "Applying cell variable to environment" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 50 | # cellResult = main.ONOSbench.setCell( cellName ) |
| 51 | cellResult = main.ONOSbench.setCell( "temp_cell_2" ) |
| 52 | verifyResult = main.ONOSbench.verifyCell() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 53 | |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 54 | if gitPullTrigger == 'on': |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 55 | main.step( "Git checkout and pull master" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 56 | main.ONOSbench.gitCheckout( gitCheckoutBranch ) |
| 57 | gitPullResult = main.ONOSbench.gitPull() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 58 | else: |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 59 | main.log.info( "Git checkout and pull skipped by config" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 60 | gitPullResult = main.TRUE |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 61 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 62 | main.step( "Using mvn clean & install" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 63 | # cleanInstallResult = main.ONOSbench.cleanInstall() |
| 64 | cleanInstallResult = main.TRUE |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 65 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 66 | main.step( "Creating ONOS package" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 67 | packageResult = main.ONOSbench.onosPackage() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 68 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 69 | main.step( "Installing ONOS package" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 70 | onosInstallResult = main.ONOSbench.onosInstall() |
| 71 | onos1Isup = main.ONOSbench.isup() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 72 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 73 | main.step( "Starting ONOS service" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 74 | startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 75 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 76 | main.step( "Setting cell for ONOScli" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 77 | main.ONOScli.setCell( cellName ) |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 78 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 79 | main.step( "Starting ONOScli" ) |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 80 | main.ONOScli.startOnosCli( ONOS1Ip ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 81 | |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 82 | case1Result = ( cleanInstallResult and packageResult and |
| 83 | cellResult and verifyResult and onosInstallResult and |
| 84 | onos1Isup and startResult ) |
| 85 | utilities.assertEquals( expect=main.TRUE, actual=case1Result, |
| 86 | onpass="Test startup successful", |
| 87 | onfail="Test startup NOT successful" ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 88 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 89 | time.sleep( 10 ) |
| 90 | |
| 91 | def CASE2( self, main ): |
| 92 | """ |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 93 | Configure topology |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 94 | """ |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 95 | import time |
| 96 | |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 97 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 98 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 99 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 100 | # Assign packet level switches to controller |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 101 | main.Mininet1.assignSwController( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 102 | sw="1", |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 103 | ip1=ONOS1Ip, |
| 104 | port1=defaultSwPort ) |
| 105 | main.Mininet1.assignSwController( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 106 | sw="2", |
kelvin-onlab | 7bbb561 | 2015-01-26 10:54:50 -0800 | [diff] [blame] | 107 | ip1=ONOS1Ip, |
| 108 | port1=defaultSwPort ) |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 109 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 110 | # Check devices in controller |
| 111 | # This should include Linc-OE devices as well |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 112 | devices = main.ONOScli.devices() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 113 | main.log.info( devices ) |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 114 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 115 | def CASE3( self, main ): |
| 116 | """ |
andrewonlab | a85a776 | 2014-10-22 18:05:52 -0400 | [diff] [blame] | 117 | Install multi-layer intents |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 118 | """ |