blob: e55758fc6bcaa1a4bf1804c3fd21a27ddc9028e8 [file] [log] [blame]
Carmelo Cascone384aade2019-07-03 15:36:04 -07001#!/usr/bin/env python2.7
Ray Milkeya2b52b42019-02-07 09:25:27 -08002
Carmelo Cascone384aade2019-07-03 15:36:04 -07003import sys
Ray Milkeya2b52b42019-02-07 09:25:27 -08004
5SCENARIO_HEADER = '''
6<!--
7 ~ Copyright 2019-present Open Networking Foundation
8 ~
9 ~ Licensed under the Apache License, Version 2.0 (the "License");
10 ~ you may not use this file except in compliance with the License.
11 ~ You may obtain a copy of the License at
12 ~
13 ~ http://www.apache.org/licenses/LICENSE-2.0
14 ~
15 ~ Unless required by applicable law or agreed to in writing, software
16 ~ distributed under the License is distributed on an "AS IS" BASIS,
17 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 ~ See the License for the specific language governing permissions and
19 ~ limitations under the License.
20 -->
21
22 <!--
23 This scenario is auto generated by onos-generate-activate-all-scenario. DO NOT EDIT
24 -->
25 <scenario name="app-activate-all" description="Tests that all apps can be activated by themselves">
26 <group name="App-Activate-All">
27 <step name="App-Activate-All.Minimal-Apps"
28 exec="onos-set-up-minimal-apps ${OCI}"/>
Ray Milkey1f0fb3b2019-02-26 08:45:48 -080029 <step name="App-Activate-All.Count-Components"
30 exec="onos-find-component-count ${OC1} starting" requires="^"/>
Ray Milkeya2b52b42019-02-07 09:25:27 -080031'''
32
33SCENARIO_FOOTER = '''
34 </group>
35 </scenario>
36'''
37
38ACTIVATE_GROUP_TEMPLATE = '''
39 <group name="App-Activate-All.%(app_id)s" %(requires)s>
40 <step name="App-Activate-All.Activate-%(app_id)s"
41 exec="onos ${OCI} app activate org.onosproject.%(app_id)s" %(requires)s/>
42 <group name="App-Activate-All.App-Check-%(app_id)s" requires="App-Activate-All.Activate-%(app_id)s">
43 <parallel var="${OC#}">
44 <step name="App-Activate-All.App-Check-${#}-%(app_id)s"
45 exec="onos-check-apps ${OC#} %(app_id)s includes"/>
46 <step name="App-Activate-All.Check-Logs-${#}-%(app_id)s" exec="onos-check-logs ${OC#}"/>
47 </parallel>
48 </group>
49 <step name="App-Activate-All.App-Deactivate-%(app_id)s"
50 exec="onos ${OCI} app deactivate org.onosproject.%(app_id)s" requires="App-Activate-All.App-Check-%(app_id)s"/>
51 <step name="App-Activate-All.Wait-For-Deactivate-%(app_id)s"
Ray Milkey1f0fb3b2019-02-26 08:45:48 -080052 exec="onos-check-component-count ${OCI} ${startingcount}" requires="App-Activate-All.App-Deactivate-%(app_id)s"/>
Ray Milkeya2b52b42019-02-07 09:25:27 -080053 <group name="App-Activate-All.App-Check-After-%(app_id)s" requires="App-Activate-All.Wait-For-Deactivate-%(app_id)s">
54 <parallel var="${OC#}">
55 <step name="App-Activate-All.Check-Logs-After-${#}-%(app_id)s" exec="onos-check-logs ${OC#}"/>
56 </parallel>
57 </group>
58 <step name="App-Activate-All.Minimal-Apps-%(app_id)s" requires="App-Activate-All.App-Deactivate-%(app_id)s"
59 exec="onos-set-up-minimal-apps ${OCI}"/>
60 </group>
61
62'''
63
64app_list = []
65app_list_file = ""
66
67if len(sys.argv) > 1:
68 app_list_file = sys.argv[1]
69else:
70 print "Usage: onos-generate-activate-all-scenario file-name-of-app-list"
71 sys.exit()
72
73with open(app_list_file) as apps:
74 for app in apps:
75 if not "#" in app:
76 normalized_app = app.strip(" \n")
77 if not normalized_app == "":
78 app_list.append(normalized_app)
79
80scenario = SCENARIO_HEADER + "\n"
81
82app_group_requires = 'requires="App-Activate-All.Minimal-Apps"'
83for app_id in app_list:
84 parameters = {
85 'requires': app_group_requires,
86 'app_id': app_id,
87 }
88 scenario = scenario + (ACTIVATE_GROUP_TEMPLATE % parameters)
89 app_group_requires = 'requires="App-Activate-All.' + app_id + '"'
90
91scenario = scenario + SCENARIO_FOOTER
92
93print scenario
94