Ray Milkey | a2b52b4 | 2019-02-07 09:25:27 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import sys, os |
| 4 | |
| 5 | SCENARIO_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}"/> |
| 29 | ''' |
| 30 | |
| 31 | SCENARIO_FOOTER = ''' |
| 32 | </group> |
| 33 | </scenario> |
| 34 | ''' |
| 35 | |
| 36 | ACTIVATE_GROUP_TEMPLATE = ''' |
| 37 | <group name="App-Activate-All.%(app_id)s" %(requires)s> |
| 38 | <step name="App-Activate-All.Activate-%(app_id)s" |
| 39 | exec="onos ${OCI} app activate org.onosproject.%(app_id)s" %(requires)s/> |
| 40 | <group name="App-Activate-All.App-Check-%(app_id)s" requires="App-Activate-All.Activate-%(app_id)s"> |
| 41 | <parallel var="${OC#}"> |
| 42 | <step name="App-Activate-All.App-Check-${#}-%(app_id)s" |
| 43 | exec="onos-check-apps ${OC#} %(app_id)s includes"/> |
| 44 | <step name="App-Activate-All.Check-Logs-${#}-%(app_id)s" exec="onos-check-logs ${OC#}"/> |
| 45 | </parallel> |
| 46 | </group> |
| 47 | <step name="App-Activate-All.App-Deactivate-%(app_id)s" |
| 48 | exec="onos ${OCI} app deactivate org.onosproject.%(app_id)s" requires="App-Activate-All.App-Check-%(app_id)s"/> |
| 49 | <step name="App-Activate-All.Wait-For-Deactivate-%(app_id)s" |
| 50 | exec="onos-check-apps ${OCI} org.onosproject.drivers" requires="App-Activate-All.App-Deactivate-%(app_id)s"/> |
| 51 | <group name="App-Activate-All.App-Check-After-%(app_id)s" requires="App-Activate-All.Wait-For-Deactivate-%(app_id)s"> |
| 52 | <parallel var="${OC#}"> |
| 53 | <step name="App-Activate-All.Check-Logs-After-${#}-%(app_id)s" exec="onos-check-logs ${OC#}"/> |
| 54 | </parallel> |
| 55 | </group> |
| 56 | <step name="App-Activate-All.Minimal-Apps-%(app_id)s" requires="App-Activate-All.App-Deactivate-%(app_id)s" |
| 57 | exec="onos-set-up-minimal-apps ${OCI}"/> |
| 58 | </group> |
| 59 | |
| 60 | ''' |
| 61 | |
| 62 | app_list = [] |
| 63 | app_list_file = "" |
| 64 | |
| 65 | if len(sys.argv) > 1: |
| 66 | app_list_file = sys.argv[1] |
| 67 | else: |
| 68 | print "Usage: onos-generate-activate-all-scenario file-name-of-app-list" |
| 69 | sys.exit() |
| 70 | |
| 71 | with open(app_list_file) as apps: |
| 72 | for app in apps: |
| 73 | if not "#" in app: |
| 74 | normalized_app = app.strip(" \n") |
| 75 | if not normalized_app == "": |
| 76 | app_list.append(normalized_app) |
| 77 | |
| 78 | scenario = SCENARIO_HEADER + "\n" |
| 79 | |
| 80 | app_group_requires = 'requires="App-Activate-All.Minimal-Apps"' |
| 81 | for app_id in app_list: |
| 82 | parameters = { |
| 83 | 'requires': app_group_requires, |
| 84 | 'app_id': app_id, |
| 85 | } |
| 86 | scenario = scenario + (ACTIVATE_GROUP_TEMPLATE % parameters) |
| 87 | app_group_requires = 'requires="App-Activate-All.' + app_id + '"' |
| 88 | |
| 89 | scenario = scenario + SCENARIO_FOOTER |
| 90 | |
| 91 | print scenario |
| 92 | |