Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / mdsal / binding_v1 / binding-parent.robot
1 *** Settings ***
2 Documentation     Suite for testing performance of Java binding v1 using binding-parent.
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 ...               This suite tests performance of binding-parent from Mdsal project.
12 ...               It measures time (only as a test case duration) needed to create Java bindings (v1).
13 ...               It uses large set of Yang modules, collected from YangModels and openconfig
14 ...               github projects.
15 ...               Some modules are removed prior to testing, as they either do not conform to RFC6020,
16 ...               or they trigger known Bugs in ODL.
17 ...               Known Bugs: 6125, 6135, 6141, 2323, 6150, 2360, 138, 6172, 6180, 6183, 5772, 6189.
18 ...
19 ...               The suite performs installation of Maven, optionally with building patched artifacts.
20 ...
21 ...               FIXME: This suite does not work when run with URL from Autorelease.
22 ...               The thing is, mdsal-parent is not part of .zip distribution.
23 ...               The fix would need to override the usual maven settings,
24 ...               as Autorelease artifacts have non-snapshot versions, but they are not released yet.
25 Suite Setup       Setup_Suite
26 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
27 Test Teardown     Teardown_Test
28 Default Tags      1node    binding_v1    critical
29 Library           SSHLibrary
30 Library           String
31 Library           XML
32 Resource          ${CURDIR}/../../../libraries/NexusKeywords.robot
33 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
34 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
35 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
36 Resource          ${CURDIR}/../../../libraries/YangCollection.robot
37
38 *** Variables ***
39 ${BRANCH}         ${EMPTY}
40 ${MAVEN_OUTPUT_FILENAME}    maven.log
41 ${PATCHES_TO_BUILD}    ${EMPTY}
42 ${POM_FILENAME}    binding-parent-test.xml
43
44 *** Test Cases ***
45 Kill_Odl
46     [Documentation]    The ODL instance consumes resources, stop it.
47     ClusterManagement.Stop_Members_From_List_Or_All
48
49 Detect_Config_Version
50     [Documentation]    Examine ODL installation to figure out which version of binding-parent should be used.
51     ...    Parent poms are not present in Karaf installation, so NexusKeywords search for a component
52     ...    associated with bindingv1 nickname.
53     ${version}    ${location} =    NexusKeywords.NexusKeywords__Detect_Version_To_Pull    component=bindingv1
54     BuiltIn.Set_Suite_Variable    \${binding_parent_version}    ${version}
55
56 Install_Maven
57     [Documentation]    Install Maven, optionally perform multipatch build.
58     NexusKeywords.Install_Maven    branch=${BRANCH}    patches=${PATCHES_TO_BUILD}
59
60 Prepare_Yang_Files_To_Test
61     [Documentation]    Set up collection of Yang files to test with.
62     YangCollection.Static_Set_As_Src
63
64 Run_Maven
65     [Documentation]    Create pom file with correct version and run maven with some performance switches.
66     ${final_pom} =    TemplatedRequests.Resolve_Text_From_Template_File    folder=${CURDIR}/../../../variables/mdsal/binding_v1    file_name=binding_template.xml    mapping={"BINDING_PARENT_VERSION":"${binding_parent_version}"}
67     SSHKeywords.Execute_Command_At_Cwd_Should_Pass    echo '${final_pom}' > '${POM_FILENAME}'
68     ${autorelease_dir} =    String.Get_Regexp_Matches    ${BUNDLE_URL}    (autorelease-[0-9]+)
69     BuiltIn.Run_Keyword_If    ${autorelease_dir} != []    Add_Autorelease_Profile    @{autorelease_dir}[0]
70     NexusKeywords.Run_Maven    pom_file=${POM_FILENAME}    log_file=${MAVEN_OUTPUT_FILENAME}
71     # TODO: Figure out patters to identify various known Bug symptoms.
72
73 Collect_Filest_To_Archive
74     [Documentation]    Download created files so Releng scripts would archive it. Size of maven log is usually under 7 megabytes.
75     [Setup]    FailFast.Run_Even_When_Failing_Fast
76     SSHKeywords.Open_Connection_To_ODL_System    # The original one may have timed out.
77     BuiltIn.Run_Keyword_And_Ignore_Error    SSHLibrary.Get_File    ${MAVEN_DEFAULT_OUTPUT_FILENAME}    # only present if multipatch build happened
78     SSHLibrary.Get_File    settings.xml
79     SSHLibrary.Get_File    ${POM_FILENAME}
80     SSHLibrary.Get_File    ${MAVEN_OUTPUT_FILENAME}
81
82 *** Keywords ***
83 Setup_Suite
84     [Documentation]    Activate dependency Resources, create SSH connection.
85     SetupUtils.Setup_Utils_For_Setup_And_Teardown
86     NexusKeywords.Initialize_Artifact_Deployment_And_Usage    tools_system_connect=False
87     SSHKeywords.Open_Connection_To_ODL_System
88
89 Teardown_Test
90     [Documentation]    Make sure CWD is set back to dot, then proceed with SetupUtils stuff.
91     SSHKeywords.Set_Cwd    .
92     SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
93
94 Add_Autorelease_Profile
95     [Arguments]    ${nexus_autorelease_dir}
96     [Documentation]    Add autorelease repository into the settings.xml file.
97     SSHLibrary.Get_File    settings.xml
98     ${root} =    XML.Parse_Xml    settings.xml
99     ${profiles} =    Xml.Get_Elements    ${root}    xpath=profiles/profile
100     FOR    ${profile}    IN    @{profiles}
101         ${id} =    XML.Get_Element_Text    ${profile}    xpath=id
102         BuiltIn.Exit_For_Loop_If    "${id}" == "opendaylight-release"
103     END
104     BuiltIn.Should_Be_Equal_As_Strings    ${id}    opendaylight-release
105     ${profile} =    Xml.Copy_Element    ${profile}
106     XML.Set_Element_Text    ${profile}    opendaylight-autorelease    xpath=id
107     Update_Repository_Element    ${profile}    repositories/repository    ${nexus_autorelease_dir}
108     Update_Repository_Element    ${profile}    pluginRepositories/pluginRepository    ${nexus_autorelease_dir}
109     XML.Add_Element    ${root}    ${profile}    xpath=profiles
110     ${profiles} =    XML.Get_Elements    ${root}    xpath=activeProfiles/activeProfile
111     ${profile} =    XML.Copy_Element    @{profiles}[0]
112     XML.Set_Element_Text    ${profile}    opendaylight-autorelease
113     XML.Add_Element    ${root}    ${profile}    xpath=activeProfiles
114     ${content} =    XML.Log_Element    ${root}
115     XML.Save_Xml    ${root}    settings.xml
116     SSHLibrary.Put_File    settings.xml
117
118 Update_Repository_Element
119     [Arguments]    ${profile}    ${repo_xpath}    ${nexus_autorelease_dir}
120     [Documentation]    Modify given profile to use autorelease dir in nexus
121     ${repository} =    XML.Get_Element    ${profile}    xpath=${repo_xpath}
122     ${url} =    XML.Get_Element_Text    ${repository}    xpath=url
123     ${url} =    String.Replace_String    ${url}    public    ${nexus_autorelease_dir}
124     XML.Set_Element_Text    ${repository}    ${url}    xpath=url
125     XML.Set_Element_Text    ${repository}    opendaylight-autorelease    xpath=id
126     XML.Set_Element_Text    ${repository}    opendaylight-autorelease    xpath=name