IMPL: A1 <-> XApp Message Flow Testing
[it/test.git] / ric_robot_suite / helm / nanobot / configmap-src / public / testsuites / a1mediator.robot
1 #   Copyright (c) 2019 AT&T Intellectual Property.
2 #
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   Tests for the A1 Mediator
17
18 Resource       /robot/resources/global_properties.robot
19 Resource       /robot/resources/a1mediator/a1mediator_interface.robot
20 Resource       /robot/resources/appmgr/appmgr_interface.robot
21
22 Library  UUID
23
24 *** Variables ***
25 ${POLICY_ID}    ${GLOBAL_A1MEDIATOR_POLICY_ID}
26 ${TARGET_XAPP}  ${GLOBAL_A1MEDIATOR_TARGET_XAPP}
27
28 *** Test Cases ***
29 Deploy Target XApp If Necessary
30   [Tags]  etetests  ci_tests  a1tests  intrusive
31   ${err}  ${xappStatus} =  Run Keyword And Ignore Error
32   ...                      Get XApp By Name          ${TARGET_XAPP}
33   Run Keyword If           '${err}' == 'FAIL'
34   ...                      Deploy XApp               ${TARGET_XAPP}
35   
36 Create Policy
37   [Tags]  etetests  ci_tests  a1tests  intrusive
38   ${policyProperty} =      Create Dictionary
39   ...                      type=string
40   ...                      description=a message
41   ${policyProperties} =    Create Dictionary
42   ...                      message=${policyProperty}
43   ${policyName} =          Generate UUID
44   ${policyName} =          Convert To String         ${policyName}
45   Set Suite Variable       ${policyName}
46   ${resp} =                Create A1 Policy Type
47   ...                      ${POLICY_ID}
48   ...                      ${policyName}
49   ...                      ${policyName}
50   ...                      ${policyProperties}
51   Should Be True           ${resp}
52   
53 Policy Should Exist
54   [Tags]  etetests  ci_tests  a1tests
55   ${resp} =                Retrieve A1 Policy        ${POLICY_ID}
56   Should Be True           ${resp}
57   Should Be Equal          ${resp.json()}[name]      ${policyName}
58   
59 Create Policy Instance
60   [Tags]  etetests  ci_tests  a1tests  intrusive
61   ${instanceName} =        Generate UUID
62   ${instanceName} =        Convert To String         ${instanceName}
63   Set Suite Variable       ${instanceName}
64   ${instanceMessage} =     Generate UUID
65   ${instanceMessage} =     Convert To String         ${instanceMessage}
66   ${instanceProperties} =  Create Dictionary
67   ...                      message=${instanceMessage}
68   Set Suite Variable       ${instanceMessage}
69   ${resp} =                Instantiate A1 Policy
70   ...                      ${POLICY_ID}
71   ...                      ${instanceName}
72   ...                      ${instanceProperties}
73   Should Be True           ${resp}
74   
75 Policy Should Have Instances
76   [Tags]  etetests  ci_tests  a1tests
77   ${resp} =                Retrieve A1 Instance      ${POLICY_ID}
78   Should Be True           ${resp}
79   Should Not Be Empty      ${resp.json()}
80   
81 Instance Should Exist
82   [Tags]  etetests  ci_tests  a1tests
83   ${resp} =                Retrieve A1 Instance      ${POLICY_ID}     ${instanceName}
84   Should Be True           ${resp}
85   Should Be Equal          ${resp.json()}[message]   ${instanceMessage}
86
87 Instance Should Be IN EFFECT
88   [Tags]  etetests  ci_tests  a1tests
89   Wait Until Keyword Succeeds  3x  5s                Status Is IN EFFECT
90
91 Delete Policy Instance
92   [Tags]  etetests  ci_tests  a1tests  intrusive
93   ${resp} =                Delete A1 Instance       ${POLICY_ID}      ${instanceName}
94   Should Be True           ${resp}
95
96 Instance Should Not Exist
97   [Tags]  etetests  ci_tests  a1tests
98   Wait Until Keyword Succeeds  3x  5s               Instance Has Been Deleted
99   
100 Delete Policy
101   [Tags]  etetests  ci_tests  a1tests  intrusive
102   ${resp} =                Delete A1 Policy         ${POLICY_ID}
103   Should Be True           ${resp}
104
105 Policy Should Not Exist
106   [Tags]  etetests  ci_tests  a1tests
107   Wait Until Keyword Succeeds  3x  5s               Policy Has Been Deleted
108
109 Undeploy Target XApp
110   [Tags]  etetests  ci_tests  a1tests  intrusive
111   Undeploy XApp            ${TARGET_XAPP}
112   
113 *** Keywords ***
114 Status Is IN EFFECT
115   ${resp} =                Retrieve A1 Instance Status
116   ...                      ${POLICY_ID}
117   ...                      ${instanceName}
118   Should Be True           ${resp}  
119   Should Be Equal          ${resp.json()}[instance_status]    IN EFFECT
120
121 Instance Has Been Deleted
122   ${resp} =                   Retrieve A1 Instance
123   ...                         ${POLICY_ID}
124   ...                         ${instanceName}
125   Should Be Equal As Strings  ${resp.status_code}  404
126
127 Policy Has Been Deleted
128   ${resp} =                   Retrieve A1 Policy   ${POLICY_ID}
129   Should Be Equal As Strings  ${resp.status_code}  404