blob: ab7e0028459032c3faab4427dbab0653bd1a2999 [file] [log] [blame]
pingping-lin28e7b212015-09-10 10:14:58 -07001# Testing the functionality of SDN-IP with single ONOS instance
2class USECASE_SdnipI2:
3
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
8
9 # This case is to setup ONOS
10 def CASE100( self, main ):
11 """
12 CASE100 is to compile ONOS and install it
13 Startup sequence:
14 cell <name>
15 onos-verify-cell
16 git pull
17 mvn clean install
18 onos-package
19 onos-install -f
20 onos-wait-for-start
21 """
22 import json
23 import time
24 from operator import eq
25
26 main.case( "Setting up test environment" )
27
28 cellName = main.params[ 'ENV' ][ 'cellName' ]
29 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
30
31 main.step( "Applying cell variable to environment" )
32 cellResult = main.ONOSbench.setCell( cellName )
33 verifyResult = main.ONOSbench.verifyCell()
34
35 branchName = main.ONOSbench.getBranchName()
36 main.log.info( "ONOS is on branch: " + branchName )
37
38 main.log.report( "Uninstalling ONOS" )
39 main.ONOSbench.onosUninstall( ONOS1Ip )
40
41 # cleanInstallResult = main.TRUE
42 # gitPullResult = main.TRUE
43
44 main.step( "Git pull" )
45 gitPullResult = main.ONOSbench.gitPull()
46
47 main.step( "Using mvn clean install" )
48 if gitPullResult == main.TRUE:
49 cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
50 else:
51 main.log.warn( "Did not pull new code so skipping mvn " +
52 "clean install" )
53 cleanInstallResult = main.TRUE
54
55 main.ONOSbench.getVersion( report = True )
56
57 main.step( "Creating ONOS package" )
58 packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
59
60 main.step( "Installing ONOS package" )
61 onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
62 node = ONOS1Ip )
63
64 main.step( "Checking if ONOS is up yet" )
65 for i in range( 2 ):
66 onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
67 if onos1Isup:
68 break
69 if not onos1Isup:
70 main.log.report( "ONOS1 didn't start!" )
71
72 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
73 commandlineTimeout = 100, onosStartTimeout = 600 )
74
75 case1Result = ( cleanInstallResult and packageResult and
76 cellResult and verifyResult and
77 onos1InstallResult and
78 onos1Isup and cliResult )
79
80 utilities.assert_equals( expect = main.TRUE, actual = case1Result,
81 onpass = "ONOS startup successful",
82 onfail = "ONOS startup NOT successful" )
83
84 if case1Result == main.FALSE:
85 main.cleanup()
86 main.exit()
87
88 def CASE1( self, main ):
89 '''
90 ping test from 3 bgp peers to BGP speaker
91 '''
92 main.case( "This case is to check ping between BGP peers and speakers" )
93
94 def CASE2( self, main ):
95 '''
96 point-to-point intents test for each BGP peer and BGP speaker pair
97 '''
98 main.case( "This case is to check point-to-point intents" )
99
100
101 def CASE3( self, main ):
102 '''
103 routes and intents check to all BGP peers
104 '''
105 main.case( "This case is to check routes and intents to all BGP peers" )
106
107 main.step( "Get links in the network" )
108 listResult = main.ONOScli.links( jsonFormat = False )
109 main.log.info( listResult )
110 main.log.info( "Activate sdn-ip application" )
111 main.ONOScli.activateApp( "org.onosproject.sdnip" )
112 # wait sdn-ip to finish installing connectivity intents, and the BGP
113 # paths in data plane are ready.
114 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
115 # wait Quagga to finish delivery all routes to each other and to sdn-ip,
116 # plus finish installing all intents.
117 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
118 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
119
120
121 allRoutesExpected = []
122 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
123 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
124 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
125
126 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
127 allRoutesActual = \
128 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
129 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
130 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
131
132 main.step( "Check routes installed" )
133 main.log.info( "Routes expected:" )
134 main.log.info( allRoutesStrExpected )
135 main.log.info( "Routes get from ONOS CLI:" )
136 main.log.info( allRoutesStrActual )
137 utilities.assertEquals( \
138 expect = allRoutesStrExpected, actual = allRoutesStrActual,
139 onpass = "***Routes in SDN-IP are correct!***",
140 onfail = "***Routes in SDN-IP are wrong!***" )
141
142 main.step( "Check MultiPointToSinglePointIntent intents installed" )
143 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
144 routeIntentsActualNum = \
145 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
146 routeIntentsExpectedNum = 3
147
148 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
149 main.log.info( routeIntentsExpectedNum )
150 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
151 main.log.info( routeIntentsActualNum )
152 utilities.assertEquals( \
153 expect = True,
154 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
155 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
156 correct!***",
157 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
158 wrong!***" )
159