Less sensitive "empty config test"
[integration/test.git] / csit / suites / netconf / MDSAL / northbound.robot
index 23b83675f19f2088ea3c70fa38b42f2b6905e86d..df92fb9d33d2cc8ea39c8f67d7ef7b75e0594362 100644 (file)
@@ -6,6 +6,21 @@ Documentation     Metconf MDSAL Northbound test suite.
 ...               This program and the accompanying materials are made available under the
 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
+...
+...
+...               The request produced by test cases "Get Config Running", "Get Config Running
+...               To Confirm No_Edit Before Commit", "Get Config Running To Confirm Delete
+...               After Commit" and "Get Config Candidate To Confirm Discard" all use the same
+...               message id ("empty") for their requests. This is possible because the
+...               requests produced by this suite are strictly serialized. The RFC 6241 does
+...               not state that these IDs are unique, it only requires that each ID used is
+...               "XML attribute normalized" if the client wants it to be returned unmodified.
+...               The RFC specifically says that "the content of this attribute is not
+...               interpreted in any way, it only is stored to be returned with the reply to
+...               the request. The reuse of the "empty" string for the 4 test cases was chosen
+...               for simplicity.
+...
+...               TODO: Change the 4 testcases to use unique message IDs.
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
@@ -14,12 +29,14 @@ Library           RequestsLibrary
 Library           SSHLibrary
 Resource          ${CURDIR}/../../../libraries/FailFast.robot
 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
+Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
 Resource          ${CURDIR}/../../../libraries/Utils.robot
 Variables         ${CURDIR}/../../../variables/Variables.py
 
 *** Variables ***
 ${datadir}        ${CURDIR}/../../../variables/netconf/MDSAL
 ${dataext}        msg
+${ssh_netconf_pid}    -1
 
 *** Test Cases ***
 Connect_To_ODL_Netconf
@@ -30,7 +47,7 @@ Connect_To_ODL_Netconf
 
 Get_Config_Running
     [Documentation]    Make sure the configuration has only the default elements in it.
-    Perform_Test    get-config
+    Check_Test_Objects_Not_Present_In_Config    get-config
 
 Missing_Message_ID_Attribute
     [Documentation]    Check that messages with missing "message-ID" attribute are rejected with the correct error (RFC 6241, section 4.1).
@@ -51,7 +68,7 @@ Edit_Config_Modules_Merge
 
 Get_Config_Running_To_Confirm_No_Edit_Before_Commit
     [Documentation]    Make sure the running configuration is still unchanged as the change was not commited yet.
-    Perform_Test    get-config-no-edit-before-commit
+    Check_Test_Objects_Not_Present_In_Config    get-config-no-edit-before-commit
 
 Commit_Edit
     [Documentation]    Commit the change and check the reply.
@@ -86,7 +103,7 @@ Commit_Delete
 
 Get_Config_Running_To_Confirm_Delete_After_Commit
     [Documentation]    Check that the element is gone.
-    Perform_Test    get-config-delete-after-commit
+    Check_Test_Objects_Not_Present_In_Config    get-config-delete-after-commit
 
 Restconf_Get_Modules_Shall_Return_404
     [Documentation]    Check that "Not Found" is returned when Restconf is asked for the deleted element.
@@ -113,7 +130,7 @@ Discard_Changes
 
 Get_Config_Candidate_To_Confirm_Discard
     [Documentation]    Check that the element was really discarded.
-    Perform_Test    get-config-candidate-discard
+    Check_Test_Objects_Not_Present_In_Config    get-config-candidate-discard
 
 Edit_Config_Modules_Multiple_Modules_Merge_1
     [Documentation]    Create the element with "name2" subelement again and check the reply.
@@ -240,10 +257,18 @@ Open_ODL_Netconf_Connection
     #    going to need to use this operation (Netconf Performance and Scaling
     #    comes to my mind now as one of the things tested is the performance
     #    of the direct netconf connection.
