Decouple netconf-ready suite and netconf connector.
[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 ...               Try to detect whether Netconf is up and running and wait for
12 ...               it for a configurable time if it is not yet up and running.
13 ...
14 ...               By default this is done by querying netconf-connector and
15 ...               seeing whether it works. Some testsuites expect netconf-connector
16 ...               to be ready as soon as possible and will fail if it is not. We
17 ...               want to see a failure if this is the cause of the failure.
18 ...
19 ...               If the netconf-connector is not ready upon startup (as seen by
20 ...               the first test case failing), the second case starts to repeat
21 ...               the query for a minute to see whether it is going "to fix itself"
22 ...               within the minute. If yes, then the testcase will pass, which
23 ...               indicates that the "ODL cooldown" of 1 minute is not long enough
24 ...               to allow for netconf-connector to initialize properly.
25 ...
26 ...               If the USE_NETCONF_CONNECTOR is forced to be False by the Robot
27 ...               invocation argument, then the suite does not use netconf
28 ...               connector for the readiness detection but merely waits for the
29 ...               Netconf topology to appear. This is a weaker condition when
30 ...               Netconf connector is about to be used but is necessary if the
31 ...               suite in question does not use the Netconf connector.
32 ...
33 ...               If the first test case passed, then the second test case does
34 ...               nothing.
35 ...
36 ...               The third test case then checks whether Netconf can pretty print
37 ...               data. This sometimes makes problems, most likely due to too
38 ...               new Robot Requests library with an interface incompatible with
39 ...               this test suite.
40 Suite Setup       Setup_Everything
41 Suite Teardown    Teardown_Everything
42 Library           RequestsLibrary
43 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
44 Resource          ${CURDIR}/../../../libraries/Utils.robot
45 Variables         ${CURDIR}/../../../variables/Variables.py
46
47 *** Variables ***
48 ${netconf_is_ready}    False
49 ${NETCONFREADY_WAIT}    60s
50 ${USE_NETCONF_CONNECTOR}    True
51 ${DEBUG_LOGGING_FOR_EVERYTHING}    False
52
53 *** Test Cases ***
54 Check_Whether_Netconf_Is_Up_And_Running
55     [Documentation]    Make one request to Netconf topology to see whether Netconf is up and running.
56     [Tags]    exclude
57     Check_Netconf_Up_And_Running
58     BuiltIn.Set_Suite_Variable    ${netconf_is_ready}    True
59     [Teardown]    Utils.Report_Failure_Due_To_Bug    4708
60
61 Wait_For_Netconf
62     [Documentation]    Wait for the Netconf to go up for configurable time.
63     [Tags]    critical
64     BuiltIn.Run_Keyword_Unless    ${netconf_is_ready}    BuiltIn.Wait_Until_Keyword_Succeeds    ${NETCONFREADY_WAIT}    1s    Check_Netconf_Up_And_Running
65     BuiltIn.Set_Suite_Variable    ${netconf_is_ready}    True
66     [Teardown]    Utils.Report_Failure_Due_To_Bug    4583
67
68 Check_Whether_Netconf_Can_Pretty_Print
69     [Documentation]    Make one request to netconf-connector and see if it works.
70     [Tags]    critical
71     Check_Netconf_Up_And_Running    ?prettyPrint=true
72
73 *** Keywords ***
74 Setup_Everything
75     [Documentation]    Setup requests library and log into karaf.log that the netconf readiness wait starts.
76     ${connector}=    BuiltIn.Set_Variable_If    ${USE_NETCONF_CONNECTOR}    /node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/controller-config    ${EMPTY}
77     BuiltIn.Set_Suite_Variable    ${netconf_connector}    ${connector}
78     KarafKeywords.Open_Controller_Karaf_Console_On_Background
79     KarafKeywords.Log_Message_To_Controller_Karaf    Starting Netconf readiness test suite
80     BuiltIn.Run_Keyword_If    ${DEBUG_LOGGING_FOR_EVERYTHING}    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set DEBUG
81     RequestsLibrary.Create_Session    ses    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}
82
83 Teardown_Everything
84     [Documentation]    Destroy all sessions in the requests library and log into karaf.log that the netconf readiness wait is over.
85     KarafKeywords.Log_Message_To_Controller_Karaf    Ending Netconf readiness test suite
86     RequestsLibrary.Delete_All_Sessions
87
88 Check_Netconf_Up_And_Running
89     [Arguments]    ${pretty_print}=${EMPTY}
90     [Documentation]    Make a request to netconf connector's list of mounted devices and check that the request was successful.
91     ${response}=    RequestsLibrary.Get    ses    restconf/config/network-topology:network-topology/topology/topology-netconf${netconf_connector}${pretty_print}
92     BuiltIn.Log    ${response.text}
93     BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    200