9d69520ab042972f8d3a5bb8de958376b491eb12
[policy/docker.git] / csit / resources / tests / policy-clamp-test.robot
1 *** Settings ***
2 Library     Collections
3 Library     RequestsLibrary
4 Library     OperatingSystem
5 Library     String
6 Library     json
7 Library     yaml
8 Resource    common-library.robot
9
10 *** Test Cases ***
11 HealthcheckAcm
12      [Documentation]    Healthcheck on Clamp Acm
13      ${auth}=    Create List    runtimeUser    zb!XztG34
14      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
15      ${session}=    Create Session      ACM  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
16      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
17      ${resp}=   GET On Session     ACM  /onap/policy/clamp/acm/health     headers=${headers}
18      Log    Received response from ACM healthcheck {resp.text}
19      Should Be Equal As Strings    ${resp.status_code}     200
20
21 HealthcheckParticipantSim
22      [Documentation]    Healthcheck on Participant Simulator
23      ${auth}=    Create List    participantUser    zb!XztG34
24      Log    Creating session http://${POLICY_PARTICIPANT_SIM_IP}
25      ${session}=    Create Session      participant  http://${POLICY_PARTICIPANT_SIM_IP}   auth=${auth}
26      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
27      ${resp}=   GET On Session     participant  /onap/policy/simparticipant/health     headers=${headers}
28      Log    Received response from participant healthcheck {resp.text}
29      Should Be Equal As Strings    ${resp.status_code}     200
30
31 HealthcheckApi
32      [Documentation]    Healthcheck on policy-api
33      Wait Until Keyword Succeeds    5 min    10 sec    VerifyHealthcheckApi
34
35 HealthcheckPap
36      [Documentation]    Healthcheck on policy-pap
37      Wait Until Keyword Succeeds    5 min    10 sec    VerifyHealthcheckPap
38
39 RegisterParticipants
40      [Documentation]  Register Participants.
41      ${auth}=    Create List    runtimeUser    zb!XztG34
42      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
43      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
44      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/participants
45      Log    Received response from runtime acm ${resp.text}
46      Should Be Equal As Strings    ${resp.status_code}     202
47
48 CommissionAutomationComposition
49      [Documentation]  Commission automation composition definition.
50      ${auth}=    Create List    runtimeUser    zb!XztG34
51      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
52      ${postyaml}=  Get file  ${CURDIR}/data/acelement-usecase.yaml
53      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
54      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
55      ${resp}=   POST On Session     policy  /onap/policy/clamp/acm/v2/compositions   data=${postyaml}  headers=${headers}
56      Log    Received response from runtime acm ${resp.text}
57      ${respyaml}=  yaml.Safe Load  ${resp.text}
58      set Suite variable  ${compositionId}  ${respyaml["compositionId"]}
59      Should Be Equal As Strings    ${resp.status_code}     201
60
61 CommissionAcDefinitionMigrationFrom
62      [Documentation]  Commission automation composition definition From.
63      ${auth}=    Create List    runtimeUser    zb!XztG34
64      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
65      ${postyaml}=  Get file  ${CURDIR}/data/ac-definition-migration-from.yaml
66      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
67      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
68      ${resp}=   POST On Session     policy  /onap/policy/clamp/acm/v2/compositions   data=${postyaml}  headers=${headers}
69      Log    Received response from runtime acm ${resp.text}
70      ${respyaml}=  yaml.Safe Load  ${resp.text}
71      set Suite variable  ${compositionFromId}  ${respyaml["compositionId"]}
72      Should Be Equal As Strings    ${resp.status_code}     201
73
74 CommissionAcDefinitionMigrationTo
75      [Documentation]  Commission automation composition definition To.
76      ${auth}=    Create List    runtimeUser    zb!XztG34
77      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
78      ${postyaml}=  Get file  ${CURDIR}/data/ac-definition-migration-to.yaml
79      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
80      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
81      ${resp}=   POST On Session     policy  /onap/policy/clamp/acm/v2/compositions   data=${postyaml}  headers=${headers}
82      Log    Received response from runtime acm ${resp.text}
83      ${respyaml}=  yaml.Safe Load  ${resp.text}
84      set Suite variable  ${compositionToId}  ${respyaml["compositionId"]}
85      Should Be Equal As Strings    ${resp.status_code}     201
86
87 PrimeACDefinitions
88      [Documentation]  Prime automation composition definition
89      ${auth}=    Create List    runtimeUser    zb!XztG34
90      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
91      ${postjson}=  Get file  ${CURDIR}/data/ACPriming.json
92      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
93      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
94      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}   data=${postjson}  headers=${headers}
95      Should Be Equal As Strings    ${resp.status_code}     202
96      Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionId}  PRIMED
97
98 PrimeACDefinitionFrom
99      [Documentation]  Prime automation composition definition Migration From.
100      ${auth}=    Create List    runtimeUser    zb!XztG34
101      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
102      ${postjson}=  Get file  ${CURDIR}/data/ACPriming.json
103      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
104      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
105      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionFromId}   data=${postjson}  headers=${headers}
106      Should Be Equal As Strings    ${resp.status_code}     202
107      Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionFromId}  PRIMED
108
109 PrimeACDefinitionTo
110      [Documentation]  Prime automation composition definition Migration To.
111      ${auth}=    Create List    runtimeUser    zb!XztG34
112      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
113      ${postjson}=  Get file  ${CURDIR}/data/ACPriming.json
114      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
115      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
116      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionToId}   data=${postjson}  headers=${headers}
117      Should Be Equal As Strings    ${resp.status_code}     202
118      Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionToId}  PRIMED
119
120 InstantiateAutomationComposition
121      [Documentation]  Instantiate automation composition.
122      ${auth}=    Create List    runtimeUser    zb!XztG34
123      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
124      Run Keyword If    '${TEST_ENV}'=='k8s'    set Suite variable  ${instantiationfile}  AcK8s.json
125
126      ...    ELSE    set Suite variable  ${instantiationfile}  AcDocker.json
127      ${postjson}=  Get file  ${CURDIR}/data/${instantiationfile}
128      ${updatedpostjson}=   Replace String     ${postjson}     COMPOSITIONIDPLACEHOLDER       ${compositionId}
129      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
130      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
131      ${resp}=   POST On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}/instances   data=${updatedpostjson}  headers=${headers}
132      Log    Received response from runtime acm ${resp.text}
133      ${respyaml}=  yaml.Safe Load  ${resp.text}
134      set Suite variable  ${instanceId}    ${respyaml["instanceId"]}
135      Should Be Equal As Strings    ${resp.status_code}     201
136
137 InstantiateAutomationCompositionMigrationFrom
138      [Documentation]  Instantiate automation composition migration.
139      ${auth}=    Create List    runtimeUser    zb!XztG34
140      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
141      ${postyaml}=  Get file  ${CURDIR}/data/ac-instance-migration-from.yaml
142      ${updatedpostyaml}=   Replace String     ${postyaml}     COMPOSITIONIDPLACEHOLDER       ${compositionFromId}
143      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
144      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
145      ${resp}=   POST On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances   data=${updatedpostyaml}  headers=${headers}
146      Log    Received response from runtime acm ${resp.text}
147      ${respyaml}=  yaml.Safe Load  ${resp.text}
148      set Suite variable  ${instanceMigrationId}    ${respyaml["instanceId"]}
149      Should Be Equal As Strings    ${resp.status_code}     201
150
151 DeployAutomationComposition
152      [Documentation]  Deploy automation composition.
153      ${auth}=    Create List    runtimeUser    zb!XztG34
154      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
155      ${postjson}=  Get file  ${CURDIR}/data/DeployAC.json
156      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
157      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
158      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}/instances/${instanceId}   data=${postjson}  headers=${headers}
159      Log    Received response from runtime acm ${resp.text}
160      Should Be Equal As Strings    ${resp.status_code}     202
161      Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionId}  ${instanceId}  DEPLOYED
162
163 CheckTraces
164      [Documentation]    Verify that traces are being recorded in jaeger
165      Log    Verifying Jaeger traces
166      ${acmResp}=    VerifyTracingWorks    ${JAEGER_IP}    acm-r
167      ${httpResp}=    VerifyTracingWorks    ${JAEGER_IP}    http-ppnt
168      ${policyResp}=    VerifyTracingWorks    ${JAEGER_IP}    policy-ppnt
169      ${k8sResp}=    VerifyTracingWorks    ${JAEGER_IP}    k8s-ppnt
170      Should Not Be Empty    ${acmResp.json()["data"][0]["spans"][0]["spanID"]}
171      Log  Received spanID is ${acmResp.json()["data"][0]["spans"][0]["spanID"]}
172      Should Not Be Empty    ${httpResp.json()["data"][0]["spans"][0]["spanID"]}
173      Should Not Be Empty    ${policyResp.json()["data"][0]["spans"][0]["spanID"]}
174      Should Not Be Empty    ${k8sResp.json()["data"][0]["spans"][0]["spanID"]}
175
176 CheckKafkaPresentInTraces
177      [Documentation]    Verify that kafka traces are being recorded in jaeger
178      Log    Verifying Kafka Jaeger traces
179      ${acmResp}=    VerifyKafkaInTraces    ${JAEGER_IP}    acm-r
180      ${httpResp}=    VerifyKafkaInTraces    ${JAEGER_IP}    http-ppnt
181      ${policyResp}=    VerifyKafkaInTraces    ${JAEGER_IP}    policy-ppnt
182      ${k8sResp}=    VerifyKafkaInTraces    ${JAEGER_IP}    k8s-ppnt
183      Should Not Be Empty    ${acmResp.json()["data"][0]["spans"][0]["spanID"]}
184      Log  Received spanID is ${acmResp.json()["data"][0]["spans"][0]["spanID"]}
185      Should Not Be Empty    ${httpResp.json()["data"][0]["spans"][0]["spanID"]}
186      Should Not Be Empty    ${policyResp.json()["data"][0]["spans"][0]["spanID"]}
187      Should Not Be Empty    ${k8sResp.json()["data"][0]["spans"][0]["spanID"]}
188
189 CheckHttpPresentInAcmTraces
190      [Documentation]    Verify that http traces are being recorded in jaeger
191      Log    Verifying Http Jaeger traces
192      ${acmResp}=    VerifyHttpInTraces    ${JAEGER_IP}    acm-r
193      Should Not Be Empty    ${acmResp.json()["data"][0]["spans"][0]["spanID"]}
194      Log  Received spanID is ${acmResp.json()["data"][0]["spans"][0]["spanID"]}
195
196 QueryPolicies
197      [Documentation]    Verify the new policies deployed
198      ${auth}=    Create List    policyadmin    zb!XztG34
199      Sleep  10s
200      Log    Creating session http://${POLICY_PAP_IP}
201      ${session}=    Create Session      policy  http://${POLICY_PAP_IP}   auth=${auth}
202      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
203      ${resp}=   GET On Session     policy  /policy/pap/v1/policies/deployed     headers=${headers}
204      Log    Received response from policy-pap {resp.text}
205      Should Be Equal As Strings    ${resp.status_code}     200
206      Dictionary Should Contain Value  ${resp.json()[0]}  onap.policies.native.apex.ac.element
207
208 QueryPolicyTypes
209      [Documentation]    Verify the new policy types created
210      ${auth}=    Create List    policyadmin    zb!XztG34
211      Sleep  10s
212      Log    Creating session http://${POLICY_API_IP}:6969
213      ${session}=    Create Session      policy  http://${POLICY_API_IP}   auth=${auth}
214      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
215      ${resp}=   GET On Session     policy  /policy/api/v1/policytypes     headers=${headers}
216      Log    Received response from policy-api ${resp.text}
217      Should Be Equal As Strings    ${resp.status_code}     200
218      List Should Contain Value  ${resp.json()['policy_types']}  onap.policies.native.Apex
219
220 DeployAutomationCompositionMigration
221      [Documentation]  Deploy automation composition.
222      ${auth}=    Create List    runtimeUser    zb!XztG34
223      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
224      ${postjson}=  Get file  ${CURDIR}/data/DeployAC.json
225      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
226      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
227      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances/${instanceMigrationId}   data=${postjson}  headers=${headers}
228      Log    Received response from runtime acm ${resp.text}
229      Should Be Equal As Strings    ${resp.status_code}     202
230      Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionFromId}  ${instanceMigrationId}  DEPLOYED
231
232 SendOutPropertiesToRuntime
233      [Documentation]  Send Out Properties To Runtime
234      ${auth}=    Create List    participantUser    zb!XztG34
235      Log    Creating session http://${POLICY_PARTICIPANT_SIM_IP}
236      ${postjson}=  Get file  ${CURDIR}/data/OutProperties.json
237      ${updatedpostjson}=   Replace String     ${postjson}     INSTACEIDPLACEHOLDER       ${instanceMigrationId}
238      ${updatedpostjson}=   Replace String     ${updatedpostjson}     TEXTPLACEHOLDER       MyTextToSend
239      ${session}=    Create Session      policy  http://${POLICY_PARTICIPANT_SIM_IP}   auth=${auth}
240      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
241      ${resp}=   PUT On Session     policy  /onap/policy/simparticipant/v2/datas   data=${updatedpostjson}  headers=${headers}
242      Log    Received response from participant sim ${resp.text}
243      Should Be Equal As Strings    ${resp.status_code}     200
244      Wait Until Keyword Succeeds    2 min    5 sec    VerifyPropertiesUpdated  ${compositionFromId}  ${instanceMigrationId}  MyTextToSend
245
246 AutomationCompositionUpdate
247      [Documentation]  Update of an automation composition.
248      ${auth}=    Create List    runtimeUser    zb!XztG34
249      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
250      ${postyaml}=  Get file  ${CURDIR}/data/ac-instance-update.yaml
251      ${updatedpostyaml}=   Replace String     ${postyaml}     COMPOSITIONIDPLACEHOLDER       ${compositionFromId}
252      ${updatedpostyaml}=   Replace String     ${updatedpostyaml}     INSTACEIDPLACEHOLDER       ${instanceMigrationId}
253      ${updatedpostyaml}=   Replace String     ${updatedpostyaml}     TEXTPLACEHOLDER       MyTextUpdated
254      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
255      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
256      ${resp}=   POST On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances   data=${updatedpostyaml}  headers=${headers}
257      Log    Received response from runtime acm ${resp.text}
258      Should Be Equal As Strings    ${resp.status_code}     200
259      Wait Until Keyword Succeeds    2 min    5 sec    VerifyDeployStatus  ${compositionFromId}  ${instanceMigrationId}  DEPLOYED
260      VerifyPropertiesUpdated  ${compositionFromId}  ${instanceMigrationId}  MyTextUpdated
261      VerifyParticipantSim  ${instanceMigrationId}  MyTextUpdated
262
263 AutomationCompositionMigrationTo
264      [Documentation]  Migration of an automation composition.
265      ${auth}=    Create List    runtimeUser    zb!XztG34
266      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
267      ${postyaml}=  Get file  ${CURDIR}/data/ac-instance-migration-to.yaml
268      ${updatedpostyaml}=   Replace String     ${postyaml}     COMPOSITIONIDPLACEHOLDER       ${compositionFromId}
269      ${updatedpostyaml}=   Replace String     ${updatedpostyaml}     COMPOSITIONTARGETIDPLACEHOLDER       ${compositionToId}
270      ${updatedpostyaml}=   Replace String     ${updatedpostyaml}     INSTACEIDPLACEHOLDER       ${instanceMigrationId}
271      ${updatedpostyaml}=   Replace String     ${updatedpostyaml}     TEXTPLACEHOLDER       TextForMigration
272      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
273      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
274      ${resp}=   POST On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances   data=${updatedpostyaml}  headers=${headers}
275      Log    Received response from runtime acm ${resp.text}
276      Should Be Equal As Strings    ${resp.status_code}     200
277      Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionToId}  ${instanceMigrationId}  DEPLOYED
278      VerifyPropertiesUpdated  ${compositionToId}  ${instanceMigrationId}  TextForMigration
279      VerifyParticipantSim  ${instanceMigrationId}  TextForMigration
280
281 UnDeployAutomationComposition
282      [Documentation]  UnDeploy automation composition.
283      ${auth}=    Create List    runtimeUser    zb!XztG34
284      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
285      ${postjson}=  Get file  ${CURDIR}/data/UndeployAC.json
286      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
287      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
288      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}/instances/${instanceId}   data=${postjson}   headers=${headers}
289      Log    Received response from runtime acm ${resp.text}
290      Should Be Equal As Strings    ${resp.status_code}     202
291      Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionId}  ${instanceId}  UNDEPLOYED
292
293 UnDeployAutomationCompositionMigrationTo
294      [Documentation]  UnDeploy automation composition migrated.
295      ${auth}=    Create List    runtimeUser    zb!XztG34
296      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
297      ${postjson}=  Get file  ${CURDIR}/data/UndeployAC.json
298      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
299      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
300      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionToId}/instances/${instanceMigrationId}   data=${postjson}   headers=${headers}
301      Log    Received response from runtime acm ${resp.text}
302      Should Be Equal As Strings    ${resp.status_code}     202
303      Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionToId}  ${instanceMigrationId}  UNDEPLOYED
304
305 UnInstantiateAutomationComposition
306      [Documentation]  Delete automation composition instance.
307      ${auth}=    Create List    runtimeUser    zb!XztG34
308      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
309      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
310      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
311      ${resp}=   DELETE On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}/instances/${instanceId}     headers=${headers}
312      Log    Received response from runtime acm ${resp.text}
313      Should Be Equal As Strings    ${resp.status_code}     202
314      Wait Until Keyword Succeeds    1 min    5 sec    VerifyUninstantiated  ${compositionId}
315
316 UnInstantiateAutomationCompositionMigrationTo
317      [Documentation]  Delete automation composition instance migrated.
318      ${auth}=    Create List    runtimeUser    zb!XztG34
319      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
320      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
321      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
322      ${resp}=   DELETE On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionToId}/instances/${instanceMigrationId}     headers=${headers}
323      Log    Received response from runtime acm ${resp.text}
324      Should Be Equal As Strings    ${resp.status_code}     202
325      Wait Until Keyword Succeeds    1 min    5 sec    VerifyUninstantiated  ${compositionToId}
326
327 DePrimeACDefinitions
328      [Documentation]  DePrime automation composition definition
329      ${auth}=    Create List    runtimeUser    zb!XztG34
330      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
331      ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
332      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
333      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
334      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}   data=${postjson}  headers=${headers}
335      Should Be Equal As Strings    ${resp.status_code}     202
336      Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionId}  COMMISSIONED
337
338 DePrimeACDefinitionsFrom
339      [Documentation]  DePrime automation composition definition migration From.
340      ${auth}=    Create List    runtimeUser    zb!XztG34
341      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
342      ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
343      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
344      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
345      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionFromId}   data=${postjson}  headers=${headers}
346      Should Be Equal As Strings    ${resp.status_code}     202
347      Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionFromId}  COMMISSIONED
348
349 DePrimeACDefinitionsTo
350      [Documentation]  DePrime automation composition definition migration To.
351      ${auth}=    Create List    runtimeUser    zb!XztG34
352      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
353      ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
354      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
355      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
356      ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionToId}   data=${postjson}  headers=${headers}
357      Should Be Equal As Strings    ${resp.status_code}     202
358      Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionToId}  COMMISSIONED
359
360 DeleteACDefinition
361      [Documentation]  Delete automation composition definition.
362      ${auth}=    Create List    runtimeUser    zb!XztG34
363      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
364      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
365      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
366      ${resp}=   DELETE On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}  headers=${headers}
367      Log    Received response from runtime acm ${resp.text}
368      Should Be Equal As Strings    ${resp.status_code}     200
369
370 DeleteACDefinitionFrom
371      [Documentation]  Delete automation composition definition migration From.
372      ${auth}=    Create List    runtimeUser    zb!XztG34
373      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
374      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
375      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
376      ${resp}=   DELETE On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionFromId}  headers=${headers}
377      Log    Received response from runtime acm ${resp.text}
378      Should Be Equal As Strings    ${resp.status_code}     200
379
380 DeleteACDefinitionTo
381      [Documentation]  Delete automation composition definition migration To.
382      ${auth}=    Create List    runtimeUser    zb!XztG34
383      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
384      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
385      ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
386      ${resp}=   DELETE On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionToId}  headers=${headers}
387      Log    Received response from runtime acm ${resp.text}
388      Should Be Equal As Strings    ${resp.status_code}     200
389
390
391 *** Keywords ***
392
393 VerifyHealthcheckApi
394      [Documentation]    Verify Healthcheck on policy-api
395      ${auth}=    Create List    policyadmin    zb!XztG34
396      Log    Creating session http://${POLICY_API_IP}
397      ${session}=    Create Session      policy  http://${POLICY_API_IP}   auth=${auth}
398      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
399      ${resp}=   GET On Session     policy  /policy/api/v1/health     headers=${headers}
400      Log    Received response from policy-api healthcheck ${resp.text}
401      Should Be Equal As Strings    ${resp.status_code}   200
402
403 VerifyHealthcheckPap
404      [Documentation]    Verify Healthcheck on policy-pap
405      ${auth}=    Create List    policyadmin    zb!XztG34
406      Log    Creating session http://${POLICY_PAP_IP}
407      ${session}=    Create Session      policy  http://${POLICY_PAP_IP}   auth=${auth}
408      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
409      ${resp}=   GET On Session     policy  /policy/pap/v1/health     headers=${headers}
410      Log    Received response from policy-pap healthcheck ${resp.text}
411      Should Be Equal As Strings    ${resp.status_code}     200
412
413 VerifyPriming
414     [Arguments]  ${theCompositionId}  ${primestate}
415     [Documentation]    Verify the AC definitions are primed to the participants
416     ${auth}=    Create List    runtimeUser    zb!XztG34
417     Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
418     ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
419     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
420     ${resp}=   GET On Session     policy  /onap/policy/clamp/acm/v2/compositions/${theCompositionId}   headers=${headers}
421     Should Be Equal As Strings    ${resp.status_code}   200
422     Run Keyword If  ${resp.status_code}==200  Should Be Equal As Strings  ${resp.json()['state']}  ${primestate}
423
424 VerifyDeployStatus
425      [Arguments]  ${theCompositionId}  ${theInstanceId}  ${deploystate}
426      [Documentation]  Verify the Deploy status of automation composition.
427      ${auth}=    Create List    runtimeUser    zb!XztG34
428      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
429      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
430      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
431      ${resp}=   GET On Session     policy  /onap/policy/clamp/acm/v2/compositions/${theCompositionId}/instances/${theInstanceId}     headers=${headers}
432      Should Be Equal As Strings    ${resp.status_code}     200
433      Run Keyword If  ${resp.status_code}==200  Should Be Equal As Strings  ${resp.json()['deployState']}  ${deploystate}
434
435 VerifyPropertiesUpdated
436      [Arguments]  ${theCompositionId}  ${theInstanceId}  ${textToFind}
437      [Documentation]  Verify the Deploy status of automation composition.
438      ${auth}=    Create List    runtimeUser    zb!XztG34
439      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
440      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
441      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
442      ${resp}=   GET On Session     policy  /onap/policy/clamp/acm/v2/compositions/${theCompositionId}/instances/${theInstanceId}     headers=${headers}
443      Should Be Equal As Strings    ${resp.status_code}     200
444      ${respstring}   Convert To String   ${resp.json()}
445      Run Keyword If  ${resp.status_code}==200  Should Match Regexp  ${respstring}  ${textToFind}
446
447 VerifyParticipantSim
448      [Arguments]  ${theInstanceId}  ${textToFind}
449      [Documentation]  Query on Participant Simulator
450      ${auth}=    Create List    participantUser    zb!XztG34
451      Log    Creating session http://${POLICY_PARTICIPANT_SIM_IP}
452      ${session}=    Create Session      ACM  http://${POLICY_PARTICIPANT_SIM_IP}   auth=${auth}
453      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
454      ${resp}=   GET On Session     ACM  /onap/policy/simparticipant/v2/instances/${theInstanceId}     headers=${headers}
455      Log    Received response from participant {resp.text}
456      Should Be Equal As Strings    ${resp.status_code}     200
457      ${respstring}   Convert To String   ${resp.json()}
458      Should Match Regexp  ${respstring}  ${textToFind}
459
460 VerifyUninstantiated
461      [Arguments]  ${theCompositionId}
462      [Documentation]  Verify the Uninstantiation of automation composition.
463      ${auth}=    Create List    runtimeUser    zb!XztG34
464      Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
465      ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
466      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
467      ${resp}=   GET On Session     policy  /onap/policy/clamp/acm/v2/compositions/${theCompositionId}/instances     headers=${headers}
468      Should Be Equal As Strings    ${resp.status_code}     200
469      Run Keyword If  ${resp.status_code}==200  Length Should Be  ${resp.json()['automationCompositionList']}  0
470
471