blob: 77992543985bd52934ebb1b6690692fe31bfa722 [file] [log] [blame]
kelvin-onlab4ff9cc12015-05-05 11:14:42 -07001
2# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
4
5import time
6import json
7
8time.sleep( 1 )
9
10class SingleFunc:
11
12 def __init__( self ):
13 self.default = ''
14
15 def CASE10( self, main ):
16 import time
17 import os
18 """
19 Startup sequence:
20 cell <name>
21 onos-verify-cell
22 onos-remove-raft-log
23 git pull
24 mvn clean install
25 onos-package
26 onos-install -f
27 onos-wait-for-start
28 """
29 #Local variables
30 cellName = main.params[ 'ENV' ][ 'cellName' ]
31 main.ONOS1ip = os.environ[ 'OC1' ]
32 main.ONOS1port = main.params[ 'CTRL' ][ 'port1' ]
33 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
34 gitBranch = main.params[ 'GIT' ][ 'branch' ]
35 topology = main.params[ 'MININET' ][ 'topo' ]
36 PULLCODE = False
37 if main.params[ 'GIT' ][ 'pull' ] == 'True':
38 PULLCODE = True
39 main.case( "Setting up test environment" )
40
41 main.step( "Apply cell to environment" )
42 cellResult = main.ONOSbench.setCell( cellName )
43 verifyResult = main.ONOSbench.verifyCell()
44 stepResult = cellResult and verifyResult
45 utilities.assert_equals( expect=main.TRUE,
46 actual=stepResult,
47 onpass="Successfully applied cell to " + \
48 "environment",
49 onfail="Failed to apply cell to environment " )
50 """main.step( "Removing raft logs" )
51 removeRaftResult = main.ONOSbench.onosRemoveRaftLogs()
52 stepResult = removeRaftResult
53 utilities.assert_equals( expect=main.TRUE,
54 actual=stepResult,
55 onpass="Successfully removed raft logs",
56 onfail="Failed to remove raft logs" )
57 """
58 if PULLCODE:
59 main.step( "Git checkout and pull " + gitBranch )
60 main.ONOSbench.gitCheckout( gitBranch )
61 gitPullResult = main.ONOSbench.gitPull()
62 if gitPullResult == main.ERROR:
63 main.log.error( "Error pulling git branch" )
64 main.step( "Using mvn clean & install" )
65 cleanInstallResult = main.ONOSbench.cleanInstall()
66 stepResult = cleanInstallResult
67 utilities.assert_equals( expect=main.TRUE,
68 actual=stepResult,
69 onpass="Successfully compiled latest ONOS",
70 onfail="Failed to compile latest ONOS" )
71 else:
72 main.log.warn( "Did not pull new code so skipping mvn " +
73 "clean install" )
74
75 main.step( "Creating ONOS package" )
76 packageResult = main.ONOSbench.onosPackage()
77 stepResult = packageResult
78 utilities.assert_equals( expect=main.TRUE,
79 actual=stepResult,
80 onpass="Successfully created ONOS package",
81 onfail="Failed to create ONOS package" )
82
83 main.step( "Uninstalling ONOS package" )
84 onosUninstallResult = main.ONOSbench.onosUninstall(
85 nodeIp=main.ONOS1ip )
86 stepResult = onosUninstallResult
87 utilities.assert_equals( expect=main.TRUE,
88 actual=stepResult,
89 onpass="Successfully uninstalled ONOS package",
90 onfail="Failed to uninstall ONOS package" )
91 time.sleep( 5 )
92 main.step( "Installing ONOS package" )
93 onosInstallResult = main.ONOSbench.onosInstall( node=main.ONOS1ip )
94 stepResult = onosInstallResult
95 utilities.assert_equals( expect=main.TRUE,
96 actual=stepResult,
97 onpass="Successfully installed ONOS package",
98 onfail="Failed to install ONOS package" )
99
100 main.step( "Starting ONOS service" )
101 stopResult = main.TRUE
102 startResult = main.TRUE
103 onosIsUp = main.ONOSbench.isup()
104 if onosIsUp == main.TRUE:
105 main.log.report( "ONOS instance is up and ready" )
106 else:
107 main.log.report( "ONOS instance may not be up, stop and " +
108 "start ONOS again " )
109 stopResult = main.ONOSbench.onosStop( main.ONOS1ip )
110 startResult = main.ONOSbench.onosStart( main.ONOS1ip )
111 stepResult = onosIsUp and stopResult and startResult
112 utilities.assert_equals( expect=main.TRUE,
113 actual=stepResult,
114 onpass="ONOS service is ready",
115 onfail="ONOS service did not start properly" )
116
117 main.step( "Starting Mininet Topology" )
118 topoResult = main.Mininet1.startNet( topoFile=topology )
119 stepResult = topoResult
120 utilities.assert_equals( expect=main.TRUE,
121 actual=stepResult,
122 onpass="Successfully loaded topology",
123 onfail="Failed to load topology" )
124 # Exit if topology did not load properly
125 if not topoResult:
126 main.cleanup()
127 main.exit()
128
129 main.step( "Start ONOS cli" )
130 cliResult = main.ONOScli1.startOnosCli( ONOSIp=main.ONOS1ip )
131 stepResult = cliResult
132 utilities.assert_equals( expect=main.TRUE,
133 actual=stepResult,
134 onpass="Successfully start ONOS cli",
135 onfail="Failed to start ONOS cli" )
136
137 def CASE11( self, main ):
138 """
139 Assign mastership to controllers
140 """
141 main.log.report( "Assigning switches to controllers" )
142 main.log.case( "Assigning swithes to controllers" )
143
144 main.step( "Assigning switches to controllers" )
145 assignResult = main.TRUE
146 for i in range( 1, 8 ):
147 main.Mininet1.assignSwController( sw=str( i ),
148 count=1,
149 ip1=ONOS1ip,
150 port1=ONOS1port )
151 for i in range( 1, ( main.numSwitches + 1 ) ):
152 response = main.Mininet1.getSwController( "s" + str( i ) )
153 print( "Response is " + str( response ) )
154 if re.search( "tcp:" + main.ONOS1cli, response ):
155 assignResult = assignResult and main.TRUE
156 else:
157 assignResult = main.FALSE
158 stepResult = assignResult
159 utilities.assert_equals( expect=main.TRUE,
160 actual=stepResult,
161 onpass="Successfully assigned switches" +
162 "to controller",
163 onfail="Failed to assign switches to " +
164 "controller" )
165
166