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}"/> |
Ray Milkey | 1f0fb3b | 2019-02-26 08:45:48 -0800 | [diff] [blame] | 29 | <step name="App-Activate-All.Count-Components" |
| 30 | exec="onos-find-component-count ${OC1} starting" requires="^"/> |
Ray Milkey | a2b52b4 | 2019-02-07 09:25:27 -0800 | [diff] [blame] | 31 | ''' |
| 32 | |
| 33 | SCENARIO_FOOTER = ''' |
| 34 | </group> |
| 35 | </scenario> |
| 36 | ''' |
| 37 | |
| 38 | ACTIVATE_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 Milkey | 1f0fb3b | 2019-02-26 08:45:48 -0800 | [diff] [blame] | 52 | exec="onos-check-component-count ${OCI} ${startingcount}" requires="App-Activate-All.App-Deactivate-%(app_id)s"/> |
Ray Milkey | a2b52b4 | 2019-02-07 09:25:27 -0800 | [diff] [blame] | 53 | <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 | |
| 64 | app_list = [] |
| 65 | app_list_file = "" |
| 66 | |
| 67 | if len(sys.argv) > 1: |
| 68 | app_list_file = sys.argv[1] |
| 69 | else: |
| 70 | print "Usage: onos-generate-activate-all-scenario file-name-of-app-list" |
| 71 | sys.exit() |
| 72 | |
| 73 | with 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 | |
| 80 | scenario = SCENARIO_HEADER + "\n" |
| 81 | |
| 82 | app_group_requires = 'requires="App-Activate-All.Minimal-Apps"' |
| 83 | for 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 | |
| 91 | scenario = scenario + SCENARIO_FOOTER |
| 92 | |
| 93 | print scenario |
| 94 | |