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 26, 2024
1 parent c0321fc commit d06eeda
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
14 changes: 10 additions & 4 deletions e2etests/boot_tests.bzl
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
def launch_cvd_boot_test(name, branch, target):
def launch_cvd_boot_test(name, branch, target, credential_source = ""):
args = ["-b", branch, "-t", target]
if credential_source:
args += ["-c", credential_source]
native.sh_test(
name = name,
size = "medium",
srcs = ["launch_cvd_boot_test.sh"],
args = ["-b", branch, "-t", target],
args = args,
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 = ""):
args = ["-e", env_file]
if credential_source:
args += ["-c", credential_source]
native.sh_test(
name = name,
size = size,
srcs = ["cvd_load_boot_test.sh"],
args = [env_file],
args = args,
data = [env_file],
tags = [
"exclusive",
Expand Down
31 changes: 25 additions & 6 deletions e2etests/cvd_load_boot_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@

set -e -x

if [[ $# != 1 ]]; then
echo "Usage: $0 ENVIRONMENT_SPECIFICATION_FILE"
usage="Usage: $0 [-c CREDENTIAL_SOURCE] ENVIRONMENT_SPECIFICATION_FILE"

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

if [[ -z "${ENV_FILE}" ]]; then
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 +60,8 @@ 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}"
credential_arg=""
if [[ -n "$CREDENTIAL_SOURCE" ]]; then
credential_arg="--override=fetch.credential_source:${CREDENTIAL_SOURCE}"
fi
cvd load ${credential_arg} "${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 d06eeda

Please sign in to comment.