zentol commented on a change in pull request #15086: URL: https://github.com/apache/flink/pull/15086#discussion_r587373925
########## File path: flink-end-to-end-tests/download_artifacts.sh ########## @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +# This bash script aims to predownload dependency tarballs for the E2E tests. + +if [ -z "$E2E_TARBALL_CACHE" ] ; then + echo "You have to export the E2E Tarball Cache as E2E_TARBALL_CACHE" + exit 1 +fi + +mkdir -p $E2E_TARBALL_CACHE + +# Given a variable name and a URL, checks whether the file exists in the E2E_TARBALL_CACHE, +# otherwise retrieves from source, and evals the path to the result variable. +# For example: +# get_artifact result https://archive.apache.org/artifact.tar.gz +# echo $result + +function get_artifact { + local __resultvar=$1 + BASENAME="`basename $2`" + echo "Checking $2" + if [ -f "$E2E_TARBALL_CACHE/$BASENAME" ]; then + echo "$BASENAME already exists. Retrieving from local cache" + else + echo "$BASENAME does not exist. Retrieving from $2" + curl $2 --retry 10 --retry-max-time 120 --output $E2E_TARBALL_CACHE/$BASENAME + fi + eval $__resultvar="'$E2E_TARBALL_CACHE/$BASENAME'" Review comment: While I suppose this works it is rather unusual (for us), and we'd like to reduce the amount of fancy bash stuff to a minimum because we have enough problems with maintaining them as is. I'd rather go with a simple `echo '$E2E_TARBALL_CACHE/$BASENAME'` and adjusting usages to `cache_path=$(get_artifact ...)` ########## File path: flink-end-to-end-tests/download_artifacts.sh ########## @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +# This bash script aims to predownload dependency tarballs for the E2E tests. + +if [ -z "$E2E_TARBALL_CACHE" ] ; then + echo "You have to export the E2E Tarball Cache as E2E_TARBALL_CACHE" + exit 1 +fi + +mkdir -p $E2E_TARBALL_CACHE + +# Given a variable name and a URL, checks whether the file exists in the E2E_TARBALL_CACHE, +# otherwise retrieves from source, and evals the path to the result variable. +# For example: +# get_artifact result https://archive.apache.org/artifact.tar.gz +# echo $result + +function get_artifact { + local __resultvar=$1 + BASENAME="`basename $2`" + echo "Checking $2" + if [ -f "$E2E_TARBALL_CACHE/$BASENAME" ]; then + echo "$BASENAME already exists. Retrieving from local cache" + else + echo "$BASENAME does not exist. Retrieving from $2" + curl $2 --retry 10 --retry-max-time 120 --output $E2E_TARBALL_CACHE/$BASENAME Review comment: ideally we also check that this download did not fail; otherwise we end up with misleading errors down the line. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
