blob: 5db602ad36d6a488f4c1e66cedaca5e9b0dd3761 [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
pingping-lin28e7b212015-09-10 10:14:58 -070088 main.step( "Get links in the network" )
89 listResult = main.ONOScli.links( jsonFormat = False )
90 main.log.info( listResult )
91 main.log.info( "Activate sdn-ip application" )
92 main.ONOScli.activateApp( "org.onosproject.sdnip" )
93 # wait sdn-ip to finish installing connectivity intents, and the BGP
94 # paths in data plane are ready.
95 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
96 # wait Quagga to finish delivery all routes to each other and to sdn-ip,
97 # plus finish installing all intents.
98 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
99 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
100
101
pingping-lin0ce60622015-09-10 14:37:33 -0700102 def CASE1( self, main ):
103 '''
104 ping test from 3 bgp peers to BGP speaker
105 '''
106 main.case( "This case is to check ping between BGP peers and speakers" )
107
108 def CASE2( self, main ):
109 '''
110 point-to-point intents test for each BGP peer and BGP speaker pair
111 '''
112 main.case( "This case is to check point-to-point intents" )
113 main.log.info( "There are %s BGP peers in total "
114 % main.params[ 'config' ][ 'peerNum' ] )
115 main.step( "Get point-to-point intents from ONOS CLI" )
116
117 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
118 bgpIntentsActualNum = \
119 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
120 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
121 main.log.info( "bgpIntentsExpected num is:" )
122 main.log.info( bgpIntentsExpectedNum )
123 main.log.info( "bgpIntentsActual num is:" )
124 main.log.info( bgpIntentsActualNum )
125 utilities.assertEquals( \
126 expect = True,
127 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
128 onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***",
129 onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" )
130
131
132 def CASE3( self, main ):
133 '''
134 routes and intents check to all BGP peers
135 '''
136 main.case( "This case is to check routes and intents to all BGP peers" )
137
pingping-lin28e7b212015-09-10 10:14:58 -0700138 allRoutesExpected = []
139 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
140 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
141 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
142
143 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
144 allRoutesActual = \
145 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
146 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
147 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
148
149 main.step( "Check routes installed" )
150 main.log.info( "Routes expected:" )
151 main.log.info( allRoutesStrExpected )
152 main.log.info( "Routes get from ONOS CLI:" )
153 main.log.info( allRoutesStrActual )
154 utilities.assertEquals( \
155 expect = allRoutesStrExpected, actual = allRoutesStrActual,
156 onpass = "***Routes in SDN-IP are correct!***",
157 onfail = "***Routes in SDN-IP are wrong!***" )
158
159 main.step( "Check MultiPointToSinglePointIntent intents installed" )
160 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
161 routeIntentsActualNum = \
162 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
163 routeIntentsExpectedNum = 3
164
165 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
166 main.log.info( routeIntentsExpectedNum )
167 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
168 main.log.info( routeIntentsActualNum )
169 utilities.assertEquals( \
170 expect = True,
171 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
172 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
173 correct!***",
174 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
175 wrong!***" )
176