c346e958a7b628fe3d4010af3a53669e398db767
[it/test.git] / ric_robot_suite / robot / resources / appmgr / appmgr_interface.robot
1 *** Settings ***
2 Documentation  Keywords for interacting with the XApp Manager, including listing, deploying, and undeploying XApps
3
4 Library        RequestsLibrary
5
6 Resource       ../global_properties.robot
7
8 Resource       ../ric/ric_utils.robot
9
10 *** Variables ***
11 ${APPMGR_BASE_PATH}  /ric/v1/xapps
12 ${APPMGR_ENDPOINT}   ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
13
14 *** Keywords ***
15 Run AppMgr Health Check
16      [Documentation]    Runs AppMgr Health check
17      Run Keyword        Get Deployed XApps
18
19 Get Deployed XApps
20      [Documentation]  Obtain the list of deployed XApps from the Appmgr
21      ${resp} =        Run AppMgr GET Request
22      [Return]         ${resp.json()}
23
24 Get Deployable XApps
25      [Documentation]  Obtain the list of deployed XApps from the Appmgr
26      ${resp} =        Run AppMgr GET Request  /search/
27      Should Be True   ${resp}
28      [Return]         ${resp.json()}
29
30 Get XApp By Name
31      [Documentation]  Get installed XApp from Appmgr given name
32      [Arguments]      ${xapp_name}
33      ${resp} =        Run AppMgr GET Request  /${xapp_name}
34      Should Be True   ${resp}
35      [Return]         ${resp.json()}
36
37 Get XApp By Name and ID
38      [Documentation]  Get installed XApp from Appmgr by name and ID
39      [Arguments]      ${xapp_name}  ${xapp_id}
40      ${resp}=         Run AppMgr GET Request  /${xapp_name}/${xapp_id}/
41      Should Be True   ${resp}
42      [Return]         ${resp.json()}
43
44 Deploy XApp
45      [Documentation]  Create Xapp
46      [Arguments]      ${xapp_name}
47      &{dict} =        Create Dictionary        name=${xapp_name}
48      ${data} =        Evaluate                 json.dumps(&{dict})  json
49      ${resp} =        Run AppMgr POST Request  ${EMPTY}             ${data}
50      Should Be True   ${resp}
51      [Return]         ${resp}
52
53 Deploy XApps
54      [Documentation]  Create one or more XApps
55      [Arguments]      @{xapp_names}
56      :FOR             ${xapp}  IN             @{xapp_names}
57      \                Deploy XApp   ${xapp}
58
59 Undeploy XApp
60      [Documentation]  Remove a deployed XApp
61      [Arguments]      ${xapp_name}
62      ${resp} =        Run AppMgr DELETE Request  /${xapp_name}
63      Should Be True   ${resp}
64      [Return]         ${resp}
65
66 Undeploy XApps
67      [Documentation]  Remove one or more deployed XApps
68      [Arguments]      @{xapp_names}
69      :FOR             ${xapp}  IN     @{xapp_names}
70      \                Undeploy XApp   ${xapp}
71
72 Deploy All Available XApps
73      [Documentation]  Attempt to deploy any not-currently-deployed XApp
74      @{d} =          Get Deployed XApps
75      @{deployed} =   Pluck               name          ${d}
76      @{available} =  Get Deployable XApps
77      @{toDeploy} =   Subtract From List  ${available}  ${deployed}
78      Deploy XApps    @{toDeploy}
79
80 Undeploy All Running XApps
81      [Documentation]  Undeploy any deployed XApps
82      @{d} =           Get Deployed XApps
83      @{deployed} =    Pluck  name  ${d}
84      Run Keyword If   ${deployed}  Undeploy XApps  @{deployed}
85
86 Run AppMgr GET Request
87      [Documentation]  Make an HTTP GET request against the XApp manager
88      [Arguments]   ${path}=${EMPTY}
89      ${session} =  Create Session     roboAppmgrGet                   ${APPMGR_ENDPOINT}
90      ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json
91      ${resp} =     Get Request        roboAppmgrGet                   ${APPMGR_BASE_PATH}${path}  headers=${headers}
92      [Return]      ${resp}
93
94 Run AppMgr POST Request
95      [Documentation]    Make an HTTP POST request against the XApp manager
96      [Arguments]   ${path}=${EMPTY}   ${body}=${EMPTY}
97      ${session} =  Create Session     roboAppmgrPost                  ${APPMGR_ENDPOINT}
98      ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json
99      ${resp} =     Post Request       roboAppmgrPost                  ${APPMGR_BASE_PATH}${path}  headers=${headers}  data=${body}
100      [Return]      ${resp}
101
102 Run AppMgr DELETE Request
103      [Documentation]  Make an HTTP DELETE request against the XApp manager
104      [Arguments]      ${path}
105      ${session} =     Create Session     roboAppmgrDelete                ${APPMGR_ENDPOINT}
106      ${headers} =     Create Dictionary  Accept=application/json         Content-Type=application/json
107      ${resp} =        Delete Request     roboAppmgrDelete                ${APPMGR_BASE_PATH}${path}  headers=${headers}
108      [Return]         ${resp}