Fix failing LISP tests due to implementation changes
[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 And Set External Variables
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/LISPFlowMapping.robot
11 Resource          ../../../libraries/Utils.robot
12
13 *** Variables ***
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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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    ${LFM_RPC_API}: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     Check Mapping Removal    ${get_mapping}
82
83 Read Mapping
84     [Documentation]    Read an existing mapping for an IPv4 EID
85     ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
86     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${get_mapping}
87     ${output}=    Get From Dictionary    ${resp.json()}    output
88     ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
89     ${eid_record_0}=    Get From List    ${eid_record}    0
90     ${loc_record}=    Get From Dictionary    ${eid_record_0}    LocatorRecord
91     ${loc_record_0}=    Get From List    ${loc_record}    0
92     ${loc}=    Get From Dictionary    ${loc_record_0}    LispAddressContainer
93     ${address}=    Get From Dictionary    ${loc}    Ipv4Address
94     ${ipv4}=    Get From Dictionary    ${address}    Ipv4Address
95     Should Be Equal As Strings    ${ipv4}    10.10.10.10
96
97 Update Mapping
98     [Documentation]    Update an existing mapping for an IPv4 EID
99     ${update_mapping}=    OperatingSystem.Get File    ${IPV4_U_MAP}
100     Post Log Check    ${LFM_RPC_API}:update-mapping    ${update_mapping}
101
102 Read Updated Mapping
103     [Documentation]    Read the mapping updated in the previous test
104     ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
105     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${get_mapping}
106     ${output}=    Get From Dictionary    ${resp.json()}    output
107     ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
108     ${eid_record_0}=    Get From List    ${eid_record}    0
109     ${loc_record}=    Get From Dictionary    ${eid_record_0}    LocatorRecord
110     ${loc_record_0}=    Get From List    ${loc_record}    0
111     ${loc}=    Get From Dictionary    ${loc_record_0}    LispAddressContainer
112     ${address}=    Get From Dictionary    ${loc}    Ipv4Address
113     ${ipv4}=    Get From Dictionary    ${address}    Ipv4Address
114     Should Be Equal As Strings    ${ipv4}    20.20.20.20
115
116 Delete Mapping
117     [Documentation]    Delete an existing mapping for an IPv4 EID
118     ${remove_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
119     Post Log Check    ${LFM_RPC_API}:remove-mapping    ${remove_mapping}
120
121 Attempt To Read Deleted Mapping
122     [Documentation]    Try to read the mapping deleted in the previous test
123     Sleep    200ms    Avoid race conditions
124     ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
125     Check Mapping Removal    ${get_mapping}