blob: 375c83fda289ba32f98fe082fff41a4fd4bc2afe [file] [log] [blame]
andrew@onlab.us1bc346b2015-05-21 17:21:16 -04001"""
2FuncPlatform
3
4A functional test designed to test the environment and
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -04005gather information on startup -> shutdown related issues.
andrew@onlab.us1bc346b2015-05-21 17:21:16 -04006
7Future works may also include security mode startup /
8shutdown check and cfg get and set.
9
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040010Abstracting the collection of commands that go hand in hand
11should allow easy rearrangement of steps to replicate or
12create scenarios.
13For example:
14 CASE N - Represents a particular scenario
15 Steps - Represents abstraction methods called from
16 dependency
17 1. Bring ONOS 1 up
18 2. Activate application X
19 3. Activate application Y
20 4. Deactivate application X
21
andrew@onlab.usd2d36fc2015-05-29 14:27:54 -040022The ideal platform test script should have incredible
23robustness to possible exceptions and report the most
24useful error messages.
25
andrew@onlab.us1bc346b2015-05-21 17:21:16 -040026contributers to contact for help:
27andrew@onlab.us
28"""
29
30class FuncPlatform:
31 def __init__( self ):
32 self.default = ''
33
34 def CASE1( self, main ):
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040035 """
36 Main scope initialization case
andrew@onlab.usd2d36fc2015-05-29 14:27:54 -040037 Must include to run any other test cases
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040038 """
andrew@onlab.usd2d36fc2015-05-29 14:27:54 -040039 # NOTE: Hardcoded application name subject to change
andrew@onlab.us9da18f22015-05-28 21:10:24 -040040 # closely monitor and make changes when necessary
41 # (or implement ways to dynamically get names)
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040042 main.appList = {
43 'bgprouter' : 'org.onosproject.bgprouter',
44 'config' : 'org.onosproject.config',
45 'cordfabric' : 'org.onosproject.cordfabric',
46 'demo' : 'org.onosproject.demo',
47 'distributedprimitives' : 'org.onosproject.distributedprimitives',
48 'election' : 'org.onosproject.election',
49 'flowrule' : 'org.onosproject.flowrule',
50 'fwd' : 'org.onosproject.fwd',
51 'intentperf' : 'org.onosproject.intentperf',
52 'messagingperf' : 'org.onosproject.messagingperf',
53 'metrics' : 'org.onosproject.metrics',
54 'mobility' : 'org.onosproject.mobility',
55 'netconf' : 'org.onosproject.netconf',
56 'null' : 'org.onosproject.null',
57 'optical' : 'org.onosproject.optical'
58 }
59 # List of ONOS ip's specififed in params
60 main.ONOSips = []
61 main.CLIs = []
andrew@onlab.us9da18f22015-05-28 21:10:24 -040062 main.ONOSnode = []
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040063
64 for node in range( 0, int(main.params['CTRL']['num']) ):
65 main.ONOSips.append( main.params['CTRL']['ip'+str(node+1)] )
66 main.CLIs.append(
67 getattr( main, 'ONOS' + str(node+1) + 'cli' ) )
andrew@onlab.us9da18f22015-05-28 21:10:24 -040068 main.ONOSnode.append(
69 getattr( main, 'ONOS' + str(node+1) ) )
70
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040071 def CASE2( self, main ):
andrew@onlab.us1bc346b2015-05-21 17:21:16 -040072 import time
73 import imp
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040074
75 startupSrc = main.params['DEP']['startupSrc']
76 startupClassName = main.params['DEP']['startupClassName']
77 cellName = main.params['CELL']['name']
78 appStr = main.params['CELL']['appStr']
79 benchIp = main.params['BENCH']['ip']
80 branchName = main.params['GIT']['branchName']
81 gitPull = main.params['GIT']['pull']
82 mnIp = main.params['MN']['ip']
83
andrew@onlab.us1bc346b2015-05-21 17:21:16 -040084 # importing dependency class(es)
85 # Refer to source files in Dependency folder to
86 # make changes to its respective methods
87 try:
88 startup = imp.load_source( startupClassName, startupSrc )
89 except ImportError:
90 main.log.error( "Error importing class " +
91 str(startupClassName) + " from " + str(startupSrc) )
92 main.cleanup()
93 main.exit()
94
andrew@onlab.us1bc346b2015-05-21 17:21:16 -040095 main.case( 'Setup environment and install ONOS' )
96 if gitPull == 'on':
97 main.step( 'Git pull and clean install' )
98 gitPullResult = startup.gitPullAndMci( branchName )
99 utilities.assert_equals( expect=main.TRUE,
100 actual=gitPullResult,
101 onpass='Git pull and install successful',
102 onfail='Git pull and install failed: ' +
103 str(gitPullResult) )
104
105 main.step( 'Initiate ONOS startup sequence' )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400106 startupResult = startup.initOnosStartupSequence(
107 cellName, appStr, benchIp, mnIp, main.ONOSips )
andrew@onlab.us1bc346b2015-05-21 17:21:16 -0400108 utilities.assert_equals( expect=main.TRUE,
109 actual=startupResult,
110 onpass='ONOS startup sequence successful',
111 onfail='ONOS startup sequence failed: ' +
112 str(startupResult) )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400113
114 def CASE3( self, main ):
115 import time
116 import imp
andrew@onlab.us1bc346b2015-05-21 17:21:16 -0400117
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400118 main.case( 'Activate applications and check installation' )
119 # Activate applications and check consistency
120 # across clusters
121 appClassName = main.params['DEP']['appClassName']
122 appSrc = main.params['DEP']['appSrc']
123
andrew@onlab.us9da18f22015-05-28 21:10:24 -0400124 logClassName = main.params['DEP']['logClassName']
125 logSrc = main.params['DEP']['logSrc']
126
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400127 # Import application file to use its methods
128 try:
129 app = imp.load_source( appClassName, appSrc )
andrew@onlab.us9da18f22015-05-28 21:10:24 -0400130 onosLog = imp.load_source( logClassName, logSrc )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400131 except ImportError:
132 main.log.error( "Error importing class " +
133 str(startupClassName) + " from " + str(startupSrc) )
134 main.cleanup()
135 main.exit()
andrew@onlab.us484ef832015-05-29 16:08:27 -0400136
137 # NOTE: Test only
138 # Unceremoniously kill onos 2
139 main.ONOSbench.onosDie( '10.128.174.2' )
140
141 time.sleep( 30 )
142
143 main.step( 'Sample Onos log check' )
144 logResult = onosLog.checkOnosLog( main.ONOSips[0] )
145 main.log.info( logResult )
146 # TODO: Define assertion pass / fail criteria
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400147
148 # Sample app activation
149 main.step( 'Activating applications metrics and fwd' )
150 appList = ['metrics', 'fwd']
151 appResult = app.activate( appList )
152 utilities.assert_equals( expect=main.TRUE,
153 actual=appResult,
154 onpass= 'App activation of ' + str(appList) + ' successful',
155 onfail= 'App activation failed ' + str(appResult) )
156
andrew@onlab.usb3a48492015-06-04 18:50:10 -0400157 def CASE4( self, main ):
158 """
159 Download ONOS tar.gz built from latest nightly
160 (following tutorial on wiki) and run ONOS directly on the
161 instance
162 """
163 import imp
164
165 targz = main.params['DEP']['targz']
166 clusterCount = main.params['CTRL']['num']
167
168 startClassName = main.params['DEP']['startupClassName']
169 startSrc = main.params['DEP']['startupSrc']
170
171 shutdownClassName = main.params['DEP']['shutdownClassName']
172 shutdownSrc = main.params['DEP']['shutdownSrc']
173
174 # Import files to use its methods
175 try:
176 startup = imp.load_source( startClassName, startSrc )
177 shutdown = imp.load_source( shutdownClassName, shutdownSrc )
178 except ImportError:
179 main.log.error( "Error importing class " +
180 str(startupClassName) + " from " + str(startupSrc) )
181 main.cleanup()
182 main.exit()
183
184 main.case( 'Install ONOS from onos.tar.gz file' )
185
186 main.step( 'Killing all ONOS instances previous started' )
187 killResult = shutdown.killOnosNodes( main.ONOSips )
188 utilities.assert_equals( expect=main.TRUE,
189 actual = killResult,
190 onpass = 'All Onos nodes successfully killed',
191 onfail = 'Onos nodes were not successfully killed' )
192
193 main.step( 'Starting ONOS using tar.gz on all nodes' )
194 installResult = startup.installOnosFromTar( targz, main.ONOSips )
195 utilities.assert_equals( expect=main.TRUE,
196 actual = installResult,
197 onpass= 'Onos tar.gz installation successful',
198 onfail= 'Onos tar.gz installation failed' )
199
200
201
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400202
203