Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / yangtools / yang-model-validator / yang-model-validator.robot
1 *** Settings ***
2 Documentation     Suite for testing performance of yang-model-validator utility.
3 ...
4 ...               Copyright (c) 2016,2017 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 ...               This suite measures time (only as a test case duration) needed
12 ...               for yang-model-validator to execute on a set of yang model.
13 ...
14 ...               The set of Yang modules is large and fixed (no changes in future).
15 ...               It is the same set of models as in mdsal binding-parent suite.
16 Suite Setup       Setup_Suite
17 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing    # TODO: Suite Teardown to close SSH connections and other cleanup?
18 Test Teardown     Teardown_Test
19 Default Tags      1node    yang-model-validator    critical
20 Library           RequestsLibrary
21 Library           SSHLibrary
22 Library           String
23 Resource          ${CURDIR}/../../../libraries/CompareStream.robot
24 Resource          ${CURDIR}/../../../libraries/NexusKeywords.robot
25 Resource          ${CURDIR}/../../../libraries/RemoteBash.robot
26 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
27 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
28 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
29 Resource          ${CURDIR}/../../../libraries/YangCollection.robot
30
31 *** Variables ***
32 ${TEST_TOOL_NAME}    yang-model-validator
33 ${EXPLICIT_YANG_SYSTEM_TEST_URL}    ${EMPTY}
34 ${NITROGEN_YANG_SYSTEM_TEST_URL}    ${NEXUS_RELEASE_BASE_URL}/org/opendaylight/yangtools/${TEST_TOOL_NAME}/2.0.0/${TEST_TOOL_NAME}-2.0.0-jar-with-dependencies.jar
35 ${OXYGEN_YANG_SYSTEM_TEST_URL}    ${NEXUS_RELEASE_BASE_URL}/org/opendaylight/yangtools/${TEST_TOOL_NAME}/2.0.1/${TEST_TOOL_NAME}-2.0.1-jar-with-dependencies.jar
36
37 *** Test Cases ***
38 Kill_Odl
39     [Documentation]    The ODL instance consumes resources, kill it.
40     ClusterManagement.Kill_Members_From_List_Or_All
41
42 Prepare_Yang_Files_To_Test
43     [Documentation]    Set up collection of Yang files to test with.
44     YangCollection.Static_Set_As_Src
45     ${dirs_to_process} =    Get_Recursive_Dirs    root=src/main/yang
46     ${p_option_value} =    BuiltIn.Catenate    SEPARATOR=:    @{dirs_to_process}
47     ${yang_files_to_validate} =    Get_Yang_Files_From_Dirs    ${dirs_to_process}
48     BuiltIn.Set_Suite_Variable    ${yang_files_to_validate}
49     BuiltIn.Set_Suite_Variable    \${p_option_value}
50
51 Deploy_And_Start_Odl_Yang_Validator_Utility
52     [Documentation]    Download appropriate version of ${TEST_TOOL_NAME} artifact
53     ...    and run it for each single yang file in the prepared set.
54     ...    The version is either given by ${EXPLICIT_YANG_SYSTEM_TEST_URL},
55     ...    or constructed from Jenkins-shaped ${BUNDLE_URL}, or downloaded from Nexus based on ODL version.
56     FOR    ${yang_file}    IN    @{yang_files_to_validate}
57         ${logfile} =    NexusKeywords.Install_And_Start_Java_Artifact    component=yangtools    artifact=${TEST_TOOL_NAME}    suffix=jar-with-dependencies    tool_options=-p ${p_option_value} ${yang_file}
58         ...    explicit_url=${EXPLICIT_YANG_SYSTEM_TEST_URL}
59         BuiltIn.Set_Suite_Variable    \${logfile}
60         Wait_Until_Utility_Finishes
61         Check_Return_Code
62     END
63
64 Collect_Files_To_Archive
65     [Documentation]    Download created files so Releng scripts would archive it.
66     [Setup]    Setup_Test_With_Logging_And_Without_Fast_Failing
67     BuiltIn.Run_Keyword_And_Ignore_Error    SSHLibrary.Get_File    ${logfile}
68
69 *** Keywords ***
70 Setup_Suite
71     [Documentation]    Activate dependency Resources, create SSH connection.
72     SetupUtils.Setup_Utils_For_Setup_And_Teardown
73     ${TEST_TOOL_NAME}=    CompareStream.Set_Variable_If_At_Most_Carbon    yang-system-test    ${TEST_TOOL_NAME}
74     ${EXPLICIT_YANG_SYSTEM_TEST_URL}=    CompareStream.Set_Variable_If_At_Least_Nitrogen    ${NITROGEN_YANG_SYSTEM_TEST_URL}    ${EMPTY}
75     ${EXPLICIT_YANG_SYSTEM_TEST_URL}=    CompareStream.Set_Variable_If_At_Least_Oxygen    ${OXYGEN_YANG_SYSTEM_TEST_URL}    ${EXPLICIT_YANG_SYSTEM_TEST_URL}
76     Set Suite Variable    ${TEST_TOOL_NAME}
77     Set Suite Variable    ${EXPLICIT_YANG_SYSTEM_TEST_URL}
78     NexusKeywords.Initialize_Artifact_Deployment_And_Usage    tools_system_connect=False
79     SSHKeywords.Open_Connection_To_ODL_System
80
81 Teardown_Test
82     [Documentation]    Make sure CWD is set back to dot, then proceed with SetupUtils stuff.
83     SSHKeywords.Set_Cwd    .
84     SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
85
86 Get_Recursive_Dirs
87     [Arguments]    ${root}=.
88     [Documentation]    Return list of sub-directories discovered recursively under ${root} relative to
89     ...    the current working directory for a new shell spawned over the active SSH session.
90     ...    This implementation returns absolute paths as that is easier.
91     ${depth_1} =    SSHLibrary.List_Directories_In_Directory    path=${root}    absolute=True
92     ${subtrees} =    BuiltIn.Create_List
93     FOR    ${subdir}    IN    @{depth_1}
94         ${tree} =    Get_Recursive_Dirs    root=${subdir}
95         # Relative paths would require prepending ${subdir}${/} to each @{tree} element.
96         Collections.Append_To_List    ${subtrees}    ${tree}
97     END
98     ${flat_list} =    Collections.Combine_Lists    ${depth_1}    @{subtrees}
99     [Return]    ${flat_list}
100
101 Get_Yang_Files_From_Dirs
102     [Arguments]    ${dirs_to_process}
103     [Documentation]    Return list of yang files from provided directories
104     ${collected_yang_files} =    BuiltIn.Create_List
105     FOR    ${dir}    IN    @{dirs_to_process}
106         ${yang_files_in_dir} =    SSHLibrary.List_Files_In_Directory    path=${dir}    pattern=*.yang    absolute=True
107         ${collected_yang_files} =    Collections.Combine_Lists    ${collected_yang_files}    ${yang_files_in_dir}
108     END
109     [Return]    ${collected_yang_files}
110
111 Wait_Until_Utility_Finishes
112     [Documentation]    Repeatedly send endline to keep session alive; pass on prompt, fail on timeout.
113     RemoteBash.Wait_Without_Idle    60m
114
115 Check_Return_Code
116     [Documentation]    Get return code of previous command (the utility), pass if it is zero.
117     RemoteBash.Check_Return_Code