Changed test csit/suites/lispflowmapping/msmr/020_RPC_CRUD.robot 67/41467/13
authorAshish <ashishk.iiit@gmail.com>
Thu, 7 Jul 2016 10:21:38 +0000 (15:51 +0530)
committerVratko Polák <vrpolak@cisco.com>
Tue, 6 Sep 2016 15:02:42 +0000 (15:02 +0000)
Removed the static Json file variables and changed tests
which uses the pyangbind generated binding file.

Change-Id: I790e59bd84b4774352059da545dd4d2e8fe3104e
Signed-off-by: Ashish <ashishk.iiit@gmail.com>
csit/libraries/LISPFlowMapping.robot
csit/suites/lispflowmapping/msmr/020_RPC_CRUD.robot

index 568527508a3e909f0c57c4cca169a1509d69bdbe..570341a081f085941f66f6cf6a8e5450fc8cfaf1 100644 (file)
@@ -3,6 +3,7 @@ Documentation     This resource file defines keywords that are used in more
 ...               than one lispflowmapping test suite. Those suites include
 ...               ../variables/Variables.py, which is where some of the
 ...               variables are coming from.
+Library           JsonGenerator.py
 
 *** Variables ***
 ${JSON_DIR}       ${CURDIR}/../variables/lispflowmapping/Be
@@ -54,3 +55,13 @@ Get Elp Hop
 Check Mapping Removal
     [Arguments]    ${json}
     Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}    404
+
+Get Mapping JSON
+    [Documentation]    Returns mapping record JSON dict
+    [Arguments]    ${eid}    ${rloc}
+    ${loc_record}=    Get LocatorRecord Object    ${rloc}
+    ${lisp_address}=    Get LispAddress Object    ${eid}
+    ${loc_record_list}=    Create List    ${loc_record}
+    ${mapping_record_json}=    Get MappingRecord JSON    ${lisp_address}    ${loc_record_list}
+    ${mapping}=    Wrap input    ${mapping_record_json}
+    [return]    ${mapping}
index 35f0fe0a058851013c8500c81c274aeaef5f3d63..e35df1632f32f1ab8162bcba1621c9fd83b204ba 100644 (file)
@@ -6,95 +6,94 @@ Library           Collections
 Library           OperatingSystem
 Library           RequestsLibrary
 Library           ../../../libraries/Common.py
+Library           ../../../libraries/JsonGenerator.py
 Variables         ../../../variables/Variables.py
 Resource          ../../../libraries/LISPFlowMapping.robot
 Resource          ../../../libraries/Utils.robot
 
-*** Variables ***
-${IPV4_C_KEY}     ${JSON_DIR}/rpc_add-key_ipv4.json
-${IPV4_RD}        ${JSON_DIR}/rpc_get-remove_ipv4.json
-${MISS_RD}        ${JSON_DIR}/rpc_get-remove_missing.json
-${IPV4_U_KEY}     ${JSON_DIR}/rpc_update-key_ipv4.json
-${IPV4_C_MAP}     ${JSON_DIR}/rpc_add-mapping_ipv4_ipv4.json
-${IPV4_U_MAP}     ${JSON_DIR}/rpc_update-mapping_ipv4_ipv4.json
-
 *** Test Cases ***
 Create Key
     [Documentation]    Create a key for an IPv4 EID
-    ${add_key}=    OperatingSystem.Get File    ${IPV4_C_KEY}
+    ${eid_json}=    Get LispAddress JSON    ipv4:192.0.2.1/32
+    ${authkey_json}=    Get MappingAuthkey JSON
+    ${add_key}=    Merge And Wrap input    ${eid_json}    ${authkey_json}
     Post Log Check    ${LFM_RPC_API}:add-key    ${add_key}
 
 Attempt To Read Non-Existing Key
     [Documentation]    Try to read a non-existing key for an IPv4 EID
