Fix tox errors
[integration/test.git] / csit / suites / distribution / version.robot
1 *** Settings ***
2 Documentation     Suite for testing ODL distribution ability to report ist version via Restconf.
3 ...
4 ...               Copyright (c) 2016 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 ...               Features needed to be installed:
12 ...               odl-distribution-version (the main feature, defines the version string holder as a config module)
13 ...               odl-netconf-connector (controller-config device is used to access the config subsystem)
14 ...               odl-restconf (or odl-restconf-noauth, to get restconf access to the data mounted by controller-config)
15 ...
16 ...               Variables needed to be rovided on pybot invocation:
17 ...               ${BUNDLEFOLDER} (directory name of ODL installation, as it is suffxed by the distribution version)
18 ...
19 ...               This suite require both Restconf and Netconf-connector to be ready,
20 ...               so it is recommended to run netconfready.robot before running this suite.
21 ...
22 ...               TODO: Figure out a way to reliably predict Odlparent version.
23 ...               Possibly, inspection of system/org/opendaylight/odlparent/ would be required.
24 Suite Setup       Suite_Setup
25 Suite Teardown    Suite_Teardown
26 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
27 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
28 Default Tags      critical    distribution    version
29 Resource          ${CURDIR}/../../libraries/distribution/StreamDistro.robot
30 Resource          ${CURDIR}/../../libraries/TemplatedRequests.robot
31 Resource          ${CURDIR}/../../libraries/SetupUtils.robot
32
33 *** Variables ***
34 ${VERSION_VARDIR}    ${CURDIR}/../../variables/distribution/version
35 ${DEVICE_NAME}    controller-config
36 ${NETCONF_DEV_FOLDER}    ${CURDIR}/../../variables/netconf/device/full-uri-device
37 ${NETCONF_MOUNT_FOLDER}    ${CURDIR}/../../variables/netconf/device/full-uri-mount
38
39 *** Test Cases ***
40 Distribution_Version
41     [Documentation]    Get version string as a part of ${BUNDLEFOLDER} and match with what RESTCONF says.
42     # ${BUNDLEFOLDER} typically looks like this: karaf-0.8.0-SNAPSHOT
43     ${filename_prefix} =    StreamDistro.Compose_Zip_Filename_Prefix
44     ${version} =    BuiltIn.Evaluate    """${BUNDLEFOLDER}"""[len("""${filename_prefix}-"""):]
45     BuiltIn.Wait_Until_Keyword_Succeeds    60x    3s    TemplatedRequests.Get_As_Json_Templated    folder=${VERSION_VARDIR}    mapping={"VERSION":"${version}"}    verify=True
46
47 *** Keywords ***
48 Suite_Setup
49     SetupUtils.Setup_Utils_For_Setup_And_Teardown
50     TemplatedRequests.Create_Default_Session
51     BuiltIn.Run_Keyword_If    """${USE_NETCONF_CONNECTOR}""" == """False"""    Configure_Netconf_Device
52
53 Suite_Teardown
54     BuiltIn.Run_Keyword_If    """${USE_NETCONF_CONNECTOR}""" == """False"""    Remove_Netconf_Device
55
56 Configure_Netconf_Device
57     [Documentation]    Configures netconf device if ${USE_NETCONF_CONNECTOR} is False.
58     &{mapping} =    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    DEVICE_PORT=1830    DEVICE_IP=${ODL_SYSTEM_IP}    DEVICE_USER=admin    DEVICE_PASSWORD=admin
59     TemplatedRequests.Put_As_Xml_Templated    ${NETCONF_DEV_FOLDER}    mapping=${mapping}
60     BuiltIn.Wait_Until_Keyword_Succeeds    10x    3s    TemplatedRequests.Get_As_Xml_Templated    ${NETCONF_MOUNT_FOLDER}    mapping=${mapping}
61
62 Remove_Netconf_Device
63     [Documentation]    Removes netconf device if ${USE_NETCONF_CONNECTOR} is False.
64     &{mapping} =    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}
65     TemplatedRequests.Delete_Templated    ${NETCONF_DEV_FOLDER}    mapping=${mapping}