Skip to content

Commit bb49221

Browse files
committed
feat: ability to download multiple artifacts
Modify `download_ci_artifacts` to accept artifacts paths as input and download by passing these paths to `ensure_ci_artifacts`. `ensure_ci_artifacts` will default to latest s3 artifacts if no args were provided. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent a47144d commit bb49221

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import host_tools.cargo_build as build_tools
3333
from framework import defs, utils
3434
from framework.artifacts import disks, kernel_params
35-
from framework.defs import DEFAULT_BINARY_DIR, ARTIFACT_DIR
35+
from framework.defs import ARTIFACT_DIR, DEFAULT_BINARY_DIR
3636
from framework.microvm import HugePagesConfig, MicroVMFactory, SnapshotType
3737
from framework.properties import global_props
3838
from framework.utils_cpu_templates import (

tools/devtool

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,13 @@ cmd_help() {
440440
echo " Builds the rootfs and guest kernel artifacts we use for our CI."
441441
echo " Run './tools/devtool build_ci_artifacts help' for more details about the available commands."
442442
echo ""
443-
echo " download_ci_artifacts"
444-
echo " Downloads the CI artifacts used for testing from our S3 bucket."
443+
echo " download_ci_artifacts [s3_path_1, s3_path_2 ...]"
444+
echo " Downloads artifacts from provided S3 paths and runs ./tools/setup-ci-artifacts.sh. for each of them."
445+
echo " If no arguments are provided, pulls newest artifacts from $DEFAULT_ARTIFACTS_S3_BUCKET"
446+
echo " set_current_artifacts s3_path_1"
447+
echo " Sets the $LOCAL_ARTIFACTS_CURRENT_DIR_FILE to contain a local path where the artifacts should be."
448+
echo " It accepts argument in the same format as `download_ci_artifacts`."
449+
echo " This command does not download artifacts."
445450
echo ""
446451

447452
cat <<EOF
@@ -590,10 +595,25 @@ cmd_distclean() {
590595
}
591596

592597
cmd_download_ci_artifacts() {
593-
if [ "$1" = "--force" ]; then
594-
rm -rf $LOCAL_ARTIFACTS_DIR
598+
local artifacts=$1
599+
600+
if [ ${#artifacts[@]} -eq 0 ]; then
601+
download_ci_artifacts
595602
fi
596-
download_ci_artifacts
603+
604+
for artifact in "${artifacts[@]}"; do
605+
download_ci_artifacts $artifact
606+
done
607+
}
608+
609+
cmd_set_current_artifacts() {
610+
local artifacts=$1
611+
if [ -z $artifacts ]; then
612+
say "No artifacts were specified"
613+
fi
614+
local local_artifacts_path=$(get_local_artifacts_path $artifacts)/$(uname -m)
615+
echo $local_artifacts_path > $LOCAL_ARTIFACTS_CURRENT_DIR_FILE
616+
say "Current artifacts setup at " $local_artifacts_path
597617
}
598618

599619
ensure_current_artifacts_are_set_up() {
@@ -607,23 +627,26 @@ ensure_current_artifacts_are_set_up() {
607627
}
608628

609629
download_ci_artifacts() {
610-
if ! command -v aws >/dev/null; then
611-
die "AWS CLI not installed, which is required for downloading artifacts for integration tests."
630+
local artifacts=$1
631+
632+
if [ -z $artifacts ]; then
633+
local default_artifacts=$(get_newest_s3_artifacts)
634+
say "No specific artifacts are defined. Using default artifacts: " $default_artifacts
635+
artifacts=$default_artifacts
612636
fi
613637

614638
# Fetch all the artifacts so they are local
615-
local artifacts_s3_url=$(get_newest_s3_artifacts)
616-
local artifacts_s3_url_arch=$artifacts_s3_url/$(uname -m)
617-
local local_artifacts_path=$(get_local_artifacts_path $artifacts_s3_url)/$(uname -m)
639+
local artifacts_arch=$artifacts/$(uname -m)
640+
local local_artifacts_path=$(get_local_artifacts_path $artifacts)/$(uname -m)
618641

619642
if [ ! -d "$local_artifacts_path" ]; then
620-
say "Fetching artifacts from S3: " $artifacts_s3_url_arch " into: " $local_artifacts_path
643+
say "Fetching artifacts from S3: " $artifacts_arch " into: " $local_artifacts_path
621644
mkdir -pv $local_artifacts_path
622-
aws s3 sync --no-sign-request "$artifacts_s3_url_arch" "$local_artifacts_path"
645+
aws s3 sync --no-sign-request "$artifacts_arch" "$local_artifacts_path"
623646
ok_or_die "Failed to download artifacts using awscli!"
624647
cmd_sh "./tools/setup-ci-artifacts.sh" $local_artifacts_path
625648
else
626-
say "Found existing artifacts " $artifacts_s3_url_arch " at: " $local_artifacts_path
649+
say "Found existing artifacts " $artifacts_arch " at: " $local_artifacts_path
627650
fi
628651

629652
LOCAL_ARTIFACTS_PATH=$local_artifacts_path

0 commit comments

Comments
 (0)