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 | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 32 | cell_name = main.params[ 'ENV' ][ 'cellName' ] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 33 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 34 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 35 | ONOS1_port = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 36 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 37 | git_pull_trigger = main.params[ 'GIT' ][ 'autoPull' ] |
| 38 | git_checkout_branch = main.params[ 'GIT' ][ 'checkout' ] |
| 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 ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 44 | cell_file_result = main.ONOSbench.create_cell_file( |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 45 | "10.128.20.10", cell_name, "10.128.10.90", |
| 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" ) |
| 50 | #cell_result = main.ONOSbench.set_cell( cell_name ) |
| 51 | cell_result = main.ONOSbench.set_cell( "temp_cell_2" ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 52 | verify_result = main.ONOSbench.verify_cell() |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 53 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 54 | if git_pull_trigger == 'on': |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 55 | main.step( "Git checkout and pull master" ) |
| 56 | main.ONOSbench.git_checkout( git_checkout_branch ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 57 | git_pull_result = main.ONOSbench.git_pull() |
| 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" ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 60 | git_pull_result = main.TRUE |
| 61 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 62 | main.step( "Using mvn clean & install" ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 63 | #clean_install_result = main.ONOSbench.clean_install() |
| 64 | clean_install_result = main.TRUE |
| 65 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 66 | main.step( "Creating ONOS package" ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 67 | package_result = main.ONOSbench.onos_package() |
| 68 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 69 | main.step( "Installing ONOS package" ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 70 | onos_install_result = main.ONOSbench.onos_install() |
| 71 | onos1_isup = 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" ) |
| 74 | start_result = main.ONOSbench.onos_start( ONOS1_ip ) |
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" ) |
| 77 | main.ONOScli.set_cell( cell_name ) |
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" ) |
| 80 | main.ONOScli.start_onos_cli( ONOS1_ip ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 81 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 82 | case1_result = ( clean_install_result and package_result and |
| 83 | cell_result and verify_result and onos_install_result and |
| 84 | onos1_isup and start_result ) |
| 85 | utilities.assert_equals( expect=main.TRUE, actual=case1_result, |
| 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 | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 97 | ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 98 | default_sw_port = 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 |
| 101 | main.Mininet1.assign_sw_controller( |
| 102 | sw="1", |
| 103 | ip1=ONOS1_ip, |
| 104 | port1=default_sw_port ) |
| 105 | main.Mininet1.assign_sw_controller( |
| 106 | sw="2", |
| 107 | ip1=ONOS1_ip, |
| 108 | port1=default_sw_port ) |
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 | """ |