blob: 6b681a735ed9dbe0bf1dd3995ab5d755a8f5d076 [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()
136
137 # Sample app activation
138 main.step( 'Activating applications metrics and fwd' )
139 appList = ['metrics', 'fwd']
140 appResult = app.activate( appList )
141 utilities.assert_equals( expect=main.TRUE,
142 actual=appResult,
143 onpass= 'App activation of ' + str(appList) + ' successful',
144 onfail= 'App activation failed ' + str(appResult) )
145
andrew@onlab.us9da18f22015-05-28 21:10:24 -0400146 main.step( 'Sample Onos log check' )
147 logResult = onosLog.getOnosLog( main.ONOSips[0] )
148 main.log.info( logResult )
149 # TODO: Define assertion pass / fail criteria
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400150
151