Release image version 1.12.2
[testsuite.git] / robot / resources / aai / aai_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with A&AI. It handles low level stuff like managing the http request library and A&AI required fields
3 Library               RequestsLibrary
4 Library           ONAPLibrary.Utilities
5 Library           ONAPLibrary.AAI    WITH NAME     AAI
6 Resource            ../global_properties.robot
7
8 *** Variables ***
9 ${AAI_HEALTH_PATH}  /aai/util/echo?action=long
10 ${VERSIONED_INDEX_PATH}     /aai/v19
11 ${AAI_FRONTEND_ENDPOINT}    ${GLOBAL_AAI_SERVER_PROTOCOL}://${GLOBAL_INJECTED_AAI_IP_ADDR}:${GLOBAL_AAI_SERVER_PORT}
12 ${model_invariant_id}    AAI-HealthCheck-Dummy
13 ${data_path}                ${VERSIONED_INDEX_PATH}/service-design-and-creation/models/model/${model_invariant_id}
14 ${PUT_data}    {"model-invariant-id": "AAI-HealthCheck-Dummy","model-type": "service"}
15 ${traversal_data_path}    ${VERSIONED_INDEX_PATH}/query?format=count
16 ${traversal_data}   {"start" : "service-design-and-creation/models"}
17
18
19 *** Keywords ***
20 Run A&AI Health Check
21     [Documentation]    Runs an A&AI health check
22     ${resp}=    AAI.Run Get Request    ${AAI_FRONTEND_ENDPOINT}    ${AAI_HEALTH_PATH}    auth=${GLOBAL_AAI_AUTHENTICATION}
23     Should Be Equal As Strings  ${resp.status_code}     200
24
25 Run Resource API AAI Inventory check
26     [Documentation]    Runs  A&AI Inventory health check Resource API
27     ${GET_res}=    AAI.Run Get Request    ${AAI_FRONTEND_ENDPOINT}    ${data_path}    auth=${GLOBAL_AAI_AUTHENTICATION}
28     Run Keyword If    ${GET_res.status_code}== 200    Run Delete dummy data     ${GET_res}
29     Run Resource API
30
31 Run Delete dummy data
32     [Documentation]    Delete Existing dummy data
33     [Arguments]   ${GET_res}
34     ${json} =      Set Variable   ${GET_res.json()}
35     ${resource_version}  Set Variable  ${json["resource-version"]}
36     ${delete_response}=    AAI.Run Delete Request    ${AAI_FRONTEND_ENDPOINT}    ${data_path}    ${resource_version}    auth=${GLOBAL_AAI_AUTHENTICATION}
37     Should Be Equal As Strings  ${delete_response.status_code}     204
38
39 Run Resource API
40     [Documentation]    Resource API check with put get and delete request
41     #PUT Request
42     ${Put_resp}=    AAI.Run Put Request    ${AAI_FRONTEND_ENDPOINT}    ${data_path}    ${PUT_data}    auth=${GLOBAL_AAI_AUTHENTICATION}
43     Should Be Equal As Strings  ${Put_resp.status_code}     201
44     #GET Request
45     ${GET_resp}=    AAI.Run Get Request    ${AAI_FRONTEND_ENDPOINT}    ${data_path}    auth=${GLOBAL_AAI_AUTHENTICATION}
46     Should Be Equal As Strings  ${GET_resp.status_code}     200
47     ${res_body}=   Convert to string     ${GET_resp.content}
48     Should contain    ${res_body}   ${model_invariant_id}
49     #DELETE Request
50     Run Delete dummy data    ${GET_resp}
51
52 Run Traversal API AAI Inventory check
53     [Documentation]    Runs  A&AI Inventory health check Traversal API
54     ${Put_resp}=    AAI.Run Put Request    ${AAI_FRONTEND_ENDPOINT}    ${traversal_data_path}    ${traversal_data}    auth=${GLOBAL_AAI_AUTHENTICATION}
55     Should Be Equal As Strings  ${Put_resp.status_code}     200
56
57 Delete A&AI Entity
58     [Documentation]    Deletes an entity in A&AI
59     [Arguments]    ${uri}
60     ${resp}=    AAI.Run Get Request    ${AAI_FRONTEND_ENDPOINT}    ${VERSIONED_INDEX_PATH}${uri}    auth=${GLOBAL_AAI_AUTHENTICATION}
61         Run Keyword If    '${resp.status_code}' == '200'    Delete A&AI Entity Exists    ${uri}    ${resp.json()['resource-version']}
62
63 Delete A&AI Entity Exists
64     [Documentation]    Deletes an  A&AI entity
65     [Arguments]    ${uri}    ${resource_version_id}
66     ${put_resp}=    AAI.Run Delete Request    ${AAI_FRONTEND_ENDPOINT}    ${VERSIONED_INDEX_PATH}${uri}    ${resource_version_id}    auth=${GLOBAL_AAI_AUTHENTICATION}
67     Should Be Equal As Strings  ${put_resp.status_code}         204