Fix wrong mapping type for templated requests in netconf
[integration/test.git] / csit / suites / netconf / clustering / bug8086.robot
1 *** Settings ***
2 Documentation     Simplified netconf clustered CRUD test suite in Bug 8086 setup.
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           RequestsLibrary
39 Resource          ${CURDIR}/../../../libraries/NetconfKeywords.robot
40 Resource          ${CURDIR}/../../../libraries/NexusKeywords.robot
41 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
42 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
43 Resource          ${CURDIR}/../../../variables/Variables.robot
44
45 *** Variables ***
46 ${NODE_CONFIGURER}    node1
47 ${NODE_SETTER}    node2
48 ${NODE_CHECKER}    node3
49 ${DEVICE_CHECK_TIMEOUT}    10s
50 ${DEVICE_NAME}    netconf-test-device
51 ${directory_with_template_folders}    ${CURDIR}/../../../variables/netconf/CRUD
52 ${empty_data}     <data xmlns="${ODL_NETCONF_NAMESPACE}"></data>
53 ${original_data}    <data xmlns="${ODL_NETCONF_NAMESPACE}"><cont xmlns="urn:opendaylight:test:netconf:crud"><l>Content</l></cont></data>
54 ${modified_data}    <data xmlns="${ODL_NETCONF_NAMESPACE}"><cont xmlns="urn:opendaylight:test:netconf:crud"><l>Modified Content</l></cont></data>
55 ${SCHEMA_DIRECTORY}    /tmp/schema
56
57 *** Test Cases ***
58 Start_Testtool
59     [Documentation]    Deploy and start test tool, then wait for all its devices to become online.
60     NetconfKeywords.Install_And_Start_Testtool    device-count=1    schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas
61
62 Check_Device_Is_Not_Mounted_At_Beginning
63     [Documentation]    Sanity check making sure our device is not there. Fail if found.
64     [Tags]    critical
65     NetconfKeywords.Check_Device_Has_No_Netconf_Connector    ${DEVICE_NAME}    session=${NODE_CONFIGURER}
66
67 Configure_Device_On_Netconf
68     [Documentation]    Make request to configure a testtool device on Netconf connector
69     [Tags]    critical
70     NetconfKeywords.Configure_Device_In_Netconf    ${DEVICE_NAME}    device_type=bug8086    session=${NODE_CONFIGURER}    schema_directory=${SCHEMA_DIRECTORY}
71
72 Check_Configurer_Has_Netconf_Connector_For_Device
73     [Documentation]    Get the list of mounts and search for our device there. Fail if not found.
74     [Tags]    critical
75     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Device_Instance_Count    1    session=${NODE_CONFIGURER}
76
77 Wait_For_Device_To_Become_Visible_For_Configurer
78     [Documentation]    Wait until the device becomes visible on configurer node.
79     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}    session=${NODE_CONFIGURER}
80
81 Wait_For_Device_To_Become_Visible_For_Checker
82     [Documentation]    Wait until the device becomes visible on checker node.
83     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}    session=${NODE_CHECKER}
84
85 Wait_For_Device_To_Become_Visible_For_Setter
86     [Documentation]    Wait until the device becomes visible on setter node.
87     NetconfKeywords.Wait_Device_Connected    ${DEVICE_NAME}    session=${NODE_SETTER}
88
89 Check_Device_Data_Is_Seen_As_Empty_On_Configurer
90     [Documentation]    Get the device data as seen by configurer and make sure it is empty.
91     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${empty_data}
92
93 Check_Device_Data_Is_Seen_As_Empty_On_Checker
94     [Documentation]    Get the device data as seen by checker and make sure it is empty.
95     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CHECKER}    ${empty_data}
96
97 Check_Device_Data_Is_Seen_As_Empty_On_Setter
98     [Documentation]    Get the device data as seen by setter and make sure it is empty.
99     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_SETTER}    ${empty_data}
100
101 Create_Device_Data
102     [Documentation]    Send some sample test data into the device and check that the request went OK.
103     ${template_as_string}=    BuiltIn.Create_Dictionary    DEVICE_NAME=${device_name}
104     TemplatedRequests.Post_As_Xml_Templated    ${directory_with_template_folders}${/}dataorig    ${template_as_string}    session=${NODE_SETTER}
105
106 Check_New_Device_Data_Is_Visible_On_Setter
107     [Documentation]    Get the device data and make sure it contains the created content.
108     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_SETTER}    ${original_data}
109
110 Check_New_Device_Data_Is_Visible_On_Checker
111     [Documentation]    Check that the created device data make their way into the checker node.
112     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CHECKER}    ${original_data}
113
114 Check_New_Device_Data_Is_Visible_On_Configurer
115     [Documentation]    Check that the created device data make their way into the configurer node.
116     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEVICE_CHECK_TIMEOUT}    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${original_data}
117
118 Modify_Device_Data
119     [Documentation]    Send a request to change the sample test data and check that the request went OK.
120     ${template_as_string}=    BuiltIn.Create_Dictionary    DEVICE_NAME=${device_name}
121     TemplatedRequests.Put_As_Xml_Templated    ${directory_with_template_folders}${/}datamod1    ${template_as_string}    session=${NODE_SETTER}
122
123 Check_Device_Data_Is_Modified
124     [Documentation]    Get the device data and make sure it contains the modified content.
125     Check_Config_Data    ${NODE_SETTER}    ${modified_data}
126
127 Check_Modified_Device_Data_Is_Visible_On_Checker
128     [Documentation]    Check that the modified device data make their way into the checker node.
129     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CHECKER}    ${modified_data}
130
131 Check_Modified_Device_Data_Is_Visible_On_Configurer
132     [Documentation]    Check that the modified device data make their way into the configurer node.
133     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${modified_data}
134
135 Delete_Device_Data
136     [Documentation]    Send a request to delete the sample test data on the device and check that the request went OK.
137     ${template_as_string}=    BuiltIn.Create_Dictionary    DEVICE_NAME=${device_name}
138     TemplatedRequests.Delete_Templated    ${directory_with_template_folders}${/}datamod1    ${template_as_string}    session=${NODE_SETTER}
139
140 Check_Device_Data_Is_Deleted
141     [Documentation]    Get the device data and make sure it is empty again.
142     Check_Config_Data    ${NODE_SETTER}    ${empty_data}
143
144 Check_Device_Data_Deletion_Is_Visible_On_Checker
145     [Documentation]    Check that the device data deletion makes its way into the checker node.
146     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CHECKER}    ${empty_data}
147
148 Check_Device_Data_Deletion_Is_Visible_On_Configurer
149     [Documentation]    Check that the device data deletion makes its way into the checker node.
150     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_Config_Data    ${NODE_CONFIGURER}    ${empty_data}
151
152 Deconfigure_Device_In_Netconf
153     [Documentation]    Make request to deconfigure the device on Netconf connector.
154     [Tags]    critical
155     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
156     NetconfKeywords.Remove_Device_From_Netconf    ${DEVICE_NAME}    session=${NODE_CONFIGURER}
157
158 Check_Device_Deconfigured_On_Configurer
159     [Documentation]    Check that the device is really going to be gone. Fail if still there after one minute.
160     ...    This is an expected behavior as the unmount request is sent to the config subsystem which
161     ...    then triggers asynchronous disconnection of the device which is reflected in the operational
162     ...    data once completed. This test makes sure this asynchronous operation does not take
163     ...    unreasonable amount of time.
164     [Tags]    critical
165     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}    session=${NODE_CONFIGURER}
166
167 Check_Device_Deconfigured_On_Checker
168     [Documentation]    Check that the device is going to be gone from the checker node. Fail if still there after one minute.
169     [Tags]    critical
170     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}    session=${NODE_CHECKER}
171
172 Check_Device_Deconfigured_On_Setter
173     [Documentation]    Check that the device is going to be gone from the setter node. Fail if still there after one minute.
174     [Tags]    critical
175     NetconfKeywords.Wait_Device_Fully_Removed    ${DEVICE_NAME}    session=${NODE_SETTER}
176
177 *** Keywords ***
178 Setup_Everything
179     [Documentation]    Initialize resources, sreate sessions, on each ODL machine create a directory and copy the car model there.
180     # Setup resources used by the suite.
181     SetupUtils.Setup_Utils_For_Setup_And_Teardown
182     NetconfKeywords.Setup_Netconf_Keywords    create_session_for_templated_requests=False
183     RequestsLibrary.Create_Session    node1    http://${ODL_SYSTEM_1_IP}:${RESTCONFPORT}    headers=${HEADERS_XML}    auth=${AUTH}
184     RequestsLibrary.Create_Session    node2    http://${ODL_SYSTEM_2_IP}:${RESTCONFPORT}    headers=${HEADERS_XML}    auth=${AUTH}
185     RequestsLibrary.Create_Session    node3    http://${ODL_SYSTEM_3_IP}:${RESTCONFPORT}    headers=${HEADERS_XML}    auth=${AUTH}
186     ${index_list} =    ClusterManagement.List_All_Indices
187     ClusterManagement.Safe_With_Ssh_To_List_Or_All_Run_Keyword    ${index_list}    Populate_Schema_Directory_Over_Active_Connection
188
189 Teardown_Everything
190     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
191     RequestsLibrary.Delete_All_Sessions
192     NetconfKeywords.Stop_Testtool
193
194 Check_Device_Instance_Count
195     [Arguments]    ${expected}    ${session}
196     [Documentation]    Count device instances over ${session} and check the count is ${expected}.
197     ${count}    NetconfKeywords.Count_Netconf_Connectors_For_Device    ${DEVICE_NAME}    session=${session}
198     Builtin.Should_Be_Equal_As_Strings    ${count}    ${expected}
199
200 Check_Config_Data
201     [Arguments]    ${node}    ${expected}    ${contains}=False
202     [Documentation]    Get device data from ${node}. Match against ${expected}, strictness given by ${contains}.
203     ${url}=    Builtin.Set_Variable    ${CONFIG_API}/network-topology:network-topology/topology/topology-netconf/node/${DEVICE_NAME}/yang-ext:mount
204     ${data}=    TemplatedRequests.Get_As_Xml_From_Uri    ${url}    session=${node}
205     BuiltIn.Run_Keyword_Unless    ${contains}    BuiltIn.Should_Be_Equal_As_Strings    ${data}    ${expected}
206     BuiltIn.Run_Keyword_If    ${contains}    BuiltIn.Should_Contain    ${data}    ${expected}
207
208 Populate_Schema_Directory_Over_Active_Connection
209     [Documentation]    Create ${SCHEMA_DIRECTORY}, unpack car.yang there from temporarily downloaded sources jar.
210     ...    TODO: Make this configurable and move to NexusKeywords.
211     ${filename} =    NexusKeywords.Deploy_Artifact    component=carpeople    artifact=clustering-it-model    name_suffix=-sources.jar
212     ${dir} =    BuiltIn.Set_Variable    '${SCHEMA_DIRECTORY}'
213     SSHKeywords.Execute_Command_Should_Pass    mkdir -p '${SCHEMA_DIRECTORY}' && unzip -j '${filename}' META-INF/yang/car@2014-08-18.yang -d '${SCHEMA_DIRECTORY}/' && rm '${filename}'