summaryrefslogtreecommitdiffstats
path: root/test/csit/tests/policy/suite1/Policy-CSIT.robot
blob: be52cd2ea5109cdff44d2d810436b63a6b2740fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
*** Settings ***
Documentation   Policy ONAP CSIT Test cases
Library    String
Library    HttpLibrary.HTTP
LIbrary    Process
Resource    policy_interface.robot
Resource    json_templater.robot

*** Variables ***
${RESOURCE_PATH_CREATE}        /pdp/createPolicy
${RESOURCE_PATH_CREATE_PUSH}        /pdp/pushPolicy
${RESOURCE_PATH_CREATE_DELETE}        /pdp/deletePolicy
${RESOURCE_PATH_GET_CONFIG}    /pdp/getConfig
${CREATE_CONFIG_VFW_TEMPLATE}    ${CURDIR}/configpolicy_vFW.template
${CREATE_CONFIG_VDNS_TEMPLATE}    ${CURDIR}/configpolicy_vDNS.template
${CREATE_CONFIG_VCPE_TEMPLATE}    ${CURDIR}/configpolicy_vCPE.template
${CREATE_OPS_VFW_TEMPLATE}    ${CURDIR}/opspolicy_VFW.template
${PUSH_POLICY_TEMPLATE}   ${CURDIR}/pushpolicy.template
${CREATE_OPS_VDNS_TEMPLATE}    ${CURDIR}/opspolicy_VDNS.template
${DEL_POLICY_TEMPLATE}   ${CURDIR}/deletepolicy.template
${GETCONFIG_TEMPLATE}    ${CURDIR}/getconfigpolicy.template
${CONFIG_POLICY_VFW_NAME}    vFirewall
${CONFIG_POLICY_VFW_TYPE}    MicroService
${CONFIG_POLICY_VDNS_NAME}    vLoadBalancer
${CONFIG_POLICY_VDNS_TYPE}    MicroService
${OPS_POLICY_VFW_NAME}    vFirewall
${OPS_POLICY_VFW_TYPE}    BRMS_PARAM
${OPS_POLICY_VDNS_NAME}    vLoadBalancer
${OPS_POLICY_VDNS_TYPE}    BRMS_PARAM
${CONFIG_POLICY_VCPE_NAME}    vCPE
${CONFIG_POLICY_VCPE_TYPE}    MicroService
${OPS_POLICY_VCPE_NAME}    vCPE
${OPS_POLICY_VCPE_TYPE}    BRMS_PARAM
${OPS_POLICY_VOLTE_NAME}    VoLTE
${OPS_POLICY_VOLTE_TYPE}    BRMS_PARAM
${file_path}        ../testsuite/robot/assets/templates/ControlLoopDemo__closedLoopControlName.drl
${RESOURCE_PATH_UPLOAD}  /pdp/api/policyEngineImport?importParametersJson=%7B%22serviceName%22%3A%22Manyu456%22%2C%20%22serviceType%22%3A%22BRMSPARAM%22%7D
${CREATE_OPS_VCPE_TEMPLATE}      ${CURDIR}/opspolicy_vCPE.template  
${CREATE_OPS_VOLTE_TEMPLATE}    ${CURDIR}/opspolicy_vOLTE.template


*** Test Cases ***
Policy Health check
    Run Policy Health Check

VFW Config Policy
    ${CONFIG_POLICY_VFW_NAME}=    Create Config VFW Policy
    Push Config Policy    ${CONFIG_POLICY_VFW_NAME}    ${CONFIG_POLICY_VFW_TYPE}
VFW Get Configs Policy
    Get Configs VFW Policy   
    #VFW Policy Tests
    
VDNS Config Policy
    ${CONFIG_POLICY_VDNS_NAME}=    Create Config VDNS Policy
    Push Config Policy    ${CONFIG_POLICY_VDNS_NAME}    ${CONFIG_POLICY_VDNS_TYPE}
    #VDNS Policy Tests
   
