Add RPC CRUD test cases for lispflowmapping
authorLorand Jakab <lojakab@cisco.com>
Mon, 8 Jun 2015 09:45:23 +0000 (12:45 +0300)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 9 Jun 2015 03:45:42 +0000 (03:45 +0000)
Change-Id: I2dcc1de462e03db11deb11cdd690e130ecbb9fed
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
(cherry picked from commit ca3ae4dbcda2d6fa9c4b3f7f46a5f377b25981be)

test/csit/suites/lispflowmapping/basic/020_RPC_CRUD.robot [new file with mode: 0644]
test/csit/variables/lispflowmapping/rpc_add-key_ipv4.json [new file with mode: 0644]
test/csit/variables/lispflowmapping/rpc_add-mapping_ipv4_ipv4.json [new file with mode: 0644]
test/csit/variables/lispflowmapping/rpc_get-remove_ipv4.json [new file with mode: 0644]
test/csit/variables/lispflowmapping/rpc_get-remove_missing.json [new file with mode: 0644]
test/csit/variables/lispflowmapping/rpc_update-key_ipv4.json [new file with mode: 0644]
test/csit/variables/lispflowmapping/rpc_update-mapping_ipv4_ipv4.json [new file with mode: 0644]

diff --git a/test/csit/suites/lispflowmapping/basic/020_RPC_CRUD.robot b/test/csit/suites/lispflowmapping/basic/020_RPC_CRUD.robot
new file mode 100644 (file)
index 0000000..b5943a0
--- /dev/null
@@ -0,0 +1,143 @@
+*** Settings ***
+Documentation     Test suite to verify CRUD operations using RPCs
+Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
+Suite Teardown    Delete All Sessions
+Library           Collections
+Library           OperatingSystem
+Library           RequestsLibrary
+Library           ../../../libraries/Common.py
+Variables         ../../../variables/Variables.py
+Resource          ../../../libraries/Utils.txt
+
+*** Variables ***
+${RPC_URL_PREFIX}    /restconf/operations/lfm-mapping-database
+${IPV4_C_KEY}     ../../../variables/lispflowmapping/rpc_add-key_ipv4.json
+${IPV4_RD}        ../../../variables/lispflowmapping/rpc_get-remove_ipv4.json
+${MISS_RD}        ../../../variables/lispflowmapping/rpc_get-remove_missing.json
+${IPV4_U_KEY}     ../../../variables/lispflowmapping/rpc_update-key_ipv4.json
+${IPV4_C_MAP}     ../../../variables/lispflowmapping/rpc_add-mapping_ipv4_ipv4.json
+${IPV4_U_MAP}     ../../../variables/lispflowmapping/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}
+    Post Log Check    ${RPC_URL_PREFIX}:add-key    ${add_key}
+
+Attempt To Create Key Again
+    [Documentation]    Try to overwrite existing IPv4 EID key
+    ${add_key}=    OperatingSystem.Get File    ${IPV4_C_KEY}
+    Post Log Check    ${RPC_URL_PREFIX}:add-key    ${add_key}    409
+
+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}
+    Post Log Check    ${RPC_URL_PREFIX}:get-key    ${get_key}    404
+
+Read Key
+    [Documentation]    Read an existing key for an IPv4 EID
+    ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-key    ${get_key}
+    ${output}=    Get From Dictionary    ${resp.json()}    output
+    ${password}=    Get From Dictionary    ${output}    authkey
+    Should Be Equal As Strings    ${password}    password
+
+Update Key
+    [Documentation]    Update an existing key for an IPv4 EID
+    ${update_key}=    OperatingSystem.Get File    ${IPV4_U_KEY}
+    Post Log Check    ${RPC_URL_PREFIX}:update-key    ${update_key}
+
+Read Updated Key
+    [Documentation]    Read the key updated in the previous test
+    ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-key    ${get_key}
+    ${output}=    Get From Dictionary    ${resp.json()}    output
+    ${password}=    Get From Dictionary    ${output}    authkey
+    Should Be Equal As Strings    ${password}    updated-password
+
+Delete Key
+    [Documentation]    Delete an existing key for an IPv4 EID
+    ${remove_key}=    OperatingSystem.Get File    ${IPV4_RD}
+    Post Log Check    ${RPC_URL_PREFIX}: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}
+    Post Log Check    ${RPC_URL_PREFIX}: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}
+    Post Log Check    ${RPC_URL_PREFIX}:update-key    ${update_key}    404
+
+Create Mapping
+    [Documentation]    Create a mapping for an IPv4 EID
+    ${add_mapping}=    OperatingSystem.Get File    ${IPV4_C_MAP}
+    Post Log Check    ${RPC_URL_PREFIX}: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}
+    ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-mapping    ${get_mapping}
+    ${output}=    Get From Dictionary    ${resp.json()}    output
+    ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
+    ${eid_record_0}=    Get From List    ${eid_record}    0
+    ${action}=    Get From Dictionary    ${eid_record_0}    action
+    Should Be Equal As Strings    ${action}    NativelyForward
+
+Read Mapping
+    [Documentation]    Read an existing mapping for an IPv4 EID
+    ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-mapping    ${get_mapping}
+    ${output}=    Get From Dictionary    ${resp.json()}    output
+    ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
+    ${eid_record_0}=    Get From List    ${eid_record}    0
+    ${loc_record}=    Get From Dictionary    ${eid_record_0}    LocatorRecord
+    ${loc_record_0}=    Get From List    ${loc_record}    0
+    ${loc}=    Get From Dictionary    ${loc_record_0}    LispAddressContainer
+    ${address}=    Get From Dictionary    ${loc}    Ipv4Address
+    ${ipv4}=    Get From Dictionary    ${address}    Ipv4Address
+    Should Be Equal As Strings    ${ipv4}    10.10.10.10
+
+Update Mapping
+    [Documentation]    Update an existing mapping for an IPv4 EID
+    ${update_mapping}=    OperatingSystem.Get File    ${IPV4_U_MAP}
+    Post Log Check    ${RPC_URL_PREFIX}:update-mapping    ${update_mapping}
+
+Read Updated Mapping
+    [Documentation]    Read the mapping updated in the previous test
+    ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-mapping    ${get_mapping}
+    ${output}=    Get From Dictionary    ${resp.json()}    output
+    ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
+    ${eid_record_0}=    Get From List    ${eid_record}    0
+    ${loc_record}=    Get From Dictionary    ${eid_record_0}    LocatorRecord
+    ${loc_record_0}=    Get From List    ${loc_record}    0
+    ${loc}=    Get From Dictionary    ${loc_record_0}    LispAddressContainer
+    ${address}=    Get From Dictionary    ${loc}    Ipv4Address
+    ${ipv4}=    Get From Dictionary    ${address}    Ipv4Address
+    Should Be Equal As Strings    ${ipv4}    20.20.20.20
+
+Delete Mapping
+    [Documentation]    Delete an existing mapping for an IPv4 EID
+    ${remove_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
+    Post Log Check    ${RPC_URL_PREFIX}:remove-mapping    ${remove_mapping}
+
+Attempt To Read Deleted Mapping
+    [Documentation]    Try to read the mapping deleted in the previous test
+    ${get_mapping}=    OperatingSystem.Get File    ${IPV4_RD}
+    ${resp}=    Post Log Check    ${RPC_URL_PREFIX}:get-mapping    ${get_mapping}
+    ${output}=    Get From Dictionary    ${resp.json()}    output
+    ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
+    ${eid_record_0}=    Get From List    ${eid_record}    0
+    ${action}=    Get From Dictionary    ${eid_record_0}    action
+    Should Be Equal As Strings    ${action}    NativelyForward
+
+*** Keywords ***
+Post Log Check
+    [Arguments]    ${uri}    ${body}    ${status_code}=200
+    [Documentation]    Post body to uri, log response content, and check status
+    ${resp}=    RequestsLibrary.Post    session    ${uri}    ${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    ${status_code}
+    [Return]    ${resp}
diff --git a/test/csit/variables/lispflowmapping/rpc_add-key_ipv4.json b/test/csit/variables/lispflowmapping/rpc_add-key_ipv4.json
new file mode 100644 (file)
index 0000000..3adef1f
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "input": {
+        "LispAddressContainer": {
+            "Ipv4Address": {
+                "afi": 1,
+                "Ipv4Address": "192.0.2.1"
+            }
+        },
+        "mask-length": 32,
+        "key-type": 1,
+        "authkey": "password"
+    }
+}
diff --git a/test/csit/variables/lispflowmapping/rpc_add-mapping_ipv4_ipv4.json b/test/csit/variables/lispflowmapping/rpc_add-mapping_ipv4_ipv4.json
new file mode 100644 (file)
index 0000000..c883525
--- /dev/null
@@ -0,0 +1,31 @@
+{
+    "input": {
+        "recordTtl": 1440,
+        "maskLength": 32,
+        "authoritative": true,
+        "LispAddressContainer": {
+            "Ipv4Address": {
+                "afi": 1,
+                "Ipv4Address": "192.0.2.1"
+            }
+        },
+        "LocatorRecord": [
+            {
+                "name": "ISP1",
+                "priority": 1,
+                "weight": 1,
+                "multicastPriority": 255,
+                "multicastWeight": 0,
+                "localLocator": true,
+                "rlocProbed": false,
+                "routed": false,
+                "LispAddressContainer": {
+                    "Ipv4Address": {
+                        "afi": 1,
+                        "Ipv4Address": "10.10.10.10"
+                    }
+                }
+            }
+        ]
+    }
+}
diff --git a/test/csit/variables/lispflowmapping/rpc_get-remove_ipv4.json b/test/csit/variables/lispflowmapping/rpc_get-remove_ipv4.json
new file mode 100644 (file)
index 0000000..f3d374e
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "input": {
+        "LispAddressContainer": {
+            "Ipv4Address": {
+                "afi": 1,
+                "Ipv4Address": "192.0.2.1"
+            }
+        },
+        "mask-length": 32
+    }
+}
diff --git a/test/csit/variables/lispflowmapping/rpc_get-remove_missing.json b/test/csit/variables/lispflowmapping/rpc_get-remove_missing.json
new file mode 100644 (file)
index 0000000..d4752dc
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "input": {
+        "LispAddressContainer": {
+            "Ipv4Address": {
+                "afi": 1,
+                "Ipv4Address": "192.0.2.255"
+            }
+        },
+        "mask-length": 32
+    }
+}
diff --git a/test/csit/variables/lispflowmapping/rpc_update-key_ipv4.json b/test/csit/variables/lispflowmapping/rpc_update-key_ipv4.json
new file mode 100644 (file)
index 0000000..3237856
--- /dev/null
@@ -0,0 +1,17 @@
+{
+    "input": {
+        "eid": {
+            "LispAddressContainer": {
+                "Ipv4Address": {
+                    "afi": 1,
+                    "Ipv4Address": "192.0.2.1"
+                }
+            },
+            "mask-length": 32
+        },
+        "key": {
+            "key-type": 1,
+            "authkey": "updated-password"
+        }
+    }
+}
diff --git a/test/csit/variables/lispflowmapping/rpc_update-mapping_ipv4_ipv4.json b/test/csit/variables/lispflowmapping/rpc_update-mapping_ipv4_ipv4.json
new file mode 100644 (file)
index 0000000..2f9a068
--- /dev/null
@@ -0,0 +1,31 @@
+{
+    "input": {
+        "recordTtl": 1440,
+        "maskLength": 32,
+        "authoritative": true,
+        "LispAddressContainer": {
+            "Ipv4Address": {
+                "afi": 1,
+                "Ipv4Address": "192.0.2.1"
+            }
+        },
+        "LocatorRecord": [
+            {
+                "name": "ISP1",
+                "priority": 1,
+                "weight": 1,
+                "multicastPriority": 255,
+                "multicastWeight": 0,
+                "localLocator": true,
+                "rlocProbed": false,
+                "routed": false,
+                "LispAddressContainer": {
+                    "Ipv4Address": {
+                        "afi": 1,
+                        "Ipv4Address": "20.20.20.20"
+                    }
+                }
+            }
+        ]
+    }
+}