Skip to content

Commit

Permalink
Allow passing credential sources to e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jemoreira committed Mar 25, 2024
1 parent c0321fc commit a2e2501
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
8 changes: 4 additions & 4 deletions e2etests/boot_tests.bzl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
def launch_cvd_boot_test(name, branch, target):
def launch_cvd_boot_test(name, branch, target, credential_source = ""):
native.sh_test(
name = name,
size = "medium",
srcs = ["launch_cvd_boot_test.sh"],
args = ["-b", branch, "-t", target],
args = ["-b", branch, "-t", target, "-c", credential_source],
tags = [
"exclusive",
"external",
"no-sandbox",
],
)

def cvd_load_boot_test(name, env_file, size = "medium"):
def cvd_load_boot_test(name, env_file, size = "medium", credential_source = ""):
native.sh_test(
name = name,
size = size,
srcs = ["cvd_load_boot_test.sh"],
args = [env_file],
args = ["-c", credential_source, env_file],
data = [env_file],
tags = [
"exclusive",
Expand Down
20 changes: 16 additions & 4 deletions e2etests/cvd_load_boot_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@

set -e -x

usage="Usage: $0 [-c CREDENTIAL_SOURCE] ENVIRONMENT_SPECIFICATION_FILE"

CREDENTIAL_SOURCE=""
while getopts "c:" opt; do
case "${opt}" in
c)
CREDENTIAL_SOURCE="${OPTARG}"
;;
*)
echo "${usage}"
exit 1
esac
done

if [[ $# != 1 ]]; then
echo "Usage: $0 ENVIRONMENT_SPECIFICATION_FILE"
echo "${usage}"
exit 1
fi

ls

ENV_FILE="$1"
CMD_OUT="cvd_load_stdout.txt"
CMD_ERR="cvd_load_stderr.txt"
Expand Down Expand Up @@ -45,4 +57,4 @@ trap collect_logs_and_cleanup EXIT
# Make sure there is no cvd server around
cvd reset -y

cvd load "${ENV_FILE}" >"${CMD_OUT}" 2>"${CMD_ERR}"
cvd load --override="fetch.credential_source:${CREDENTIAL_SOURCE}" "${ENV_FILE}" >"${CMD_OUT}" 2>"${CMD_ERR}"
11 changes: 9 additions & 2 deletions e2etests/launch_cvd_boot_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ set -e -x

BRANCH=""
TARGET=""
CREDENTIAL_SOURCE=""

while getopts "b:t:" opt; do
while getopts "c:b:t:" opt; do
case "${opt}" in
b)
BRANCH="${OPTARG}"
;;
c)
CREDENTIAL_SOURCE="${OPTARG}"
;;
t)
TARGET="${OPTARG}"
;;
Expand Down Expand Up @@ -51,7 +55,10 @@ trap collect_logs_and_cleanup EXIT
# client can still connect to the server outside the sandbox and cause issues.
cvd reset -y

cvd fetch --default_build="${BRANCH}/${TARGET}" --target_directory="${workdir}"
cvd fetch \
--default_build="${BRANCH}/${TARGET}" \
--target_directory="${workdir}" \
--credential_source="${CREDENTIAL_SOURCE}"

(
cd "${workdir}"
Expand Down

0 comments on commit a2e2501

Please sign in to comment.