VCPE Config Policy
    ${CONFIG_POLICY_VCPE_NAME}=    Create Config VCPE Policy
    Push Config Policy    ${CONFIG_POLICY_VCPE_NAME}    ${CONFIG_POLICY_VCPE_TYPE}
    #VCPE Policy Tests
 
#VOLTE Policy
    #VOLTE Policy Tests
    
*** Keywords ***

VFW Policy Tests
     ${CONFIG_POLICY_VFW_NAME}=    Create Config VFW Policy
     Push Config Policy    ${CONFIG_POLICY_VFW_NAME}    ${CONFIG_POLICY_VFW_TYPE}
     Get Configs VFW Policy    
     ${OPS_POLICY_VFW_NAME}=    Create Ops VFW Policy
     Push Ops Policy    ${OPS_POLICY_VFW_NAME}    ${OPS_POLICY_VFW_TYPE}
    
VDNS Policy Tests
     ${CONFIG_POLICY_VDNS_NAME}=    Create Config VDNS Policy
     Push Config Policy    ${CONFIG_POLICY_VDNS_NAME}    ${CONFIG_POLICY_VDNS_TYPE}
     Get Configs VDNS Policy
     ${OPS_POLICY_VDNS_NAME}=    Create Ops VDNS Policy
     Push Ops Policy    ${OPS_POLICY_VDNS_NAME}    ${OPS_POLICY_VDNS_TYPE}

VCPE Policy Tests
     ${CONFIG_POLICY_VCPE_NAME}=    Create Config VCPE Policy
     Push Config Policy    ${CONFIG_POLICY_VCPE_NAME}    ${CONFIG_POLICY_VCPE_TYPE}
     Get Configs VCPE Policy    
     ${OPS_POLICY_VCPE_NAME}=    Create Ops VCPE Policy
     Push Ops Policy    ${OPS_POLICY_VCPE_NAME}    ${OPS_POLICY_VCPE_TYPE}
     
VOLTE Policy Tests  
     ${OPS_POLICY_VOLTE_NAME}=    Create Ops VOLTE Policy
     Push Ops Policy    ${OPS_POLICY_VOLTE_NAME}    ${OPS_POLICY_VOLTE_TYPE}
     
Get Configs VFW Policy
    [Documentation]    Get Config Policy for VFW
    ${getconfigpolicy}=    Catenate    .*${CONFIG_POLICY_VFW_NAME}*
    ${configpolicy_name}=    Create Dictionary    config_policy_name=${getconfigpolicy}
    ${output} =     Fill JSON Template File     ${GETCONFIG_TEMPLATE}    ${configpolicy_name}
    ${get_resp} =    Run Policy Get Configs Request    ${RESOURCE_PATH_GET_CONFIG}   ${output}
  Should Be Equal As Strings  ${get_resp.status_code}   200
  
Create Config VFW Policy
    [Documentation]    Create Config Policy
    ${randompolicyname} =     Create Policy Name
    ${policyname1}=    Catenate   com.${randompolicyname}_vFirewall
    ${CONFIG_POLICY_VFW_NAME}=    Set Test Variable    ${policyname1}
    ${configpolicy}=    Create Dictionary    policy_name=${policyname1}
    ${output} =     Fill JSON Template File     ${CREATE_CONFIG_VFW_TEMPLATE}    ${configpolicy}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE}  ${output}
  Should Be Equal As Strings  ${put_resp.status_code}   200
  [Return]    ${policyname1}

 Create Policy Name
     [Documentation]    Generate Policy Name
     [Arguments]    ${prefix}=CSIT_
     ${random}=    Generate Random String    15    [LOWER][NUMBERS]
     ${policyname}=    Catenate    ${prefix}${random}
     [Return]    ${policyname}

