Use fallback URL for deploying tools for custom-built .zip
[integration/test.git] / csit / libraries / NexusKeywords.robot
index 4061559317d5a0a2a358fab4b153a06e5a303927..90178aa3313b78db82a0f7e3973f960642c55636 100644 (file)
@@ -11,24 +11,28 @@ Documentation     Nexus repository access keywords.
 ...               This library encapsulates a bunch of somewhat complex and commonly used
 ...               netconf operations into reusable keywords to make writing netconf
 ...               test suites easier.
+Library           OperatingSystem
 Library           SSHLibrary
 Library           String
 Resource          SSHKeywords.robot
 
+*** Variables ***
+${NEXUS_FALLBACK_URL}    http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot
+
 *** Keywords ***
 Initialize_Artifact_Deployment_And_Usage
-    [Documentation]    Initialize Nexus artifact deployment and usage
-    ...    Create and activate a connection to the tools system and perform
-    ...    additional configuration to allow the remaining keywords to deploy
-    ...    and use artifacts from Nexus on the tools system.
-    # Connect to the ODL machine
+    [Arguments]    ${tools_system_connect}=True
+    [Documentation]    Places search utility to ODL system, which will be needed for version detection.
+    ...    By default also initialize a SSH connection to Tools system,
+    ...    as following Keywords assume a working connection towards target system.
+    # Connect to the ODL machine.
     ${odl}=    SSHKeywords.Open_Connection_To_ODL_System
     # Deploy the search tool.
     SSHLibrary.Put_File    ${CURDIR}/../../tools/deployment/search.sh
     SSHLibrary.Close_Connection
-    # Connect to the Tools System machine
-    ${tools}=    SSHKeywords.Open_Connection_To_Tools_System
-    BuiltIn.Set_Suite_Variable    ${SSHKeywords__tools_system_connection}    ${tools}
+    # Optionally connect to the Tools System machine.
+    BuiltIn.Return_From_Keyword_If    not (${tools_system_connect})    # the argument may be a convoluted Python expression
+    SSHKeywords.Open_Connection_To_Tools_System
 
 NexusKeywords__Get_Items_To_Look_At
     [Arguments]    ${component}
@@ -59,9 +63,16 @@ NexusKeywords__Detect_Version_To_Pull
     [Return]    ${version}    ${location}
 
 Deploy_Artifact
-    [Arguments]    ${component}    ${artifact}    ${name_prefix}    ${name_suffix}=-executable.jar    ${type}=snapshot
+    [Arguments]    ${component}    ${artifact}    ${name_prefix}    ${name_suffix}=-executable.jar    ${fallback_url}=${NEXUS_FALLBACK_URL}
     [Documentation]    Deploy the specified artifact from Nexus to the cwd of the machine to which the active SSHLibrary connection points.
-    ${urlbase}=    BuiltIn.Set_Variable    ${NEXUSURL_PREFIX}/content/repositories/opendaylight.${type}
+    ...    Must have ${BUNDLE_URL} variable set to the URL from which the
+    ...    tested ODL distribution was downloaded and this place must be
+    ...    inside a repository created by a standard distribution
+    ...    construction job. If this is detected to ne be the case, fallback URL is used.
+    ${urlbase}=    String.Fetch_From_Left    ${BUNDLE_URL}    /org/opendaylight
+    # If the BUNDLE_URL points somewhere else (perhaps *patch-test* job in Jenkins),
+    # ${urlbase} is the whole ${BUNDLE_URL}, in which case we use the ${fallback_url}
+    ${urlbase}=    BuiltIn.Set_Variable_If    '${urlbase}' != '${BUNDLE_URL}'    ${urlbase}    ${fallback_url}
     ${version}    ${location}=    NexusKeywords__Detect_Version_To_Pull    ${component}
     # TODO: Use RequestsLibrary and String instead of curl and bash utilities?
     ${url}=    BuiltIn.Set_Variable    ${urlbase}/${location}/${artifact}/${version}
@@ -78,10 +89,10 @@ Deploy_Artifact
     [Return]    ${filename}
 
 Deploy_Test_Tool
-    [Arguments]    ${component}    ${artifact}    ${suffix}=executable    ${type}=snapshot
+    [Arguments]    ${component}    ${artifact}    ${suffix}=executable
     [Documentation]    Deploy a test tool.
     ...    The test tools have naming convention of the form
-    ...    "${type}/some/dir/somewhere/<tool-name>/<tool-name>-<version-tag>-${suffix}.jar"
+    ...    "<repository_url>/some/dir/somewhere/<tool-name>/<tool-name>-<version-tag>-${suffix}.jar"
     ...    where "<tool-name>" is the name of the tool and "<version-tag>" is
     ...    the version tag that is digged out of the maven metadata. This
     ...    keyword calculates ${name_prefix} and ${name_suffix} for
@@ -89,5 +100,5 @@ Deploy_Test_Tool
     ...    work of deploying the artifact.
     ${name_prefix}=    BuiltIn.Set_Variable    ${artifact}-
     ${name_suffix}=    BuiltIn.Set_Variable    -${suffix}.jar
-    ${filename}=    Deploy_Artifact    ${component}    ${artifact}    ${name_prefix}    ${name_suffix}    ${type}
+    ${filename}=    Deploy_Artifact    ${component}    ${artifact}    ${name_prefix}    ${name_suffix}
     [Return]    ${filename}