-    ${get_key}=    OperatingSystem.Get File    ${MISS_RD}
+    ${get_key}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.255/32
     Post Log Check    ${LFM_RPC_API}:get-key    ${get_key}    404
 
 Read Key
     [Documentation]    Read an existing key for an IPv4 EID
-    ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${get_key}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-key    ${get_key}
     Authentication Key Should Be    ${resp}    password
 
 Update Key
     [Documentation]    Update an existing key for an IPv4 EID
-    ${update_key}=    OperatingSystem.Get File    ${IPV4_U_KEY}
+    ${eid_json}=    Get LispAddress JSON    ipv4:192.0.2.1/32
+    ${authkey_json}=    Get MappingAuthkey JSON    key_string=updated-password
+    ${update_key}=    Merge And Wrap input    ${eid_json}    ${authkey_json}
     Post Log Check    ${LFM_RPC_API}:update-key    ${update_key}
 
 Read Updated Key
     [Documentation]    Read the key updated in the previous test
-    ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${get_key}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-key    ${get_key}
     Authentication Key Should Be    ${resp}    updated-password
 
 Delete Key
     [Documentation]    Delete an existing key for an IPv4 EID
-    ${remove_key}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${remove_key}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
     Post Log Check    ${LFM_RPC_API}:remove-key    ${remove_key}
 
 Attempt To Read Deleted Key
     [Documentation]    Try to read the key deleted in the previous test
-    ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${get_key}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
     Post Log Check    ${LFM_RPC_API}:get-key    ${get_key}    404
 
 Attempt To Update Non-Existing Key
     [Documentation]    Update a non-existing key for an IPv4 EID
-    ${update_key}=    OperatingSystem.Get File    ${IPV4_U_KEY}
+    ${eid_json}=    Get LispAddress JSON    ipv4:192.0.2.1/32
+    ${authkey_json}=    Get MappingAuthkey JSON    key_string=updated-password
+    ${update_key}=    Merge And Wrap input    ${eid_json}    ${authkey_json}
     Post Log Check    ${LFM_RPC_API}:update-key    ${update_key}    404
 
 Create Mapping
     [Documentation]    Create a mapping for an IPv4 EID
-    ${add_mapping}=    OperatingSystem.Get File    ${IPV4_C_MAP}
+    ${add_mapping}=    Get Mapping JSON    ipv4:192.0.2.1/32    ipv4:10.10.10.10
     Post Log Check    ${LFM_RPC_API}:add-mapping    ${add_mapping}
 
 Attempt To Read Non-Existing Mapping
     [Documentation]    Try to read a non-existing mapping for an IPv4 EID
-    ${get_mapping}=    OperatingSystem.Get File    ${MISS_RD}
+    ${get_mapping}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.255/32
     Check Mapping Removal    ${get_mapping}
 
 Read Mapping
     [Documentation]    Read an existing mapping for an IPv4 EID
-    ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${get_mapping}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${get_mapping}
     Ipv4 Rloc Should Be    ${resp}    10.10.10.10
 
 Update Mapping
     [Documentation]    Update an existing mapping for an IPv4 EID
-    ${update_mapping}=    OperatingSystem.Get File    ${IPV4_U_MAP}
+    ${update_mapping}=    Get Mapping JSON    ipv4:192.0.2.1/32    ipv4:20.20.20.20
     Post Log Check    ${LFM_RPC_API}:update-mapping    ${update_mapping}
 
 Read Updated Mapping
     [Documentation]    Read the mapping updated in the previous test
-    ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${get_mapping}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${get_mapping}
     Ipv4 Rloc Should Be    ${resp}    20.20.20.20
 
 Delete Mapping
     [Documentation]    Delete an existing mapping for an IPv4 EID
-    ${remove_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${remove_mapping}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
     Post Log Check    ${LFM_RPC_API}:remove-mapping    ${remove_mapping}
 
 Attempt To Read Deleted Mapping
     [Documentation]    Try to read the mapping deleted in the previous test
     Sleep    200ms    Avoid race conditions
-    ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${get_mapping}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
     Check Mapping Removal    ${get_mapping}