You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2022/02/09 14:31:54 UTC

[flink] branch release-1.13 updated: [FLINK-25041][e2e] Improve error handling for missing environment variables in E2E tests

This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a commit to branch release-1.13
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.13 by this push:
     new cff3939  [FLINK-25041][e2e] Improve error handling for missing environment variables in E2E tests
cff3939 is described below

commit cff3939be83aa500fcf2c09f6093c9ecc8d27aa4
Author: Mika Naylor <ma...@autophagy.io>
AuthorDate: Wed Nov 24 13:10:54 2021 +0100

    [FLINK-25041][e2e] Improve error handling for missing environment variables in E2E tests
    
    There are several points where the E2E tests check that an environment
    variable is nonempty before proceeding with the tests, such as the
    E2E_TARBALL_CACHE. Usually, this results in a friendly error message
    stating "You have to export the E2E Tarball Cache as E2E_TARBALL_CACHE".
    
    However, if running the scripts with nounset during development, this results
    in an `E2E_TARBALL_CACHE: unbound variable` error, which is less friendly to
    the user.
    
    This PR changes these instances to use parameter expansion for these
    variables, so that even with nounset, the user recieves the friendly
    error message for a missing environment variable.
    
    (cherry picked from commit 8bd978683f76b691d7edbf4f5eba5f7a9f690672)
---
 flink-end-to-end-tests/run-nightly-tests.sh                         | 2 +-
 flink-end-to-end-tests/test-scripts/common.sh                       | 2 +-
 .../test-scripts/common_artifact_download_cacher.sh                 | 2 +-
 flink-end-to-end-tests/test-scripts/common_s3.sh                    | 6 +++---
 flink-end-to-end-tests/test-scripts/elasticsearch-common.sh         | 2 +-
 flink-end-to-end-tests/test-scripts/kafka-common.sh                 | 2 +-
 flink-end-to-end-tests/test-scripts/test_azure_fs.sh                | 6 +++---
 .../test-scripts/test_resume_externalized_checkpoints.sh            | 2 +-
 tools/ci/test_controller.sh                                         | 4 ++--
 tools/releasing/create_binary_release.sh                            | 2 +-
 tools/releasing/create_release_branch.sh                            | 4 ++--
 tools/releasing/create_snapshot_branch.sh                           | 4 ++--
 tools/releasing/create_source_release.sh                            | 2 +-
 tools/releasing/update_branch_version.sh                            | 4 ++--
 tools/releasing/update_japicmp_configuration.sh                     | 2 +-
 15 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/flink-end-to-end-tests/run-nightly-tests.sh b/flink-end-to-end-tests/run-nightly-tests.sh
index 7ad8e21..449d931 100755
--- a/flink-end-to-end-tests/run-nightly-tests.sh
+++ b/flink-end-to-end-tests/run-nightly-tests.sh
@@ -27,7 +27,7 @@ fi
 
 export END_TO_END_DIR
 
-if [ -z "$FLINK_DIR" ] ; then
+if [ -z "${FLINK_DIR:-}" ] ; then
     echo "You have to export the Flink distribution directory as FLINK_DIR"
     exit 1
 fi
diff --git a/flink-end-to-end-tests/test-scripts/common.sh b/flink-end-to-end-tests/test-scripts/common.sh
index ac9f7fc..790abfa 100644
--- a/flink-end-to-end-tests/test-scripts/common.sh
+++ b/flink-end-to-end-tests/test-scripts/common.sh
@@ -21,7 +21,7 @@
 #set -Eexuo pipefail
 set -o pipefail
 
-if [[ -z $FLINK_DIR ]]; then
+if [[ -z "${FLINK_DIR:-}" ]]; then
     echo "FLINK_DIR needs to point to a Flink distribution directory"
     exit 1
 fi
diff --git a/flink-end-to-end-tests/test-scripts/common_artifact_download_cacher.sh b/flink-end-to-end-tests/test-scripts/common_artifact_download_cacher.sh
index 58976a2..9c80625 100755
--- a/flink-end-to-end-tests/test-scripts/common_artifact_download_cacher.sh
+++ b/flink-end-to-end-tests/test-scripts/common_artifact_download_cacher.sh
@@ -19,7 +19,7 @@
 
 # This bash script aims to predownload dependency tarballs for the E2E tests.
 
-if [ -z "$E2E_TARBALL_CACHE" ] ; then
+if [ -z "${E2E_TARBALL_CACHE:-}" ] ; then
     echo "You have to export the E2E Tarball Cache as E2E_TARBALL_CACHE"
     exit 1
 fi
diff --git a/flink-end-to-end-tests/test-scripts/common_s3.sh b/flink-end-to-end-tests/test-scripts/common_s3.sh
index b7d107c..903fb6a 100644
--- a/flink-end-to-end-tests/test-scripts/common_s3.sh
+++ b/flink-end-to-end-tests/test-scripts/common_s3.sh
@@ -22,21 +22,21 @@ if [[ $S3_SOURCED ]]; then
 fi
 export S3_SOURCED="common_s3.sh"
 