Create Ops VFW Policy
  [Documentation]    Create Opertional Policy
    ${randompolicyname} =     Create Policy Name
  ${policyname1}=    Catenate   com.${randompolicyname}_vFirewall
  ${OPS_POLICY_VFW_NAME}=    Set Test Variable    ${policyname1}
  ${dict}=     Create Dictionary    policy_name=${policyname1}
  ${output} =     Fill JSON Template File     ${CREATE_OPS_VFW_TEMPLATE}    ${dict}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE}  ${output}
    Log    ${put_resp}
    Should Be Equal As Strings  ${put_resp.status_code}   200
    [Return]    ${policyname1}

Push Ops Policy
    [Documentation]    Push Ops Policy
    [Arguments]    ${policyname}    ${policytype}
    ${dict}=     Create Dictionary     policy_name=${policyname}    policy_type=${policytype}
  ${output} =     Fill JSON Template File    ${PUSH_POLICY_TEMPLATE}     ${dict}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE_PUSH}  ${output}
    Should Be Equal As Strings  ${put_resp.status_code}   200

Push Config Policy
    [Documentation]    Push Config Policy
    [Arguments]    ${policyname}    ${policytype}
    ${dict}=     Create Dictionary     policy_name=${policyname}    policy_type=${policytype}
  ${output} =     Fill JSON Template File    ${PUSH_POLICY_TEMPLATE}     ${dict}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE_PUSH}  ${output}
    Should Be Equal As Strings  ${put_resp.status_code}   200

Delete Ops Policy
    [Documentation]    Delete Config Policy
    [Arguments]    ${policy_name}
    ${policyname3}=    Catenate   com.Config_BRMS_Param_${policyname}.1.xml
    ${dict}=     Create Dictionary     policy_name=${policyname3}
  ${output} =     Fill JSON Template     ${DEL_POLICY_TEMPLATE}     ${dict}
    ${put_resp} =    Run Policy Delete Request    ${RESOURCE_PATH_CREATE_DELETE}  ${output}
    Should Be Equal As Strings  ${put_resp.status_code}   200

Delete Config Policy
    [Documentation]    Delete Ops Policy
    [Arguments]    ${policy_name}
    ${policyname3}=    Catenate   com.Config_MS_com.${policy_name}.1.xml
    ${dict}=     Create Dictionary     policy_name=${policyname3}
  ${output} =     Fill JSON Template     ${DEL_POLICY_TEMPLATE}     ${dict}
    ${put_resp} =    Run Policy Delete Request    ${RESOURCE_PATH_CREATE_DELETE}  ${output}
    Should Be Equal As Strings  ${put_resp.status_code}   200

Get Configs VDNS Policy
    [Documentation]    Get Config Policy for VDNS
    ${getconfigpolicy}=    Catenate    .*${CONFIG_POLICY_VDNS_NAME}*
    ${configpolicy_name}=    Create Dictionary    config_policy_name=${getconfigpolicy}
    ${output} =     Fill JSON Template File     ${GETCONFIG_TEMPLATE}    ${configpolicy_name}
    ${get_resp} =    Run Policy Get Configs Request    ${RESOURCE_PATH_GET_CONFIG}   ${output}
  Should Be Equal As Strings  ${get_resp.status_code}   200
  
Create Config VDNS Policy
    [Documentation]    Create Config Policy
    ${randompolicyname} =     Create Policy Name
    ${policyname1}=    Catenate   com.${randompolicyname}_vLoadBalancer
    ${CONFIG_POLICY_VDNS_NAME}=    Set Test Variable    ${policyname1}
    ${configpolicy}=    Create Dictionary    policy_name=${policyname1}
    ${output} =     Fill JSON Template File     ${CREATE_CONFIG_VDNS_TEMPLATE}    ${configpolicy}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE}  ${output}
  Should Be Equal As Strings  ${put_resp.status_code}   200
  [Return]    ${policyname1}

