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