Added link to bug 5089
[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 ${DIRECTORY_WITH_TEMPLATE_FOLDERS}    ${CURDIR}/../../../variables/netconf/CRUD
57 ${DEVICE_NAME}    netconf-test-device
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 Check_Device_Is_Not_Mounted_At_Beginning
64     [Documentation]    Sanity check making sure our device is not there. Fail if found.
65     [Tags]    critical
66     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
67     NetconfKeywords.Check_Device_Has_No_Netconf_Connector    ${DEVICE_NAME}
68
69 Configure_Device_On_Netconf
70     [Documentation]    Make request to configure a testtool device on Netconf connector
71     [Tags]    critical
72     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
73     NetconfKeywords.Configure_Device_In_Netconf    ${DEVICE_NAME}    device_type=configure-via-topology
74     [Teardown]    Utils.Report_Failure_Due_To_Bug    5089
75
76 Check_Configurer_Has_Netconf_Connector_For_Device
77     [Documentation]    Get the list of mounts and search for our device there. Fail if not found.
78     [Tags]    critical
79     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
80     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Device_Instance_Count    1
81
82 Wait_For_Device_To_Become_Visible_For_Configurer
83     [Documentation]    Wait until the device becomes visible on configurer node.
84     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
85     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
86
87 Wait_For_Device_To_Become_Visible_For_Checker
88     [Documentation]    Wait until the device becomes visible on checker node.
89     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CHECKER}
90     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
91
92 Wait_For_Device_To_Become_Visible_For_Setter
93     [Documentation]    Wait until the device becomes visible on setter node.
94     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
95     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}
96
97 Check_Device_Data_Is_Seen_As_Empty_On_Configurer
98     [Documentation]    Get the device data as seen by configurer and make sure it is empty.
99     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${EMPTY_DATA}
100
101 Check_Device_Data_Is_Seen_As_Empty_On_Checker
102     [Documentation]    Get the device data as seen by checker and make sure it is empty.
103     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CHECKER}    ${EMPTY_DATA}
104
105 Check_Device_Data_Is_Seen_As_Empty_On_Setter
106     [Documentation]    Get the device data as seen by setter and make sure it is empty.
107     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_SETTER}    ${EMPTY_DATA}
108
109 Create_Device_Data
110     [Documentation]    Send some sample test data into the device and check that the request went OK.
111     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
112     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${DEVICE_NAME}'}
113     NetconfViaRestconf.Post_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}dataorig    ${template_as_string}
114
115 Check_New_Device_Data_Is_Visible_On_Setter
116     [Documentation]    Get the device data and make sure it contains the created content.
117     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_SETTER}    ${ORIGINAL_DATA}
118
119 Check_New_Device_Data_Is_Visible_On_Checker
120     [Documentation]    Check that the created device data make their way into the checker node.
121     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CHECKER}    ${ORIGINAL_DATA}
122
123 Check_New_Device_Data_Is_Visible_On_Configurer
124     [Documentation]    Check that the created device data make their way into the configurer node.
125     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${ORIGINAL_DATA}
126
127 Modify_Device_Data
128     [Documentation]    Send a request to change the sample test data and check that the request went OK.
129     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
130     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${DEVICE_NAME}'}
131     NetconfViaRestconf.Put_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}datamod1    ${template_as_string}
132     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
133
134 Check_Device_Data_Is_Modified
135     [Documentation]    Get the device data and make sure it contains the modified content.
136     Check_Config_Data    ${NODE_SETTER}    ${MODIFIED_DATA}
137     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
138
139 Check_Modified_Device_Data_Is_Visible_On_Checker
140     [Documentation]    Check that the modified device data make their way into the checker node.
141     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CHECKER}    ${MODIFIED_DATA}
142     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
143
144 Check_Modified_Device_Data_Is_Visible_On_Configurer
145     [Documentation]    Check that the modified device data make their way into the configurer node.
146     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${MODIFIED_DATA}
147     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
148
149 Delete_Device_Data
150     [Documentation]    Send a request to delete the sample test data on the device and check that the request went OK.
151     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
152     ${template_as_string}=    BuiltIn.Set_Variable    {'DEVICE_NAME': '${DEVICE_NAME}'}
153     NetconfViaRestconf.Delete_Xml_Template_Folder_Via_Restconf    ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}datamod1    ${template_as_string}
154     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
155
156 Check_Device_Data_Is_Deleted
157     [Documentation]    Get the device data and make sure it is empty again.
158     Check_Config_Data    ${NODE_SETTER}    ${EMPTY_DATA}
159     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
160
161 Check_Device_Data_Deletion_Is_Visible_On_Checker
162     [Documentation]    Check that the device data deletion makes its way into the checker node.
163     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CHECKER}    ${EMPTY_DATA}
164     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
165
166 Check_Device_Data_Deletion_Is_Visible_On_Configurer
167     [Documentation]    Check that the device data deletion makes its way into the checker node.
168     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${EMPTY_DATA}
169     [Teardown]    Utils.Report_Failure_Due_To_Bug    4968
170
171 Deconfigure_Device_In_Netconf
172     [Documentation]    Make request to deconfigure the device on Netconf connector.
173     [Tags]    critical
174     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
175     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
176     NetconfKeywords.Remove_Device_From_Netconf    ${DEVICE_NAME}
177
178 Check_Device_Deconfigured_On_Configurer
179     [Documentation]    Check that the device is really going to be gone. Fail if still there after one minute.
180     ...    This is an expected behavior as the unmount request is sent to the config subsystem which
181     ...    then triggers asynchronous disconnection of the device which is reflected in the operational
182     ...    data once completed. This test makes sure this asynchronous operation does not take
183     ...    unreasonable amount of time.
184     [Tags]    critical
185     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CONFIGURER}
186     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}
187
188 Check_Device_Deconfigured_On_Checker
189     [Documentation]    Check that the device is going to be gone from the checker node. Fail if still there after one minute.
190     [Tags]    critical
191     NetconfViaRestconf.Activate_NVR_Session    ${NODE_CHECKER}
192     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}
193
194 Check_Device_Deconfigured_On_Setter
195     [Documentation]    Check that the device is going to be gone from the setter node. Fail if still there after one minute.
196     [Tags]    critical
197     NetconfViaRestconf.Activate_NVR_Session    ${NODE_SETTER}
198     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}
199
200 *** Keywords ***
201 Setup_Everything
202     [Documentation]    Setup everything needed for the test cases.
203     # Setup resources used by the suite.
204     SetupUtils.Setup_Utils_For_Setup_And_Teardown
205     NetconfKeywords.Setup_Netconf_Keywords
206     NetconfViaRestconf.Create_NVR_Session    node1    ${ODL_SYSTEM_1_IP}
207     NetconfViaRestconf.Create_NVR_Session    node2    ${ODL_SYSTEM_2_IP}
208     NetconfViaRestconf.Create_NVR_Session    node3    ${ODL_SYSTEM_3_IP}
209     # Connect to the Mininet machine
210     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    prompt=${TOOLS_SYSTEM_PROMPT}
211     Utils.Flexible_Mininet_Login
212     NetconfKeywords.Install_And_Start_Testtool    device-count=1    schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas
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}