Create Ops VDNS Policy
  [Documentation]    Create Opertional Policy
    ${randompolicyname} =     Create Policy Name
  ${policyname1}=    Catenate   com.${randompolicyname}_vLoadBalancer
  ${OPS_POLICY_VDNS_NAME}=    Set Test Variable    ${policyname1}
  ${dict}=     Create Dictionary    policy_name=${policyname1}
  ${output} =     Fill JSON Template File     ${CREATE_OPS_VDNS_TEMPLATE}    ${dict}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE}  ${output}
    Log    ${put_resp}
    Should Be Equal As Strings  ${put_resp.status_code}   200
    [Return]    ${policyname1}
    
Create Config VCPE Policy
    [Documentation]    Create Config Policy
    ${randompolicyname} =     Create Policy Name
    ${policyname1}=    Catenate   com.${randompolicyname}_vFirewall
    ${CONFIG_POLICY_VCPE_NAME}=    Set Test Variable    ${policyname1}
    ${configpolicy}=    Create Dictionary    policy_name=${policyname1}
    ${output} =     Fill JSON Template File     ${CREATE_CONFIG_VCPE_TEMPLATE}    ${configpolicy}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE}  ${output}
  Should Be Equal As Strings  ${put_resp.status_code}   200
  [Return]    ${policyname1}
  
Get Configs VCPE Policy
    [Documentation]    Get Config Policy for VCPE
    ${getconfigpolicy}=    Catenate    .*${CONFIG_POLICY_VCPE_NAME}*
    ${configpolicy_name}=    Create Dictionary    config_policy_name=${getconfigpolicy}
    ${output} =     Fill JSON Template File     ${GETCONFIG_TEMPLATE}    ${configpolicy_name}
    ${get_resp} =    Run Policy Get Configs Request    ${RESOURCE_PATH_GET_CONFIG}   ${output}
  Should Be Equal As Strings  ${get_resp.status_code}   200

Create Ops vCPE Policy
  [Documentation]    Create Opertional Policy
    ${randompolicyname} =     Create Policy Name
  ${policyname1}=    Catenate   com.${randompolicyname}
  ${OPS_POLICY_NAME}=    Set Test Variable    ${policyname1}
  ${dict}=     Create Dictionary    policy_name=${OPS_POLICY_NAME}
  ${NEWPOLICY1}=     Create Dictionary    policy_name=com.${OPS_POLICY_NAME}
  ${output} =     Fill JSON Template File     ${CREATE_OPS_VCPE_TEMPLATE}    ${dict}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE}  ${output}
    Log    ${put_resp}
    Should Be Equal As Strings  ${put_resp.status_code}   200
    
Create Ops VolTE Policy
  [Documentation]    Create Opertional Policy
    ${randompolicyname} =     Create Policy Name
  ${policyname2}=    Catenate   com.${randompolicyname}
  #${OPS_POLICY_VOLTE_NAME}=    Set Test Variable    ${policyname2}
  ${dict}=     Create Dictionary    policy_name=${policyname2}
  #${NEWPOLICY1}=     Create Dictionary    policy_name=com.${OPS_POLICY_NAME}
  ${output} =     Fill JSON Template File     ${CREATE_OPS_VOLTE_TEMPLATE}    ${dict}
    ${put_resp} =    Run Policy Put Request    ${RESOURCE_PATH_CREATE}  ${output}
    Log    ${put_resp}
    Should Be Equal As Strings  ${put_resp.status_code}   200
    
Upload DRL file
    [Documentation]    Upload DRL file1
    ${file_data}=     Get Binary File  ${file_path}
    ${files}=    Create Dictionary    file=${file_data}
   #${CONFIG_POLICY_VDNS_NAME}=    Set Test Variable    ${policyname1}
   # ${files2} = {'file': open('../testsuite/robot/assets/templates/ControlLoopDemo__closedLoopControlName.drl', 'rb')}
   # ${files}=  Create Dictionary  file  ${file_data}
    ${put_resp} =    Run Policy Post form Request    ${RESOURCE_PATH_UPLOAD}    ${files}      
  Should Be Equal As Strings  ${put_resp.status_code}   200