-if [[ -z "$IT_CASE_S3_BUCKET" ]]; then
+if [[ -z "${IT_CASE_S3_BUCKET:-}" ]]; then
     echo "Did not find AWS environment variables, NOT running the e2e test."
     exit 0
 else
     echo "Found AWS bucket $IT_CASE_S3_BUCKET, running the e2e test."
 fi
 
-if [[ -z "$IT_CASE_S3_ACCESS_KEY" ]]; then
+if [[ -z "${IT_CASE_S3_ACCESS_KEY:-}" ]]; then
     echo "Did not find AWS environment variables, NOT running the e2e test."
     exit 0
 else
     echo "Found AWS access key, running the e2e test."
 fi
 
-if [[ -z "$IT_CASE_S3_SECRET_KEY" ]]; then
+if [[ -z "${IT_CASE_S3_SECRET_KEY:-}" ]]; then
     echo "Did not find AWS environment variables, NOT running the e2e test."
     exit 0
 else
diff --git a/flink-end-to-end-tests/test-scripts/elasticsearch-common.sh b/flink-end-to-end-tests/test-scripts/elasticsearch-common.sh
index b932ceb..8de1cd2 100644
--- a/flink-end-to-end-tests/test-scripts/elasticsearch-common.sh
+++ b/flink-end-to-end-tests/test-scripts/elasticsearch-common.sh
@@ -17,7 +17,7 @@
 # limitations under the License.
 ################################################################################
 
-if [[ -z $TEST_DATA_DIR ]]; then
+if [[ -z "${TEST_DATA_DIR:-}" ]]; then
   echo "Must run common.sh before elasticsearch-common.sh."
   exit 1
 fi
diff --git a/flink-end-to-end-tests/test-scripts/kafka-common.sh b/flink-end-to-end-tests/test-scripts/kafka-common.sh
index 9631fc5..4830333 100644
--- a/flink-end-to-end-tests/test-scripts/kafka-common.sh
+++ b/flink-end-to-end-tests/test-scripts/kafka-common.sh
@@ -17,7 +17,7 @@
 # limitations under the License.
 ################################################################################
 
-if [[ -z $TEST_DATA_DIR ]]; then
+if [[ -z "${TEST_DATA_DIR:-}" ]]; then
   echo "Must run common.sh before kafka-common.sh."
   exit 1
 fi
diff --git a/flink-end-to-end-tests/test-scripts/test_azure_fs.sh b/flink-end-to-end-tests/test-scripts/test_azure_fs.sh
index b200e49..0ae880e 100755
--- a/flink-end-to-end-tests/test-scripts/test_azure_fs.sh
+++ b/flink-end-to-end-tests/test-scripts/test_azure_fs.sh
@@ -25,21 +25,21 @@
 
 source "$(dirname "$0")"/common.sh
 
-if [[ -z "$IT_CASE_AZURE_ACCOUNT" ]]; then
+if [[ -z "${IT_CASE_AZURE_ACCOUNT:-}" ]]; then
     echo "Did not find Azure storage account environment variable, NOT running the e2e test."
     exit 0
 else
     echo "Found Azure storage account $IT_CASE_AZURE_ACCOUNT, running the e2e test."
 fi
 
-if [[ -z "$IT_CASE_AZURE_ACCESS_KEY" ]]; then
+if [[ -z "${IT_CASE_AZURE_ACCESS_KEY:-}" ]]; then
     echo "Did not find Azure storage access key environment variable, NOT running the e2e test."
     exit 0
 else
     echo "Found Azure storage access key $IT_CASE_AZURE_ACCESS_KEY, running the e2e test."
 fi
 
-if [[ -z "$IT_CASE_AZURE_CONTAINER" ]]; then
+if [[ -z "${IT_CASE_AZURE_CONTAINER:-}" ]]; then
     echo "Did not find Azure storage container environment variable, NOT running the e2e test."
     exit 0
 else
