Added JSON modification request to CRUD suite 56/33756/5
authorJozef Behran <jbehran@cisco.com>
Fri, 29 Jan 2016 09:52:06 +0000 (10:52 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 29 Jan 2016 14:25:11 +0000 (14:25 +0000)
This was created as a result of investigation of failure
of restperfclient to send valid requests.

Change-Id: Ia1c2006a6abd37bd2f92ee5d5159033538153523
Signed-off-by: Jozef Behran <jbehran@cisco.com>
csit/libraries/NetconfViaRestconf.robot
csit/suites/netconf/CRUD/CRUD.robot
csit/variables/netconf/CRUD/datamodjson/config.uri [new file with mode: 0644]
csit/variables/netconf/CRUD/datamodjson/data.json [new file with mode: 0644]

index be5c48ea4c51823b6b89221a1cd908120dee0022..fe794b910440927250c292149a7d9fc0e4f69ceb 100644 (file)
@@ -76,6 +76,14 @@ Resolve_Xml_Data_From_Template_Folder
     ${xml_data}=    Strip_Endline_And_Apply_Substitutions_From_Mapping    ${data_template}    ${mapping_as_string}
     [Return]    ${xml_data}
 
+Resolve_Json_Data_From_Template_Folder
+    [Arguments]    ${folder}    ${mapping_as_string}
+    [Documentation]    Read data template from folder, strip endline, make changes according to mapping, return the result.
+    ${data_template}=    OperatingSystem.Get_File    ${folder}${/}data.json
+    BuiltIn.Log    ${data_template}
+    ${json_data}=    Strip_Endline_And_Apply_Substitutions_From_Mapping    ${data_template}    ${mapping_as_string}
+    [Return]    ${json_data}
+
 Strip_Endline_And_Apply_Substitutions_From_Mapping
     [Arguments]    ${template_as_string}    ${mapping_as_string}
     [Documentation]    Strip endline, apply substitutions, Log and return the result.
@@ -124,6 +132,24 @@ Put_Xml_Template_Folder_Via_Restconf
     ${xml_data}=    Resolve_Xml_Data_From_Template_Folder    ${folder}    ${mapping_as_string}
     Put_Xml_Via_Restconf    ${uri_part}    ${xml_data}
 
+Put_Json_Via_Restconf
+    [Arguments]    ${uri_part}    ${json_data}
+    [Documentation]    Put JSON data to given controller-config URI, check reponse text is empty and status_code is one of allowed ones.
+    BuiltIn.Log    ${uri_part}
+    BuiltIn.Log    ${json_data}
+    ${response}=    RequestsLibrary.Put    ${NetconfViaRestconf__active_config_session}    ${uri_part}    data=${json_data}    headers=${HEADERS_YANG_JSON}
+    BuiltIn.Log    ${response.text}
+    BuiltIn.Log    ${response.status_code}
+    BuiltIn.Should_Be_Empty    ${response.text}
+    BuiltIn.Should_Contain    ${allowed_status_codes}    ${response.status_code}
+
+Put_Json_Template_Folder_Via_Restconf
+    [Arguments]    ${folder}    ${mapping_as_string}={}
+    [Documentation]    Resolve URI and data from folder, PUT to controller config.
+    ${uri_part}=    Resolve_URI_From_Template_Folder    ${folder}    ${mapping_as_string}
+    ${json_data}=    Resolve_Json_Data_From_Template_Folder    ${folder}    ${mapping_as_string}
+    Put_Json_Via_Restconf    ${uri_part}    ${json_data}
+
 Delete_Via_Restconf
     [Arguments]    ${uri_part}
     [Documentation]    Delete resource at controller-config URI, check reponse text is empty and status_code is 204.
index 8d4dcbad19d95bb8a766ac6f6c049490a352dc46..1579bc62a2101fc4f4918d1768075c105069a68f 100644 (file)
@@ -78,6 +78,15 @@ Check_Device_Data_Is_Modified
     [Documentation]    Get the device data and make sure it contains the created content.
     Check_Config_Data    <data xmlns="${ODL_NETCONF_NAMESPACE}"><cont xmlns="urn:opendaylight:test:netconf:crud"><l>Modified Content</l></cont></data>
 
+Modify_Device_Data_Via_JSON
+    [Documentation]    Send a JSON request to change the sample test data and check that the request went OK.
+    ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${device_name}'}
+    NetconfViaRestconf.Put_Json_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}datamodjson    ${template_as_string}
+
+Check_Device_Data_Is_Modified_Via_JSON
+    [Documentation]    Get the device data as XML and make sure it matches the content posted as JSON in the previous case.
+    Check_Config_Data    <data xmlns="${ODL_NETCONF_NAMESPACE}"><cont xmlns="urn:opendaylight:test:netconf:crud"><l>Content Modified via JSON</l></cont></data>
+
 Delete_Device_Data
     [Documentation]    Send a request to delete the sample test data on the device and check that the request went OK.
     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${device_name}'}
diff --git a/csit/variables/netconf/CRUD/datamodjson/config.uri b/csit/variables/netconf/CRUD/datamodjson/config.uri
new file mode 100644 (file)
index 0000000..41fb71a
--- /dev/null
@@ -0,0 +1 @@
+network-topology:network-topology/topology/topology-netconf/node/$DEVICE_NAME/yang-ext:mount/test:cont
diff --git a/csit/variables/netconf/CRUD/datamodjson/data.json b/csit/variables/netconf/CRUD/datamodjson/data.json
new file mode 100644 (file)
index 0000000..3f7b76c
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "test:cont": {
+    "l":"Content Modified via JSON"
+  }
+}