blob: b971d8c047bb839a0baf1ce5f1c6f30c773965af [file] [log] [blame]
kelvin-onlab1d03c602015-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 """
kelvin-onlab2bb86ca2015-05-05 14:34:07 -0700141 import re
kelvin-onlab1d03c602015-05-05 11:14:42 -0700142 main.log.report( "Assigning switches to controllers" )
143 main.log.case( "Assigning swithes to controllers" )
144
145 main.step( "Assigning switches to controllers" )
146 assignResult = main.TRUE
kelvin-onlab2bb86ca2015-05-05 14:34:07 -0700147 for i in range( 1, ( main.numSwitch + 1 ) ):
kelvin-onlab1d03c602015-05-05 11:14:42 -0700148 main.Mininet1.assignSwController( sw=str( i ),
149 count=1,
kelvin-onlab2bb86ca2015-05-05 14:34:07 -0700150 ip1=main.ONOS1ip,
151 port1=main.ONOS1port )
152 for i in range( 1, ( main.numSwitch + 1 ) ):
kelvin-onlab1d03c602015-05-05 11:14:42 -0700153 response = main.Mininet1.getSwController( "s" + str( i ) )
154 print( "Response is " + str( response ) )
kelvin-onlab2bb86ca2015-05-05 14:34:07 -0700155 if re.search( "tcp:" + main.ONOS1ip, response ):
kelvin-onlab1d03c602015-05-05 11:14:42 -0700156 assignResult = assignResult and main.TRUE
157 else:
158 assignResult = main.FALSE
159 stepResult = assignResult
160 utilities.assert_equals( expect=main.TRUE,
161 actual=stepResult,
162 onpass="Successfully assigned switches" +
163 "to controller",
164 onfail="Failed to assign switches to " +
165 "controller" )
166