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