e784dd9f8510be017cd3cb8be331572bd03115b9
[integration/test.git] / csit / suites / netconf / ready / netconfready.robot
1 *** Settings ***
2 Documentation     netconf-connector readiness test suite.
3 ...
4 ...               Copyright (c) 2015 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 ...               Query netconf-connector and see if it works. Some testsuites
12 ...               expect netconf-connector to be ready as soon as possible and
13 ...               will fail if it is not. We want to see a failure if this is
14 ...               the cause of the failure.
15 ...
16 ...               If the netconf-connector is not ready upon startup (as seen by
17 ...               the first test case failing), the second case starts to repeat
18 ...               the query for a minute to see whether it is going "to fix itself"
19 ...               within the minute. If yes, then the testcase will pass, which
20 ...               indicates that the "ODL cooldown" of 1 minute is not long enough
21 ...               to allow for netconf-connector to initialize properly.
22 ...
23 ...               If the first test case passed, then the second test case does
24 ...               nothing.
25 Suite Setup       Setup_Everything
26 Suite Teardown    Teardown_Everything
27 Library           RequestsLibrary
28 Variables         ${CURDIR}/../../../variables/Variables.py
29
30 *** Variables ***
31 ${first_case_ok}    False
32 ${NETCONFREADY_WAIT}    60s
33
34 *** Test Cases ***
35 Check_Whether_Netconf_Connector_Works
36     [Documentation]    Make one request to netconf-connector and see if it works.
37     [Tags]    critical
38     Check_Netconf_Connector
39     BuiltIn.Set_Suite_Variable    ${first_case_ok}    True
40
41 Wait_For_Netconf_Connector
42     [Documentation]    Attempt to wait for the netconf-connector for configurable time.
43     [Tags]    critical
44     BuiltIn.Run_Keyword_Unless    ${first_case_ok}    BuiltIn.Wait_Until_Keyword_Succeeds    ${NETCONFREADY_WAIT}    1s    Check_Netconf_Connector
45     [Teardown]    Utils.Report_Failure_Due_To_Bug    4583
46
47 *** Keywords ***
48 Setup_Everything
49     [Documentation]    Setup requests library.
50     RequestsLibrary.Create_Session    ses    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}
51     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
52     # TODO: Alternatively, create variable in Variables which starts with http.
53     # Both TODOs would probably need to update every suite relying on current Variables.
54
55 Teardown_Everything
56     [Documentation]    Destroy all sessions in the requests library.
57     RequestsLibrary.Delete_All_Sessions
58
59 Check_Netconf_Connector
60     [Documentation]    Make a request to netconf connector's list of mounted devices and check that the request was successful.
61     ${response}=    RequestsLibrary.Get    ses    restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/controller-config/?prettyPrint=true
62     BuiltIn.Log    ${response.text}
63     BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    200