Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Improve fusion-symlink.nf test #5819

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions tests/checks/fusion-symlink.nf/.checks
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
#!/bin/bash

# Retry a command with exponential backoff. The function returns 0 if the command was successful
# on its first attempt, 1 if the command failed after all attempts, and 2 if the command was successful
# after one or more retries.
function _retry {

if [[ $# -lt 4 ]]; then
echo "Usage: _retry <max_attempts> <initial_delay> <max_delay> <cmd>"
return 1
fi

local max_attempts="$1"; shift
local initial_delay="$1"; shift
local max_delay="$1"; shift
local cmd=( "$@" )
local attempt_num=1
local max_attempts=${max_attempts}
local max_delay=${max_delay}
local initial_delay=${initial_delay}
local exit_code=0

until "${cmd[@]}"; do
exit_code=2
if (( attempt_num == max_attempts )); then
echo "-- [$attempt_num/$max_attempts] attempt failed! No more attempts left."
return 1
fi
echo "-- [$attempt_num/$max_attempts] attempt failed! Retrying in ${initial_delay}s..."
sleep "$initial_delay"
(( attempt_num++ ))
(( initial_delay *= 2 ))
if (( initial_delay > max_delay )); then
initial_delay=$max_delay
fi
done
echo "-- [$attempt_num/$max_attempts] attempt succeeded!"
return $exit_code
}

# Skip test if AWS keys are missing
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
echo "Missing AWS credentials -- Skipping test"
Expand All @@ -12,7 +50,11 @@ fi
echo initial run
$NXF_RUN -c .config

$NXF_CMD fs cp s3://nextflow-ci/work/ci-test/fusion-symlink/data.txt data.txt
_retry 5 1 16 "$NXF_CMD" fs cp s3://nextflow-ci/work/ci-test/fusion-symlink/data.txt data.txt
if [ $? -eq 2 ]; then
echo "succeeded on retry"
false
fi
cmp data.txt .expected || false

#
Expand All @@ -21,5 +63,10 @@ cmp data.txt .expected || false
echo resumed run
$NXF_RUN -c .config -resume

$NXF_CMD fs cp s3://nextflow-ci/work/ci-test/fusion-symlink/data.txt data.txt
_retry 5 1 16 "$NXF_CMD" fs cp s3://nextflow-ci/work/ci-test/fusion-symlink/data.txt data.txt
if [ $? -eq 2 ]; then
echo "succeeded on retry"
false

fi
cmp data.txt .expected || false
1 change: 1 addition & 0 deletions tests/checks/fusion-symlink.nf/.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ workDir = 's3://nextflow-ci/work'
fusion.enabled = true
fusion.exportStorageCredentials = true
wave.enabled = true
docker.runOptions = '-e FUSION_TRACING_DESTINATION=objectstore://'
Loading