2 Documentation Nexus repository access keywords.
4 ... Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
11 ... This library encapsulates a bunch of somewhat complex and commonly used
12 ... netconf operations into reusable keywords to make writing netconf
13 ... test suites easier.
14 Library OperatingSystem
17 Resource SSHKeywords.robot
20 ${JAVA_7_HOME_CENTOS} /usr/lib/jvm/java-1.7.0
21 ${JAVA_7_HOME_UBUNTU} /usr/lib/jvm/java-7-openjdk-amd64
22 ${JAVA_8_HOME_CENTOS} /usr/lib/jvm/java-1.8.0
23 ${JAVA_8_HOME_UBUNTU} /usr/lib/jvm/java-8-openjdk-amd64
24 ${NEXUS_FALLBACK_URL} ${NEXUSURL_PREFIX}/content/repositories/opendaylight.snapshot
27 Initialize_Artifact_Deployment_And_Usage
28 [Arguments] ${tools_system_connect}=True
29 [Documentation] Places search utility to ODL system, which will be needed for version detection.
30 ... By default also initialize a SSH connection to Tools system,
31 ... as following Keywords assume a working connection towards target system.
32 # Connect to the ODL machine.
33 ${odl}= SSHKeywords.Open_Connection_To_ODL_System
34 # Deploy the search tool.
35 SSHLibrary.Put_File ${CURDIR}/../../tools/deployment/search.sh
36 SSHLibrary.Close_Connection
37 # Optionally connect to the Tools System machine.
38 BuiltIn.Return_From_Keyword_If not (${tools_system_connect}) # the argument may be a convoluted Python expression
39 SSHKeywords.Open_Connection_To_Tools_System
41 NexusKeywords__Get_Items_To_Look_At
42 [Arguments] ${component}
43 [Documentation] Get a list of items that might contain the version number that we are looking for.
44 BuiltIn.Return_From_Keyword_If '${component}' == 'bgpcep' pcep-impl
45 [Return] ${component}-impl
47 NexusKeywords__Detect_Version_To_Pull
48 [Arguments] ${component}
49 [Documentation] Determine the exact Nexus directory to be used as a source for a particular test tool
50 ... Figure out what version of the tool needs to be pulled out of the
51 ... Nexus by looking at the version directory of the subsystem from
52 ... which the tool is being pulled. This code is REALLY UGLY but there
53 ... is no way around it until the bug
54 ... https://bugs.opendaylight.org/show_bug.cgi?id=5206 gets fixed.
55 ... I also don't want to depend on maven-metadata-local.xml and other
56 ... bits and pieces of ODL distribution which are not required for ODL
57 ... to function properly.
58 ${itemlist}= NexusKeywords__Get_Items_To_Look_At ${component}
59 ${current_ssh_connection}= SSHLibrary.Get Connection
60 SSHKeywords.Open_Connection_To_ODL_System
61 ${version} ${result}= SSHLibrary.Execute_Command sh search.sh ${WORKSPACE}/${BUNDLEFOLDER}/system ${itemlist} return_rc=True
62 SSHLibrary.Close_Connection
63 Restore Current SSH Connection From Index ${current_ssh_connection.index}
64 BuiltIn.Log ${version}
65 BuiltIn.Run_Keyword_If ${result}!=0 BuiltIn.Fail Component "${component}" not found, cannot locate test tool
66 ${version} ${location}= String.Split_String ${version} max_split=1
67 [Return] ${version} ${location}
70 [Arguments] ${component} ${artifact} ${name_prefix} ${name_suffix}=-executable.jar ${fallback_url}=${NEXUS_FALLBACK_URL}
71 [Documentation] Deploy the specified artifact from Nexus to the cwd of the machine to which the active SSHLibrary connection points.
72 ... Must have ${BUNDLE_URL} variable set to the URL from which the
73 ... tested ODL distribution was downloaded and this place must be
74 ... inside a repository created by a standard distribution
75 ... construction job. If this is detected to ne be the case, fallback URL is used.
76 ${urlbase}= String.Fetch_From_Left ${BUNDLE_URL} /org/opendaylight
77 # If the BUNDLE_URL points somewhere else (perhaps *patch-test* job in Jenkins),
78 # ${urlbase} is the whole ${BUNDLE_URL}, in which case we use the ${fallback_url}
79 ${urlbase}= BuiltIn.Set_Variable_If '${urlbase}' != '${BUNDLE_URL}' ${urlbase} ${fallback_url}
80 ${version} ${location}= NexusKeywords__Detect_Version_To_Pull ${component}
81 # TODO: Use RequestsLibrary and String instead of curl and bash utilities?
82 ${url}= BuiltIn.Set_Variable ${urlbase}/${location}/${artifact}/${version}
83 ${namepart}= SSHLibrary.Execute_Command curl ${url}/maven-metadata.xml | grep value | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1
84 BuiltIn.Log ${namepart}
85 ${length}= BuiltIn.Get_Length ${namepart}
86 ${namepart}= BuiltIn.Set_Variable_If ${length} == 0 ${version} ${namepart}
87 ${filename}= BuiltIn.Set_Variable ${name_prefix}${namepart}${name_suffix}
88 BuiltIn.Log ${filename}
89 ${url}= BuiltIn.Set_Variable ${url}/${filename}
90 ${response} ${result}= SSHLibrary.Execute_Command wget -q -N ${url} 2>&1 return_rc=True
91 BuiltIn.Log ${response}
92 BuiltIn.Run_Keyword_If ${result} != 0 BuiltIn.Fail Artifact "${artifact}" in component "${component}" could not be downloaded from ${url}
96 [Arguments] ${component} ${artifact} ${suffix}=executable
97 [Documentation] Deploy a test tool.
98 ... The test tools have naming convention of the form
99 ... "<repository_url>/some/dir/somewhere/<tool-name>/<tool-name>-<version-tag>-${suffix}.jar"
100 ... where "<tool-name>" is the name of the tool and "<version-tag>" is
101 ... the version tag that is digged out of the maven metadata. This
102 ... keyword calculates ${name_prefix} and ${name_suffix} for
103 ... "Deploy_Artifact" and then calls "Deploy_Artifact" to do the real
104 ... work of deploying the artifact.
105 ${name_prefix}= BuiltIn.Set_Variable ${artifact}-
106 ${name_suffix}= BuiltIn.Set_Variable -${suffix}.jar
107 ${filename}= Deploy_Artifact ${component} ${artifact} ${name_prefix} ${name_suffix}
110 Compose_Dilemma_Filepath
111 [Arguments] ${default_path} ${specific_path}
112 [Documentation] Query active SSH connection, return specific path if it exists else default path.
113 ${out} ${rc}= SSHLibrary.Execute_Command ls -lA ${specific_path} &2>1 return_rc=True
114 BuiltIn.Return_From_Keyword_If ${rc} == 0 ${specific_path}
115 BuiltIn.Return_From_Keyword ${default_path}
117 Compose_Base_Java_Command
118 [Arguments] ${openjdk}=${JDKVERSION}
119 [Documentation] Return string suitable for launching Java programs over SSHLibrary, depending on JRE version needed.
120 ... This requires that the SSH connection on which the command is going to be used is active as it is needed for querying files.
121 ... Commands composed for one SSH connection shall not be reused on other SSH connections as the two connections may have different Java setups.
122 ... Not directly related to Nexus, but versioned Java tools may need this.
123 BuiltIn.Run_Keyword_And_Return_If """${openjdk}""" == "openjdk8" Compose_Dilemma_Filepath ${JAVA_8_HOME_CENTOS}/bin/java ${JAVA_8_HOME_UBUNTU}/bin/java
124 BuiltIn.Run_Keyword_And_Return_If """${openjdk}""" == "openjdk7" Compose_Dilemma_Filepath ${JAVA_7_HOME_CENTOS}/bin/java ${JAVA_7_HOME_UBUNTU}/bin/java
125 BuiltIn.Return_From_Keyword java
127 Compose_Full_Java_Command
128 [Arguments] ${options} ${openjdk}=${JDKVERSION}
129 [Documentation] Return full Bash command to run Java with given options.
130 ... This requires that the SSH connection on which the command is going to be used is active as it is needed for querying files.
131 ... The options may include JVM options, application command line arguments, Bash redirects and other constructs.
132 ${base_command}= Compose_Base_Java_Command openjdk=${openjdk}
133 ${full_command}= BuiltIn.Set_Variable ${base_command} ${options}
134 BuiltIn.Log ${full_command}
135 [Return] ${full_command}