Added missing resource import
[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 Resource          ${CURDIR}/../../../libraries/Utils.robot
29 Variables         ${CURDIR}/../../../variables/Variables.py
30
31 *** Variables ***
32 ${first_case_ok}    False
33 ${NETCONFREADY_WAIT}    60s
34
35 *** Test Cases ***
36 Check_Whether_Netconf_Connector_Works
37     [Documentation]    Make one request to netconf-connector and see if it works.
38     [Tags]    critical
39     Check_Netconf_Connector
40     BuiltIn.Set_Suite_Variable    ${first_case_ok}    True
41
42 Wait_For_Netconf_Connector
43     [Documentation]    Attempt to wait for the netconf-connector for configurable time.
44     [Tags]    critical
45     BuiltIn.Run_Keyword_Unless    ${first_case_ok}    BuiltIn.Wait_Until_Keyword_Succeeds    ${NETCONFREADY_WAIT}    1s    Check_Netconf_Connector
46     [Teardown]    Utils.Report_Failure_Due_To_Bug    4583
47
48 *** Keywords ***
49 Setup_Everything
50     [Documentation]    Setup requests library.
51     RequestsLibrary.Create_Session    ses    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}
52     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
53     # TODO: Alternatively, create variable in Variables which starts with http.
54     # Both TODOs would probably need to update every suite relying on current Variables.
55
56 Teardown_Everything
57     [Documentation]    Destroy all sessions in the requests library.
58     RequestsLibrary.Delete_All_Sessions
59
60 Check_Netconf_Connector
61     [Documentation]    Make a request to netconf connector's list of mounted devices and check that the request was successful.
62     ${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
63     BuiltIn.Log    ${response.text}
64     BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    200