-    SSHLibrary.Open_Connection    ${host}    prompt=${ODL_SYSTEM_PROMPT}    timeout=10s
+    ${control}=    SSHLibrary.Open_Connection    ${host}    prompt=${ODL_SYSTEM_PROMPT}    timeout=10s
     Utils.Flexible_Controller_Login
+    BuiltIn.Set_Suite_Variable    ${ssh_control}    ${control}
+    ${netconf}=    SSHLibrary.Open_Connection    ${host}    prompt=${ODL_SYSTEM_PROMPT}    timeout=10s
+    Utils.Flexible_Controller_Login
+    BuiltIn.Set_Suite_Variable    ${ssh_netconf}    ${netconf}
     SSHLibrary.Write    sshpass -p ${password} ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${user}\@127.0.0.1 -p ${port} -s netconf
     ${hello}=    SSHLibrary.Read_Until    ${ODL_NETCONF_PROMPT}
+    SSHLibrary.Switch_Connection    ${ssh_control}
+    ${pid}=    SSHLibrary.Execute_Command    ps -A | grep sshpass | cut -b 1-6
+    BuiltIn.Set_Suite_Variable    ${ssh_netconf_pid}    ${pid}
+    SSHLibrary.Switch_Connection    ${ssh_netconf}
     [Return]    ${hello}
 
 Transmit_Message
@@ -286,7 +311,13 @@ Load_Expected_Reply
 
 Close_ODL_Netconf_Connection
     [Documentation]    Correctly close the Netconf connection and make sure it is really dead.
-    Utils.Write_Bare_Ctrl_D
+    BuiltIn.Return_From_Keyword_If    ${ssh_netconf_pid} == -1
+    ${kill_command}=    BuiltIn.Set_Variable    kill ${ssh_netconf_pid}
+    BuiltIn.Set_Suite_Variable    ${ssh_netconf_pid}    -1
+    SSHLibrary.Switch_Connection    ${ssh_control}
+    SSHLibrary.Write    ${kill_command}
+    SSHLibrary.Read_Until_Prompt
+    SSHLibrary.Switch_Connection    ${ssh_netconf}
     SSHLibrary.Read_Until_Prompt
 
 Setup_Everything
@@ -299,6 +330,16 @@ Teardown_Everything
     Close_ODL_Netconf_Connection
     RequestsLibrary.Delete_All_Sessions
 
+Check_Test_Objects_Not_Present_In_Config
+    [Arguments]    ${name}
+    [Documentation]    Use dataset with the specified name to get the configuration and check that none of our test objects are there.
+    ${reply}=    Load_And_Send_Message    ${name}
+    BuiltIn.Should_Not_Contain    ${reply}    <name>name0</name>
+    BuiltIn.Should_Not_Contain    ${reply}    <name>name1</name>
+    BuiltIn.Should_Not_Contain    ${reply}    <name>name2</name>
+    BuiltIn.Should_Not_Contain    ${reply}    <name>name3</name>
+    BuiltIn.Should_Not_Contain    ${reply}    <name>name4</name>
+
 Perform_Test
     [Arguments]    ${name}
     [Documentation]    Load and send the request from the dataset and compare the returned reply to the one stored in the dataset.
@@ -308,6 +349,11 @@ Perform_Test
     BuiltIn.Should_Be_Equal    ${actual}    ${newline}${expected}${ODL_NETCONF_PROMPT}
     [Return]    ${actual}
 
+Send_And_Check
+    [Arguments]    ${name}    ${expected}
+    ${actual}=    Load_And_Send_Message    ${name}
+    BuiltIn.Should_Be_Equal    ${actual}    ${expected}
+
 Test_Commit_With_No_Transactions
     [Documentation]    Issue a "commit" RPC request and check that it fails with "No current transactions" error.
     ${reply}=    Load_And_Send_Message    commit-no-transaction