blob: 6bcb06c712ca8ff03409799ab25d943d58314cd7 [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.us1bc346b2015-05-21 17:21:16 -040022contributers to contact for help:
23andrew@onlab.us
24"""
25
26class FuncPlatform:
27 def __init__( self ):
28 self.default = ''
29
30 def CASE1( self, main ):
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040031 """
32 Main scope initialization case
33 """
34 main.appList = {
35 'bgprouter' : 'org.onosproject.bgprouter',
36 'config' : 'org.onosproject.config',
37 'cordfabric' : 'org.onosproject.cordfabric',
38 'demo' : 'org.onosproject.demo',
39 'distributedprimitives' : 'org.onosproject.distributedprimitives',
40 'election' : 'org.onosproject.election',
41 'flowrule' : 'org.onosproject.flowrule',
42 'fwd' : 'org.onosproject.fwd',
43 'intentperf' : 'org.onosproject.intentperf',
44 'messagingperf' : 'org.onosproject.messagingperf',
45 'metrics' : 'org.onosproject.metrics',
46 'mobility' : 'org.onosproject.mobility',
47 'netconf' : 'org.onosproject.netconf',
48 'null' : 'org.onosproject.null',
49 'optical' : 'org.onosproject.optical'
50 }
51 # List of ONOS ip's specififed in params
52 main.ONOSips = []
53 main.CLIs = []
54
55 for node in range( 0, int(main.params['CTRL']['num']) ):
56 main.ONOSips.append( main.params['CTRL']['ip'+str(node+1)] )
57 main.CLIs.append(
58 getattr( main, 'ONOS' + str(node+1) + 'cli' ) )
59
60 def CASE2( self, main ):
andrew@onlab.us1bc346b2015-05-21 17:21:16 -040061 import time
62 import imp
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040063
64 startupSrc = main.params['DEP']['startupSrc']
65 startupClassName = main.params['DEP']['startupClassName']
66 cellName = main.params['CELL']['name']
67 appStr = main.params['CELL']['appStr']
68 benchIp = main.params['BENCH']['ip']
69 branchName = main.params['GIT']['branchName']
70 gitPull = main.params['GIT']['pull']
71 mnIp = main.params['MN']['ip']
72
andrew@onlab.us1bc346b2015-05-21 17:21:16 -040073 # importing dependency class(es)
74 # Refer to source files in Dependency folder to
75 # make changes to its respective methods
76 try:
77 startup = imp.load_source( startupClassName, startupSrc )
78 except ImportError:
79 main.log.error( "Error importing class " +
80 str(startupClassName) + " from " + str(startupSrc) )
81 main.cleanup()
82 main.exit()
83
andrew@onlab.us1bc346b2015-05-21 17:21:16 -040084 main.case( 'Setup environment and install ONOS' )
85 if gitPull == 'on':
86 main.step( 'Git pull and clean install' )
87 gitPullResult = startup.gitPullAndMci( branchName )
88 utilities.assert_equals( expect=main.TRUE,
89 actual=gitPullResult,
90 onpass='Git pull and install successful',
91 onfail='Git pull and install failed: ' +
92 str(gitPullResult) )
93
94 main.step( 'Initiate ONOS startup sequence' )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040095 startupResult = startup.initOnosStartupSequence(
96 cellName, appStr, benchIp, mnIp, main.ONOSips )
andrew@onlab.us1bc346b2015-05-21 17:21:16 -040097 utilities.assert_equals( expect=main.TRUE,
98 actual=startupResult,
99 onpass='ONOS startup sequence successful',
100 onfail='ONOS startup sequence failed: ' +
101 str(startupResult) )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400102
103 def CASE3( self, main ):
104 import time
105 import imp
andrew@onlab.us1bc346b2015-05-21 17:21:16 -0400106
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -0400107 main.case( 'Activate applications and check installation' )
108 # Activate applications and check consistency
109 # across clusters
110 appClassName = main.params['DEP']['appClassName']
111 appSrc = main.params['DEP']['appSrc']
112
113 # Import application file to use its methods
114 try:
115 app = imp.load_source( appClassName, appSrc )
116 except ImportError:
117 main.log.error( "Error importing class " +
118 str(startupClassName) + " from " + str(startupSrc) )
119 main.cleanup()
120 main.exit()
121
122 # Sample app activation
123 main.step( 'Activating applications metrics and fwd' )
124 appList = ['metrics', 'fwd']
125 appResult = app.activate( appList )
126 utilities.assert_equals( expect=main.TRUE,
127 actual=appResult,
128 onpass= 'App activation of ' + str(appList) + ' successful',
129 onfail= 'App activation failed ' + str(appResult) )
130
131
132