blob: c12400bb43e7b949b49097de76a17828a62532d1 [file] [log] [blame]
#!/usr/bin/env python
import sys, os
SCENARIO_HEADER = '''
<!--
~ Copyright 2019-present Open Networking Foundation
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!--
This scenario is auto generated by onos-generate-activate-all-scenario. DO NOT EDIT
-->
<scenario name="app-activate-all" description="Tests that all apps can be activated by themselves">
<group name="App-Activate-All">
<step name="App-Activate-All.Minimal-Apps"
exec="onos-set-up-minimal-apps ${OCI}"/>
'''
SCENARIO_FOOTER = '''
</group>
</scenario>
'''
ACTIVATE_GROUP_TEMPLATE = '''
<group name="App-Activate-All.%(app_id)s" %(requires)s>
<step name="App-Activate-All.Activate-%(app_id)s"
exec="onos ${OCI} app activate org.onosproject.%(app_id)s" %(requires)s/>
<group name="App-Activate-All.App-Check-%(app_id)s" requires="App-Activate-All.Activate-%(app_id)s">
<parallel var="${OC#}">
<step name="App-Activate-All.App-Check-${#}-%(app_id)s"
exec="onos-check-apps ${OC#} %(app_id)s includes"/>
<step name="App-Activate-All.Check-Logs-${#}-%(app_id)s" exec="onos-check-logs ${OC#}"/>
</parallel>
</group>
<step name="App-Activate-All.App-Deactivate-%(app_id)s"
exec="onos ${OCI} app deactivate org.onosproject.%(app_id)s" requires="App-Activate-All.App-Check-%(app_id)s"/>
<step name="App-Activate-All.Wait-For-Deactivate-%(app_id)s"
exec="onos-check-apps ${OCI} org.onosproject.drivers" requires="App-Activate-All.App-Deactivate-%(app_id)s"/>
<group name="App-Activate-All.App-Check-After-%(app_id)s" requires="App-Activate-All.Wait-For-Deactivate-%(app_id)s">
<parallel var="${OC#}">
<step name="App-Activate-All.Check-Logs-After-${#}-%(app_id)s" exec="onos-check-logs ${OC#}"/>
</parallel>
</group>
<step name="App-Activate-All.Minimal-Apps-%(app_id)s" requires="App-Activate-All.App-Deactivate-%(app_id)s"
exec="onos-set-up-minimal-apps ${OCI}"/>
</group>
'''
app_list = []
app_list_file = ""
if len(sys.argv) > 1:
app_list_file = sys.argv[1]
else:
print "Usage: onos-generate-activate-all-scenario file-name-of-app-list"
sys.exit()
with open(app_list_file) as apps:
for app in apps:
if not "#" in app:
normalized_app = app.strip(" \n")
if not normalized_app == "":
app_list.append(normalized_app)
scenario = SCENARIO_HEADER + "\n"
app_group_requires = 'requires="App-Activate-All.Minimal-Apps"'
for app_id in app_list:
parameters = {
'requires': app_group_requires,
'app_id': app_id,
}
scenario = scenario + (ACTIVATE_GROUP_TEMPLATE % parameters)
app_group_requires = 'requires="App-Activate-All.' + app_id + '"'
scenario = scenario + SCENARIO_FOOTER
print scenario