diff --git a/flink-end-to-end-tests/test-scripts/test_resume_externalized_checkpoints.sh b/flink-end-to-end-tests/test-scripts/test_resume_externalized_checkpoints.sh
index a3f0cf1..c9b1848 100755
--- a/flink-end-to-end-tests/test-scripts/test_resume_externalized_checkpoints.sh
+++ b/flink-end-to-end-tests/test-scripts/test_resume_externalized_checkpoints.sh
@@ -104,7 +104,7 @@ function run_resume_externalized_checkpoints() {
   # take the latest checkpoint
   CHECKPOINT_PATH=$(find_latest_completed_checkpoint ${CHECKPOINT_DIR}/${DATASTREAM_JOB})
 
-  if [ -z $CHECKPOINT_PATH ]; then
+  if [ -z "${CHECKPOINT_PATH:-}" ]; then
     echo "Expected an externalized checkpoint to be present, but none exists."
     exit 1
   fi
diff --git a/tools/ci/test_controller.sh b/tools/ci/test_controller.sh
index c0fa5ad..6e07352 100755
--- a/tools/ci/test_controller.sh
+++ b/tools/ci/test_controller.sh
@@ -38,7 +38,7 @@ STAGE=$1
 # =============================================================================
 
 # check preconditions
-if [ -z "$DEBUG_FILES_OUTPUT_DIR" ] ; then
+if [ -z "${DEBUG_FILES_OUTPUT_DIR:-}" ] ; then
 	echo "ERROR: Environment variable 'DEBUG_FILES_OUTPUT_DIR' is not set but expected by test_controller.sh. Tests may use this location to store debugging files."
 	exit 1
 fi
@@ -48,7 +48,7 @@ if [ ! -d "$DEBUG_FILES_OUTPUT_DIR" ] ; then
 	exit 1
 fi
 
-if [ -z "$STAGE" ] ; then
+if [ -z "${STAGE:-}" ] ; then
 	echo "ERROR: Environment variable 'STAGE' is not set but expected by test_controller.sh. THe variable refers to the stage being executed."
 	exit 1
 fi
diff --git a/tools/releasing/create_binary_release.sh b/tools/releasing/create_binary_release.sh
index 559a753..4c66190 100755
--- a/tools/releasing/create_binary_release.sh
+++ b/tools/releasing/create_binary_release.sh
@@ -24,7 +24,7 @@ SCALA_VERSION=${SCALA_VERSION:-none}
 SKIP_GPG=${SKIP_GPG:-false}
 MVN=${MVN:-mvn}
 
-if [ -z "${RELEASE_VERSION}" ]; then
+if [ -z "${RELEASE_VERSION:-}" ]; then
     echo "RELEASE_VERSION was not set."
     exit 1
 fi
diff --git a/tools/releasing/create_release_branch.sh b/tools/releasing/create_release_branch.sh
index c12e438..59b7fe0 100755
--- a/tools/releasing/create_release_branch.sh
+++ b/tools/releasing/create_release_branch.sh
@@ -23,12 +23,12 @@
 RELEASE_CANDIDATE=${RELEASE_CANDIDATE:-none}
 MVN=${MVN:-mvn}
 
-if [ -z "${OLD_VERSION}" ]; then
+if [ -z "${OLD_VERSION:-}" ]; then
     echo "OLD_VERSION was not set."
     exit 1
 fi
 
-if [ -z "${NEW_VERSION}" ]; then
+if [ -z "${NEW_VERSION:-}" ]; then
     echo "NEW_VERSION was not set."
     exit 1
 fi
diff --git a/tools/releasing/create_snapshot_branch.sh b/tools/releasing/create_snapshot_branch.sh
index b5fcfa6..c3d8674 100755
--- a/tools/releasing/create_snapshot_branch.sh
+++ b/tools/releasing/create_snapshot_branch.sh
@@ -17,12 +17,12 @@
 # limitations under the License.
 #
 
-if [ -z "${SHORT_RELEASE_VERSION}" ]; then
+if [ -z "${SHORT_RELEASE_VERSION:-}" ]; then
     echo "SHORT_RELEASE_VERSION was not set."
     exit 1
 fi
 
-if [ -z "${RELEASE_VERSION}" ]; then
+if [ -z "${RELEASE_VERSION:-}" ]; then
     echo "RELEASE_VERSION was not set."
     exit 1
 fi
diff --git a/tools/releasing/create_source_release.sh b/tools/releasing/create_source_release.sh
index 9952535..bc36271 100755
--- a/tools/releasing/create_source_release.sh
+++ b/tools/releasing/create_source_release.sh
@@ -22,7 +22,7 @@
 ##
 MVN=${MVN:-mvn}
 
-if [ -z "${RELEASE_VERSION}" ]; then
+if [ -z "${RELEASE_VERSION:-}" ]; then
     echo "RELEASE_VERSION was not set."
     exit 1
 fi
diff --git a/tools/releasing/update_branch_version.sh b/tools/releasing/update_branch_version.sh
index 0559487..de50a6c 100755
--- a/tools/releasing/update_branch_version.sh
+++ b/tools/releasing/update_branch_version.sh
@@ -22,12 +22,12 @@
 ##
 MVN=${MVN:-mvn}
 
-if [ -z "${OLD_VERSION}" ]; then
+if [ -z "${OLD_VERSION:-}" ]; then
     echo "OLD_VERSION was not set."
     exit 1
 fi
 
-if [ -z "${NEW_VERSION}" ]; then
+if [ -z "${NEW_VERSION:-}" ]; then
     echo "NEW_VERSION was not set."
     exit 1
 fi
diff --git a/tools/releasing/update_japicmp_configuration.sh b/tools/releasing/update_japicmp_configuration.sh
index 79e771c..e8678a7 100755
--- a/tools/releasing/update_japicmp_configuration.sh
+++ b/tools/releasing/update_japicmp_configuration.sh
@@ -17,7 +17,7 @@
 # limitations under the License.
 #
 
-if [ -z "${NEW_VERSION}" ]; then
+if [ -z "${NEW_VERSION:-}" ]; then
     echo "NEW_VERSION was not set."
     exit 1
 fi