blob: 60b1aa0046f0737a764cebde27279d03ed4b33b7 [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.us19b5e042015-06-05 13:14:02 -040039 import imp
40
andrew@onlab.usd2d36fc2015-05-29 14:27:54 -040041 # NOTE: Hardcoded application name subject to change
andrew@onlab.us9da18f22015-05-28 21:10:24 -040042 # closely monitor and make changes when necessary
43 # (or implement ways to dynamically get names)
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040044 main.appList = {
45 'bgprouter' : 'org.onosproject.bgprouter',
46 'config' : 'org.onosproject.config',
47 'cordfabric' : 'org.onosproject.cordfabric',
48 'demo' : 'org.onosproject.demo',
49 'distributedprimitives' : 'org.onosproject.distributedprimitives',
50 'election' : 'org.onosproject.election',
51 'flowrule' : 'org.onosproject.flowrule',
52 'fwd' : 'org.onosproject.fwd',
53 'intentperf' : 'org.onosproject.intentperf',
54 'messagingperf' : 'org.onosproject.messagingperf',
55 'metrics' : 'org.onosproject.metrics',
56 'mobility' : 'org.onosproject.mobility',
57 'netconf' : 'org.onosproject.netconf',
58 'null' : 'org.onosproject.null',
andrew@onlab.us19b5e042015-06-05 13:14:02 -040059 'optical' : 'org.onosproject.optical',
60 'pcep' : 'org.onosproject.pcep',
61 'proxyarp' : 'org.onosproject.proxyarp',
62 'reactive.routing' : 'org.onosproject.reactive.routing',
63 'sdnip' : 'org.onosproject.sdnip',
64 'segmentrouting' : 'org.onosproject.segmentrouting',
65 'tunnel' : 'org.onosproject.tunnel',
66 'virtualbng' : 'org.onosproject.virtualbng',
67 'xosintegration' : 'org.onosproject.xosintegration'
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040068 }
69 # List of ONOS ip's specififed in params
70 main.ONOSips = []
71 main.CLIs = []
andrew@onlab.us9da18f22015-05-28 21:10:24 -040072 main.ONOSnode = []
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040073
74 for node in range( 0, int(main.params['CTRL']['num']) ):
75 main.ONOSips.append( main.params['CTRL']['ip'+str(node+1)] )
76 main.CLIs.append(
77 getattr( main, 'ONOS' + str(node+1) + 'cli' ) )
andrew@onlab.us9da18f22015-05-28 21:10:24 -040078 main.ONOSnode.append(
79 getattr( main, 'ONOS' + str(node+1) ) )
andrew@onlab.us19b5e042015-06-05 13:14:02 -040080
81 # Application source and name definitions
82 startupSrc = main.params['DEP']['startupSrc']
83 startupClassName = main.params['DEP']['startupClassName']
84
85 appClassName = main.params['DEP']['appClassName']
86 appSrc = main.params['DEP']['appSrc']
87
88 logClassName = main.params['DEP']['logClassName']
89 logSrc = main.params['DEP']['logSrc']
90
91 shutdownClassName = main.params['DEP']['shutdownClassName']
92 shutdownSrc = main.params['DEP']['shutdownSrc']
93
94 # Importing dependency class(es)
95 # Refer to source files in Dependency folder to
96 # make changes to its respective methods
97 # Be weary of naming collisions
98 try:
99 main.startup = imp.load_source( startupClassName, startupSrc )
100 main.app = imp.load_source( appClassName, appSrc )
101 main.onosLog = imp.load_source( logClassName, logSrc )
102 main.shutdown = imp.load_source( shutdownClassName, shutdownSrc )
103 except ImportError:
104 main.log.error( 'Error importing class file(s). Please ' +
105 'check file location' )
106 main.cleanup()
107 main.exit()
andrew@onlab.us9da18f22015-05-28 21:10:24 -0400108
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400109 def CASE2( self, main ):
andrew@onlab.us1bc346b2015-05-21 17:21:16 -0400110 import time
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400111
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400112 cellName = main.params['CELL']['name']
113 appStr = main.params['CELL']['appStr']
114 benchIp = main.params['BENCH']['ip']
115 branchName = main.params['GIT']['branchName']
116 gitPull = main.params['GIT']['pull']
117 mnIp = main.params['MN']['ip']
118
andrew@onlab.us1bc346b2015-05-21 17:21:16 -0400119 main.case( 'Setup environment and install ONOS' )
120 if gitPull == 'on':
121 main.step( 'Git pull and clean install' )
andrew@onlab.us19b5e042015-06-05 13:14:02 -0400122 gitPullResult = main.startup.gitPullAndMci( branchName )
andrew@onlab.us1bc346b2015-05-21 17:21:16 -0400123 utilities.assert_equals( expect=main.TRUE,
124 actual=gitPullResult,
125 onpass='Git pull and install successful',
126 onfail='Git pull and install failed: ' +
127 str(gitPullResult) )
128
129 main.step( 'Initiate ONOS startup sequence' )
andrew@onlab.us19b5e042015-06-05 13:14:02 -0400130 startupResult = main.startup.initOnosStartupSequence(
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400131 cellName, appStr, benchIp, mnIp, main.ONOSips )
andrew@onlab.us1bc346b2015-05-21 17:21:16 -0400132 utilities.assert_equals( expect=main.TRUE,
133 actual=startupResult,
134 onpass='ONOS startup sequence successful',
135 onfail='ONOS startup sequence failed: ' +
136 str(startupResult) )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400137
138 def CASE3( self, main ):
139 import time
andrew@onlab.us1bc346b2015-05-21 17:21:16 -0400140
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400141 main.case( 'Activate applications and check installation' )
andrew@onlab.us484ef832015-05-29 16:08:27 -0400142
143 # NOTE: Test only
144 # Unceremoniously kill onos 2
145 main.ONOSbench.onosDie( '10.128.174.2' )
146
147 time.sleep( 30 )
148
149 main.step( 'Sample Onos log check' )
andrew@onlab.us19b5e042015-06-05 13:14:02 -0400150 logResult = main.onosLog.checkOnosLog( main.ONOSips[0] )
andrew@onlab.us484ef832015-05-29 16:08:27 -0400151 main.log.info( logResult )
andrew@onlab.us19b5e042015-06-05 13:14:02 -0400152 # TODO: Define pass criteria
153 utilities.assert_equals( expect=main.TRUE,
154 actual=main.TRUE,
155 onpass= 'Logging successful',
156 onfail= 'Logging failed ' )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400157
158 # Sample app activation
159 main.step( 'Activating applications metrics and fwd' )
160 appList = ['metrics', 'fwd']
andrew@onlab.us19b5e042015-06-05 13:14:02 -0400161 appResult = main.app.activate( appList )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400162 utilities.assert_equals( expect=main.TRUE,
163 actual=appResult,
164 onpass= 'App activation of ' + str(appList) + ' successful',
165 onfail= 'App activation failed ' + str(appResult) )
166
andrew@onlab.usb3a48492015-06-04 18:50:10 -0400167 def CASE4( self, main ):
168 """
169 Download ONOS tar.gz built from latest nightly
170 (following tutorial on wiki) and run ONOS directly on the
171 instance
172 """
173 import imp
174
175 targz = main.params['DEP']['targz']
176 clusterCount = main.params['CTRL']['num']
177
andrew@onlab.usb3a48492015-06-04 18:50:10 -0400178 main.case( 'Install ONOS from onos.tar.gz file' )
179
180 main.step( 'Killing all ONOS instances previous started' )
andrew@onlab.us19b5e042015-06-05 13:14:02 -0400181 killResult = main.shutdown.killOnosNodes( main.ONOSips )
andrew@onlab.usb3a48492015-06-04 18:50:10 -0400182 utilities.assert_equals( expect=main.TRUE,
183 actual = killResult,
184 onpass = 'All Onos nodes successfully killed',
185 onfail = 'Onos nodes were not successfully killed' )
186
187 main.step( 'Starting ONOS using tar.gz on all nodes' )
andrew@onlab.us19b5e042015-06-05 13:14:02 -0400188 installResult = main.startup.installOnosFromTar( targz, main.ONOSips )
andrew@onlab.usb3a48492015-06-04 18:50:10 -0400189 utilities.assert_equals( expect=main.TRUE,
190 actual = installResult,
191 onpass= 'Onos tar.gz installation successful',
192 onfail= 'Onos tar.gz installation failed' )
193
194