Step 1: Move vm scripts to the right place
[integration/test.git] / csit / suites / lispflowmapping / basic / 020_RPC_CRUD.robot
1 *** Settings ***
2 Documentation     Test suite to verify CRUD operations using RPCs
3 Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           Collections
6 Library           OperatingSystem
7 Library           RequestsLibrary
8 Library           ../../../libraries/Common.py
9 Variables         ../../../variables/Variables.py
10 Resource          ../../../libraries/Utils.robot
11
12 *** Variables ***
13 ${RPC_URL_PREFIX}    /restconf/operations/mappingservice
14 ${IPV4_C_KEY}     ${CURDIR}/../../../variables/lispflowmapping/rpc_add-key_ipv4.json
15 ${IPV4_RD}        ${CURDIR}/../../../variables/lispflowmapping/rpc_get-remove_ipv4.json
16 ${MISS_RD}        ${CURDIR}/../../../variables/lispflowmapping/rpc_get-remove_missing.json
17 ${IPV4_U_KEY}     ${CURDIR}/../../../variables/lispflowmapping/rpc_update-key_ipv4.json
18 ${IPV4_C_MAP}     ${CURDIR}/../../../variables/lispflowmapping/rpc_add-mapping_ipv4_ipv4.json
19 ${IPV4_U_MAP}     ${CURDIR}/../../../variables/lispflowmapping/rpc_update-mapping_ipv4_ipv4.json
20
21 *** Test Cases ***
22 Create Key
23     [Documentation]    Create a key for an IPv4 EID
24     ${add_key}=    OperatingSystem.Get File    ${IPV4_C_KEY}
25     Post Log Check    ${RPC_URL_PREFIX}:add-key    ${add_key}
26
27 Attempt To Create Key Again
28     [Documentation]    Try to overwrite existing IPv4 EID key
29     ${add_key}=    OperatingSystem.Get File    ${IPV4_C_KEY}
30     Post Log Check    ${RPC_URL_PREFIX}:add-key    ${add_key}    409
31
32 Attempt To Read Non-Existing Key
33     [Documentation]    Try to read a non-existing key for an IPv4 EID
34     ${get_key}=    OperatingSystem.Get File    ${MISS_RD}
35     Post Log Check    ${RPC_URL_PREFIX}:get-key    ${get_key}    404
36
37 Read Key
38     [Documentation]    Read an existing key for an IPv4 EID
39     ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
40     ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-key    ${get_key}
41     ${output}=    Get From Dictionary    ${resp.json()}    output
42     ${password}=    Get From Dictionary    ${output}    authkey
43     Should Be Equal As Strings    ${password}    password
44
45 Update Key
46     [Documentation]    Update an existing key for an IPv4 EID
47     ${update_key}=    OperatingSystem.Get File    ${IPV4_U_KEY}
48     Post Log Check    ${RPC_URL_PREFIX}:update-key    ${update_key}
49
50 Read Updated Key
51     [Documentation]    Read the key updated in the previous test
52     ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
53     ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-key    ${get_key}
54     ${output}=    Get From Dictionary    ${resp.json()}    output
55     ${password}=    Get From Dictionary    ${output}    authkey
56     Should Be Equal As Strings    ${password}    updated-password
57
58 Delete Key
59     [Documentation]    Delete an existing key for an IPv4 EID
60     ${remove_key}=    OperatingSystem.Get File    ${IPV4_RD}
61     Post Log Check    ${RPC_URL_PREFIX}:remove-key    ${remove_key}
62
63 Attempt To Read Deleted Key
64     [Documentation]    Try to read the key deleted in the previous test
65     ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
66     Post Log Check    ${RPC_URL_PREFIX}:get-key    ${get_key}    404
67
68 Attempt To Update Non-Existing Key
69     [Documentation]    Update a non-existing key for an IPv4 EID
70     ${update_key}=    OperatingSystem.Get File    ${IPV4_U_KEY}
71     Post Log Check    ${RPC_URL_PREFIX}:update-key    ${update_key}    404
72
73 Create Mapping
74     [Documentation]    Create a mapping for an IPv4 EID
75     ${add_mapping}=    OperatingSystem.Get File    ${IPV4_C_MAP}
76     Post Log Check    ${RPC_URL_PREFIX}:add-mapping    ${add_mapping}
77
78 Attempt To Read Non-Existing Mapping
79     [Documentation]    Try to read a non-existing mapping for an IPv4 EID
80     ${get_mapping}=    OperatingSystem.Get File    ${MISS_RD}
81     ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-mapping    ${get_mapping}
82     ${output}=    Get From Dictionary    ${resp.json()}    output
83     ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
84     ${eid_record_0}=    Get From List    ${eid_record}    0
85     ${action}=    Get From Dictionary    ${eid_record_0}    action
86     Should Be Equal As Strings    ${action}    NativelyForward
87
88 Read Mapping
89     [Documentation]    Read an existing mapping for an IPv4 EID
90     ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
91     ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-mapping    ${get_mapping}
92     ${output}=    Get From Dictionary    ${resp.json()}    output
93     ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
94     ${eid_record_0}=    Get From List    ${eid_record}    0
95     ${loc_record}=    Get From Dictionary    ${eid_record_0}    LocatorRecord
96     ${loc_record_0}=    Get From List    ${loc_record}    0
97     ${loc}=    Get From Dictionary    ${loc_record_0}    LispAddressContainer
98     ${address}=    Get From Dictionary    ${loc}    Ipv4Address
99     ${ipv4}=    Get From Dictionary    ${address}    Ipv4Address
100     Should Be Equal As Strings    ${ipv4}    10.10.10.10
101
102 Update Mapping
103     [Documentation]    Update an existing mapping for an IPv4 EID
104     ${update_mapping}=    OperatingSystem.Get File    ${IPV4_U_MAP}
105     Post Log Check    ${RPC_URL_PREFIX}:update-mapping    ${update_mapping}
106
107 Read Updated Mapping
108     [Documentation]    Read the mapping updated in the previous test
109     ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
110     ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-mapping    ${get_mapping}
111     ${output}=    Get From Dictionary    ${resp.json()}    output
112     ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
113     ${eid_record_0}=    Get From List    ${eid_record}    0
114     ${loc_record}=    Get From Dictionary    ${eid_record_0}    LocatorRecord
115     ${loc_record_0}=    Get From List    ${loc_record}    0
116     ${loc}=    Get From Dictionary    ${loc_record_0}    LispAddressContainer
117     ${address}=    Get From Dictionary    ${loc}    Ipv4Address
118     ${ipv4}=    Get From Dictionary    ${address}    Ipv4Address
119     Should Be Equal As Strings    ${ipv4}    20.20.20.20
120
121 Delete Mapping
122     [Documentation]    Delete an existing mapping for an IPv4 EID
123     ${remove_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
124     Post Log Check    ${RPC_URL_PREFIX}:remove-mapping    ${remove_mapping}
125
126 Attempt To Read Deleted Mapping
127     [Documentation]    Try to read the mapping deleted in the previous test
128     Sleep    200ms    Avoid race conditions
129     ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
130     ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-mapping    ${get_mapping}
131     ${output}=    Get From Dictionary    ${resp.json()}    output
132     ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
133     ${eid_record_0}=    Get From List    ${eid_record}    0
134     ${action}=    Get From Dictionary    ${eid_record_0}    action
135     Should Be Equal As Strings    ${action}    NativelyForward
136
137 *** Keywords ***
138 Post Log Check
139     [Arguments]    ${uri}    ${body}    ${status_code}=200
140     [Documentation]    Post body to uri, log response content, and check status
141     ${resp}=    RequestsLibrary.Post    session    ${uri}    ${body}
142     Log    ${resp.content}
143     Should Be Equal As Strings    ${resp.status_code}    ${status_code}
144     [Return]    ${resp}