Fix variable naming for some immutable variables
[integration/test.git] / csit / suites / netconf / clustering / CRUD.robot
1 *** Settings ***
2 Documentation     netconf clustered CRUD test suite.
3 ...
4 ...               Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
5 ...
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...
11 ...               Perform basic operations (Create, Read, Update and Delete or CRUD) on device
12 ...               data mounted onto a netconf connector and see if they work.
13 ...
14 ...               The suite recognizes 3 nodes, "CONFIGURER" (the node that configures the
15 ...               device at the beginning and then deconfigures it at the end), "SETTER" (the
16 ...               node that manipulates the data on the device) and "CHECKER" (the node that
17 ...               checks the data on the device). The configured device and the results of each
18 ...               data operation on it is expected to be visible on all nodes so after each
19 ...               operation three test cases make sure they can see the result on their
20 ...               respective nodes.
21 ...
22 ...               The 3 nodes are configured by placing "node1", "node2" or "node3" into the
23 ...               ${NODE_CONFIGURER}, ${NODE_SETTER} and ${NODE_CHECKER} to make the node
24 ...               a "CONFIGURER", "SETTER" and "CHECKER" respectively. The "nodeX" name refers
25 ...               to the node with its IP address configured with the ${ODL_SYSTEM_X_IP}
26 ...               variable where the "X" is 1, 2 or 3.
27 ...
28 ...               The suite checks the integrity of the presence of the device and the data
29 ...               seen on the device only for nodes that have at least one of the roles
30 ...               ("CONFIGURER", "SETTER" and "CHECKER") assigned. A better design would have
31 ...               a "checker list" of sorts and have only one checking test case that runs
32 ...               through the check list and performs the test on each node listed. However
33 ...               this currently has fairly low priority due to Beryllium delivery date so
34 ...               it was left out.
35 Suite Setup       Setup_Everything
36 Suite Teardown    Teardown_Everything
37 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
38 Library           Collections
39 Library           RequestsLibrary
40 Library           OperatingSystem
41 Library           String
42 Library           SSHLibrary    timeout=10s
43 Resource          ${CURDIR}/../../../libraries/FailFast.robot
44 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
45 Resource          ${CURDIR}/../../../libraries/NetconfKeywords.robot
46 Resource          ${CURDIR}/../../../libraries/NetconfViaRestconf.robot
47 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
48 Resource          ${CURDIR}/../../../libraries/Utils.robot
49 Variables         ${CURDIR}/../../../variables/Variables.py
50
51 *** Variables ***
52 ${NODE_CONFIGURER}    node1
53 ${NODE_SETTER}    node2
54 ${NODE_CHECKER}    node3
55 ${DEVICE_CHECK_TIMEOUT}    60s
56 ${DEVICE_NAME}    netconf-test-device
57 ${directory_with_template_folders}    ${CURDIR}/../../../variables/netconf/CRUD
58 ${empty_data}     <data xmlns="${ODL_NETCONF_NAMESPACE}"></data>
59 ${original_data}    <data xmlns="${ODL_NETCONF_NAMESPACE}"><cont xmlns="urn:opendaylight:test:netconf:crud"><l>Content</l></cont></data>
60 ${modified_data}    <data xmlns="${ODL_NETCONF_NAMESPACE}"><cont xmlns="urn:opendaylight:test:netconf:crud"><l>Modified Content</l></cont></data>
61
62 *** Test Cases ***
63 Start_Testtool
64     [Documentation]    Deploy and start test tool, then wait for all its devices to become online.
65     NetconfKeywords.Install_And_Start_Testtool    device-count=1    schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas
66
67 Check_Device_Is_Not_Mounted_At_Beginning
68     [Documentation]    Sanity check making sure our device is not there. Fail if found.
69     [Tags]    critical
70     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
71     NetconfKeywords.Check_Device_Has_No_Netconf_Connector    ${DEVICE_NAME}
72
73 Configure_Device_On_Netconf
74     [Documentation]    Make request to configure a testtool device on Netconf connector
75     [Tags]    critical
76     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
77     NetconfKeywords.Configure_Device_In_Netconf    ${DEVICE_NAME}    device_type=configure-via-topology
78     [Teardown]    Utils.Report_Failure_Due_To_Bug    5089
79
80 Check_Configurer_Has_Netconf_Connector_For_Device
81     [Documentation]    Get the list of mounts and search for our device there. Fail if not found.
82     [Tags]    critical
83     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
84     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Device_Instance_Count    1
85
86 Wait_For_Device_To_Become_Visible_For_Configurer
87     [Documentation]    Wait until the device becomes visible on configurer node.
88     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
89     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
90
91 Wait_For_Device_To_Become_Visible_For_Checker
92     [Documentation]    Wait until the device becomes visible on checker node.
93     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CHECKER}
94     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
95
96 Wait_For_Device_To_Become_Visible_For_Setter
97     [Documentation]    Wait until the device becomes visible on setter node.
98     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
99     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
100
101 Check_Device_Data_Is_Seen_As_Empty_On_Configurer
102     [Documentation]    Get the device data as seen by configurer and make sure it is empty.
103     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${empty_data}
104
105 Check_Device_Data_Is_Seen_As_Empty_On_Checker
106     [Documentation]    Get the device data as seen by checker and make sure it is empty.
107     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CHECKER}    ${empty_data}
108
109 Check_Device_Data_Is_Seen_As_Empty_On_Setter
110     [Documentation]    Get the device data as seen by setter and make sure it is empty.
111     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_SETTER}    ${empty_data}
112
113 Create_Device_Data
114     [Documentation]    Send some sample test data into the device and check that the request went OK.
115     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
116     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${DEVICE_NAME}'}
117     NetconfViaRestconf.Post_Xml_Template_Folder_Via_Restconf    ${directory_with_template_folders}${/}dataorig    ${template_as_string}
118
119 Check_New_Device_Data_Is_Visible_On_Setter
120     [Documentation]    Get the device data and make sure it contains the created content.
121     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_SETTER}    ${original_data}
122
123 Check_New_Device_Data_Is_Visible_On_Checker
124     [Documentation]    Check that the created device data make their way into the checker node.
125     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CHECKER}    ${original_data}
126
127 Check_New_Device_Data_Is_Visible_On_Configurer
128     [Documentation]    Check that the created device data make their way into the configurer node.
129     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${original_data}
130
131 Modify_Device_Data
132     [Documentation]    Send a request to change the sample test data and check that the request went OK.
133     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
134     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${DEVICE_NAME}'}
135     NetconfViaRestconf.Put_Xml_Template_Folder_Via_Restconf    ${directory_with_template_folders}${/}datamod1    ${template_as_string}
136     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
137
138 Check_Device_Data_Is_Modified
139     [Documentation]    Get the device data and make sure it contains the modified content.
140     Check_Config_Data    ${NODE_SETTER}    ${modified_data}
141     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
142
143 Check_Modified_Device_Data_Is_Visible_On_Checker
144     [Documentation]    Check that the modified device data make their way into the checker node.
145     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CHECKER}    ${modified_data}
146     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
147
148 Check_Modified_Device_Data_Is_Visible_On_Configurer
149     [Documentation]    Check that the modified device data make their way into the configurer node.
150     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${modified_data}
151     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
152
153 Delete_Device_Data
154     [Documentation]    Send a request to delete the sample test data on the device and check that the request went OK.
155     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
156     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${DEVICE_NAME}'}
157     NetconfViaRestconf.Delete_Xml_Template_Folder_Via_Restconf    ${directory_with_template_folders}${/}datamod1    ${template_as_string}
158     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
159
160 Check_Device_Data_Is_Deleted
161     [Documentation]    Get the device data and make sure it is empty again.
162     Check_Config_Data    ${NODE_SETTER}    ${empty_data}
163     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
164
165 Check_Device_Data_Deletion_Is_Visible_On_Checker
166     [Documentation]    Check that the device data deletion makes its way into the checker node.
167     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CHECKER}    ${empty_data}
168     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
169
170 Check_Device_Data_Deletion_Is_Visible_On_Configurer
171     [Documentation]    Check that the device data deletion makes its way into the checker node.
172     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${empty_data}
173     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
174
175 Deconfigure_Device_In_Netconf
176     [Documentation]    Make request to deconfigure the device on Netconf connector.
177     [Tags]    critical
178     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
179     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
180     NetconfKeywords.Remove_Device_From_Netconf    ${DEVICE_NAME}
181
182 Check_Device_Deconfigured_On_Configurer
183     [Documentation]    Check that the device is really going to be gone. Fail if still there after one minute.
184     ...    This is an expected behavior as the unmount request is sent to the config subsystem which
185     ...    then triggers asynchronous disconnection of the device which is reflected in the operational
186     ...    data once completed. This test makes sure this asynchronous operation does not take
187     ...    unreasonable amount of time.
188     [Tags]    critical
189     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
190     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}
191
192 Check_Device_Deconfigured_On_Checker
193     [Documentation]    Check that the device is going to be gone from the checker node. Fail if still there after one minute.
194     [Tags]    critical
195     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CHECKER}
196     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}
197
198 Check_Device_Deconfigured_On_Setter
199     [Documentation]    Check that the device is going to be gone from the setter node. Fail if still there after one minute.
200     [Tags]    critical
201     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
202     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}
203
204 *** Keywords ***
205 Setup_Everything
206     [Documentation]    Setup everything needed for the test cases.
207     # Setup resources used by the suite.
208     SetupUtils.Setup_Utils_For_Setup_And_Teardown
209     NetconfKeywords.Setup_Netconf_Keywords
210     NetconfViaRestconf.Create_NVR_Session    node1    ${ODL_SYSTEM_1_IP}
211     NetconfViaRestconf.Create_NVR_Session    node2    ${ODL_SYSTEM_2_IP}
212     NetconfViaRestconf.Create_NVR_Session    node3    ${ODL_SYSTEM_3_IP}
213
214 Teardown_Everything
215     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
216     Teardown_Netconf_Via_Restconf
217     RequestsLibrary.Delete_All_Sessions
218     NetconfKeywords.Stop_Testtool
219
220 Check_Device_Instance_Count
221     [Arguments]    ${expected}
222     ${count}    NetconfKeywords.Count_Netconf_Connectors_For_Device    ${DEVICE_NAME}
223     Builtin.Should_Be_Equal_As_Strings    ${count}    ${expected}
224
225 Check_Config_Data
226     [Arguments]    ${node}    ${expected}    ${contains}=False
227     NetconfViaRestconf.Activate_NVR_Session    ${node}
228     ${url}=    Builtin.Set_Variable    network-topology:network-topology/topology/topology-netconf/node/${DEVICE_NAME}/yang-ext:mount
229     ${data}=    NetconfViaRestconf.Get_Config_Data_From_URI    ${url}    headers=${ACCEPT_XML}
230     BuiltIn.Run_Keyword_Unless    ${contains}    BuiltIn.Should_Be_Equal_As_Strings    ${data}    ${expected}
231     BuiltIn.Run_Keyword_If    ${contains}    BuiltIn.Should_Contain    ${data}    ${expected}