Issue-ID: RIC-149
[it/test.git] / ric_robot_suite / helm / nanobot / configmap-src / public / resources / appmgr_interface.robot
1 #   Copyright (c) 2019 AT&T Intellectual Property.
2 #   Copyright (c) 2020 HCL Technologies Limited. 
3 #   Licensed under the Apache License, Version 2.0 (the "License");
4 #   you may not use this file except in compliance with the License.
5 #   You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #   Unless required by applicable law or agreed to in writing, software
10 #   distributed under the License is distributed on an "AS IS" BASIS,
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #   See the License for the specific language governing permissions and
13 #   limitations under the License.
14
15 **settings *** 
16 Documentation  Keywords for interacting with the XApp Manager, including listing, deploying, and undeploying XApps 
17  
18 Library        RequestsLibrary 
19 Library                 Process 
20 Library                 Collections 
21 Library                 OperatingSystem 
22  
23 Resource       /robot/resources/global_properties.robot 
24 Resource       /robot/resources/ric/ric_utils.robot 
25  
26 *** Variables *** 
27 ${APPMGR_BASE_PATH}  /ric/v1/xapps 
28 ${APPMGR_ENDPOINT}   ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT} 
29  
30 *** Keywords *** 
31 Run AppMgr Health Check 
32      [Documentation]    Runs AppMgr Health check 
33      ${resp}=        Run Keyword        Get Deployed XApps 
34  
35 Get Deployed XApps 
36      [Documentation]  Obtain the list of deployed XApps from the Appmgr 
37      ${resp} =        Run AppMgr GET Request 
38      [Return]         ${resp.json()} 
39  
40 Get Deployable XApps 
41      [Documentation]  Obtain the list of deployed XApps from the Appmgr 
42      #${resp} =        Run AppMgr GET Request  /search/ 
43      ${resp} =        Run AppMgr GET Request 
44      Should Be True   ${resp} 
45      [Return]         ${resp.json()} 
46  
47 Get XApp By Name 
48      [Documentation]  Get installed XApp from Appmgr given name 
49      [Arguments]      ${xapp_name} 
50      ${resp} =        Run AppMgr GET Request  /${xapp_name} 
51      Should Be True   ${resp} 
52      [Return]         ${resp.json()} 
53  
54 Get XApp By Name and ID 
55      [Documentation]  Get installed XApp from Appmgr by name and ID 
56      [Arguments]      ${xapp_name}  ${xapp_id} 
57      ${resp}=         Run AppMgr GET Request  /${xapp_name}/${xapp_id}/ 
58      Should Be True   ${resp} 
59      [Return]         ${resp.json()} 
60  
61 Deploy XApp 
62      [Documentation]  Create Xapp 
63      [Arguments]      ${xapp_name} 
64      &{dict} =        Create Dictionary        xappName=${xapp_name} 
65      ${data} =        Evaluate                 json.dumps(&{dict})  json 
66      Log To Console     ${dict} 
67      Log To Console     ${data} 
68      ${resp} =        Run AppMgr POST Request  ${EMPTY}             ${data} 
69      Should Be True   ${resp} 
70      [Return]         ${resp} 
71  
72 Deploy XApps 
73      [Documentation]  Create one or more XApps 
74      [Arguments]      @{xapp_names} 
75      FOR             ${xapp}  IN             @{xapp_names} 
76                      Deploy XApp   ${xapp} 
77      END 
78  
79 Undeploy XApp 
80      [Documentation]  Remove a deployed XApp 
81      [Arguments]      ${xapp_name} 
82      ${resp} =        Run AppMgr DELETE Request  /${xapp_name} 
83      Should Be True   ${resp} 
84      [Return]         ${resp} 
85  
86 Undeploy XApps 
87      [Documentation]  Remove one or more deployed XApps 
88      [Arguments]      @{xapp_names} 
89      FOR             ${xapp}  IN     @{xapp_names} 
90                      Undeploy XApp   ${xapp} 
91  
92 Deploy All Available XApps 
93      [Documentation]  Attempt to deploy any not-currently-deployed XApp 
94      @{d} =          Get Deployed XApps 
95      @{deployed} =   Pluck               name          ${d} 
96      @{available} =  Get Deployable XApps 
97      @{toDeploy} =   Subtract From List  ${available}  ${deployed} 
98      Deploy XApps    @{toDeploy} 
99  
100 Undeploy All Running XApps 
101      [Documentation]  Undeploy any deployed XApps 
102      @{d} =           Get Deployed XApps 
103      @{deployed} =    Pluck  name  ${d} 
104      Run Keyword If   ${deployed}  Undeploy XApps  @{deployed} 
105  
106 Run AppMgr GET Request 
107      [Documentation]  Make an HTTP GET request against the XApp manager 
108      [Arguments]   ${path}=${EMPTY} 
109      ${session} =  Create Session     roboAppmgrGet                   ${APPMGR_ENDPOINT} 
110      ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json 
111      ${resp} =     Get Request        roboAppmgrGet                   ${APPMGR_BASE_PATH}${path}  headers=${headers} 
112      [Return]      ${resp} 
113  
114 Run AppMgr POST Request 
115      [Documentation]    Make an HTTP POST request against the XApp manager 
116      [Arguments]   ${path}=${EMPTY}   ${body}=${EMPTY} 
117      ${session} =  Create Session     roboAppmgrPost                  ${APPMGR_ENDPOINT} 
118      ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json 
119      Log To Console     ${headers}.... 
120      Log To Console     ${body}.... 
121      ${resp} =     Post Request       roboAppmgrPost                  ${APPMGR_BASE_PATH}${path}  headers=${headers}  data=${body} 
122      [Return]      ${resp} 
123  
124 Run AppMgr DELETE Request 
125      [Documentation]  Make an HTTP DELETE request against the XApp manager 
126      [Arguments]      ${path} 
127      ${session} =     Create Session     roboAppmgrDelete                ${APPMGR_ENDPOINT} 
128      ${headers} =     Create Dictionary  Accept=application/json         Content-Type=application/json 
129      ${resp} =        Delete Request     roboAppmgrDelete                ${APPMGR_BASE_PATH}${path}  headers=${headers} 
130      [Return]         ${resp} 
131  
132