Skip to content

Commit e446012

Browse files
committed
chore(devtool): minor adjustments
- rename ensure_current_artifacts_are_set_up to ensure_current_artifacts to shorten a name a bit - rename LOCAL_ARTIFACTS_CURRENT_DIR_FILE to LOCAL_CURRENT_ARTIFACTS_FILE to make name more descriptive - Simplify logs regarding artifacts status - remove ` symbols from cmd_help as bash was interpreting them as actual commands to execute - other minor renamings Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent a54f9e8 commit e446012

File tree

1 file changed

+31
-37
lines changed

1 file changed

+31
-37
lines changed

tools/devtool

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ LOCAL_ARTIFACTS_DIR="build/artifacts"
120120

121121
# File with a single line specifing the name of the
122122
# currently used artifacts
123-
LOCAL_ARTIFACTS_CURRENT_DIR_FILE="build/current_artifacts"
123+
LOCAL_CURRENT_ARTIFACTS_LINK_PATH="build/current_artifacts"
124124

125125
# Full path to the public key mapping on the guest
126126
PUB_KEY_PATH=/root/.ssh/id_rsa.pub
@@ -432,16 +432,16 @@ cmd_help() {
432432
echo " The Firecracker testing system is based on pytest. All arguments after --"
433433
echo " will be passed through to pytest."
434434
echo ""
435-
echo " Args for the `test` itself:"
435+
echo " Args for the 'test' itself:"
436436
echo " -h, --help Print help"
437437
echo " -c, --cpuset-cpus cpulist Set a dedicated cpulist to be used by the tests."
438438
echo " -m, --cpuset-mems memlist Set a dedicated memlist to be used by the tests."
439439
echo " --performance Tweak various setting of the host running the tests (such as C- and P-states)"
440440
echo " to achieve consistent performance. Used for running performance tests in CI."
441441
echo " --ab Run A/B test."
442442
echo " --no-build Skip building step."
443-
echo " --no-archive Skip archiving of `test_result` after the test is done."
444-
echo " --no-kvm-check Skip checking for `/dev/kvm` presence."
443+
echo " --no-archive Skip archiving of 'test_result' after the test is done."
444+
echo " --no-kvm-check Skip checking for '/dev/kvm' presence."
445445
echo " --no-artifacts-check Skip checking existing artifacts."
446446
echo ""
447447
echo " build_ci_artifacts [all|rootfs|kernels]"
@@ -452,18 +452,17 @@ cmd_help() {
452452
echo " Downloads artifacts from provided S3 URI (like s3://spec.ccfc.min/firecracker-ci/my_artifacts)"
453453
echo " and runs ./tools/setup-ci-artifacts.sh. for each of them."
454454
echo " If no arguments are provided, pulls newest artifacts from $DEFAULT_ARTIFACTS_S3_BUCKET"
455-
echo " If `--force` is specified, removes previous artifacts with same name"
455+
echo " If '--force' is specified, removes previous artifacts with same name"
456456
echo ""
457-
echo " set_current_artifacts s3_uri/directory name"
458-
echo " Sets the $LOCAL_ARTIFACTS_CURRENT_DIR_FILE to contain a local path where the artifacts should be."
457+
echo " set_current_artifacts [s3_uri/directory name]"
458+
echo " Sets the $LOCAL_CURRENT_ARTIFACTS_LINK_PATH to contain a local path where the artifacts should be."
459459
echo " Accepts some name used to generate the final directory name. Mainly used with S3 URI"
460-
echo " like `download_ci_artifacts` cmd. Alternatively it is possible to manually write local "
461-
echo " path to artifacts directory into $LOCAL_ARTIFACTS_CURRENT_DIR_FILE file"
460+
echo " like 'download_ci_artifacts'. Alternatively it is possible to manually write local "
461+
echo " path to artifacts directory into $LOCAL_CURRENT_ARTIFACTS_LINK_PATH file"
462462
echo ""
463-
echo " ensure_current_artifacts_are_set_up s3_uri/directory name"
464-
echo " Makes sure the $LOCAL_ARTIFACTS_CURRENT_DIR_FILE file contains a path to current artifacts."
465-
echo " If file already exist, change it to point to specified artifacts. If file does not exist,"
466-
echo " try to download artifacts from S3 and sets them as current."
463+
echo " ensure_current_artifacts [s3_uri/directory name]"
464+
echo " Makes sure the $LOCAL_CURRENT_ARTIFACTS_LINK_PATH file contains a path to current artifacts."
465+
echo " If an optional path/URI is provided, try to set it as current artifacts."
467466
echo ""
468467

469468
cat <<EOF
@@ -616,13 +615,13 @@ cmd_download_ci_artifacts() {
616615
FORCE_ARTIFACT_DOWNLOAD=1
617616
shift 1
618617
fi
619-
local artifacts=$@
618+
local artifacts_list=$@
620619

621-
if [[ -z ${artifacts[@]} ]]; then
620+
if [[ -z ${artifacts_list[@]} ]]; then
622621
download_ci_artifacts
623622
else
624-
for artifact in ${artifacts[@]}; do
625-
download_ci_artifacts $artifact
623+
for artifacts in ${artifacts_list[@]}; do
624+
download_ci_artifacts $artifacts
626625
done
627626
fi
628627
}
@@ -633,34 +632,29 @@ cmd_set_current_artifacts() {
633632
say "No artifacts were specified"
634633
else
635634
local local_artifacts_path=$(get_local_artifacts_path $artifacts)/$(uname -m)
636-
echo $local_artifacts_path > $LOCAL_ARTIFACTS_CURRENT_DIR_FILE
637-
say "Current artifacts setup at " $local_artifacts_path
635+
echo $local_artifacts_path > $LOCAL_CURRENT_ARTIFACTS_LINK_PATH
636+
say "Current artifacts path: " $local_artifacts_path
638637
fi
639638
}
640639

641-
cmd_ensure_current_artifacts_are_set_up() {
640+
cmd_ensure_current_artifacts() {
642641
local artifacts=$1
643-
if [ -f $LOCAL_ARTIFACTS_CURRENT_DIR_FILE ]; then
644-
local current_local_artifacts_path=$(cat $LOCAL_ARTIFACTS_CURRENT_DIR_FILE)
642+
if [ -f $LOCAL_CURRENT_ARTIFACTS_LINK_PATH ]; then
645643
if [ -z $artifacts ]; then
646-
say "Current artifacts already setup at " $current_local_artifacts_path
644+
local current_local_artifacts_path=$(cat $LOCAL_CURRENT_ARTIFACTS_LINK_PATH)
645+
say "Current artifacts path: " $current_local_artifacts_path
647646
else
648647
local local_artifacts_path=$(get_local_artifacts_path $artifacts)/$(uname -m)
649-
if [ $current_local_artifacts_path == $local_artifacts_path ]; then
650-
say "Current artifacts already setup at " $current_local_artifacts_path
651-
else
652-
echo $local_artifacts_path > $LOCAL_ARTIFACTS_CURRENT_DIR_FILE
653-
say "Current artifacts setup at " $local_artifacts_path
654-
fi
648+
say "Current artifacts path: " $local_artifacts_path
655649
fi
656650
else
657651
if [ -z $artifacts ]; then
658652
download_ci_artifacts
659653
else
660654
download_ci_artifacts $artifacts
661655
fi
662-
echo $LOCAL_ARTIFACTS_PATH > $LOCAL_ARTIFACTS_CURRENT_DIR_FILE
663-
say "Current artifacts downloaded and setup at " $LOCAL_ARTIFACTS_PATH
656+
echo $LOCAL_ARTIFACTS_PATH > $LOCAL_CURRENT_ARTIFACTS_LINK_PATH
657+
say "Current artifacts path: " $LOCAL_ARTIFACTS_PATH
664658
fi
665659
}
666660

@@ -689,7 +683,7 @@ download_ci_artifacts() {
689683
ok_or_die "Failed to download artifacts using awscli!"
690684
cmd_sh "./tools/setup-ci-artifacts.sh" $local_artifacts_path
691685
else
692-
say "Found existing artifacts " $artifacts_arch " at: " $local_artifacts_path
686+
say "Found existing artifacts: " $artifacts_arch " at: " $local_artifacts_path
693687
fi
694688

695689
LOCAL_ARTIFACTS_PATH=$local_artifacts_path
@@ -847,9 +841,9 @@ cmd_test() {
847841
ensure_build_dir
848842
if [ $do_artifacts_check != 0 ]; then
849843
if [ -z $artifacts ]; then
850-
cmd_ensure_current_artifacts_are_set_up
844+
cmd_ensure_current_artifacts
851845
else
852-
cmd_ensure_current_artifacts_are_set_up $artifacts
846+
cmd_ensure_current_artifacts $artifacts
853847
fi
854848
fi
855849

@@ -1033,7 +1027,7 @@ cmd_sh() {
10331027

10341028
cmd_sandbox() {
10351029
cmd_build --release
1036-
cmd_ensure_current_artifacts_are_set_up
1030+
cmd_ensure_current_artifacts
10371031
cmd_sh "tmux new env PYTEST_ADDOPTS=--pdbcls=IPython.terminal.debugger:TerminalPdb PYTHONPATH=tests IPYTHONDIR=\$PWD/.ipython ipython -i ./tools/sandbox.py $@"
10381032
cmd_fix_perms ".ipython"
10391033
}
@@ -1055,12 +1049,12 @@ cmd_sandbox_native() {
10551049
pip3.11 install ipython requests requests_unixsocket2 psutil tenacity filelock
10561050
pip3.11 install jsonschema aws_embedded_metrics
10571051
pip3.11 install packaging pytest
1058-
cmd_ensure_current_artifacts_are_set_up
1052+
cmd_ensure_current_artifacts
10591053
tmux neww sudo --preserve-env=HOME,PATH,TMUX env PYTHONPATH=tests IPYTHONDIR=\$PWD/.ipython ipython -i ./tools/sandbox.py $@
10601054
}
10611055

10621056
cmd_test_debug() {
1063-
cmd_ensure_current_artifacts_are_set_up
1057+
cmd_ensure_current_artifacts
10641058
cmd_sh "tmux new ./tools/test.sh --pdb $@"
10651059
}
10661060

0 commit comments

Comments
 (0)