Skip to content
Draft
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
25 changes: 20 additions & 5 deletions .kokoro/presubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,29 @@ if [ -f "$CACHE_CONFIG_FILE" ]; then
source "$CACHE_CONFIG_FILE"
fi

"${TOOL_DIR}/buildutils/build_packages.sh" -r "${BAZEL_REMOTE_CACHE}" -c "${CACHE_VERSION}"

# Add test user to the kokoro group so it has access to the source dir
"${TOOL_DIR}/testutils/prepare_host.sh" -d "${REPO_DIR}" -u testrunner -g kokoro
if [[ "${ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS:-}" == *"-p"* ]]; then
retry sudo apt-get install -y docker.io
sudo systemctl start docker || true

sudo docker build -t android-cuttlefish-build:latest -f "${TOOL_DIR}/buildutils/cw/Containerfile" "${REPO_DIR}"
sudo docker run --rm --network=host -v="${REPO_DIR}":/mnt/build -w /mnt/build android-cuttlefish-build:latest base -r "${BAZEL_REMOTE_CACHE}" -c "${CACHE_VERSION}"
sudo docker run --rm --network=host -v="${REPO_DIR}":/mnt/build -w /mnt/build android-cuttlefish-build:latest container
sudo docker run --rm --network=host -v="${REPO_DIR}":/mnt/build -w /mnt/build android-cuttlefish-build:latest frontend
# Clean up temporary packaging directories created during debuild
sudo rm -rf "${REPO_DIR}"/*/debian/tmp

"${TOOL_DIR}/testutils/prepare_host.sh" -d "${REPO_DIR}" -u testrunner -g kokoro -p
sudo -u testrunner "${REPO_DIR}/container/image/image-builder.sh" -c podman -m dev -t localhost/cuttlefish-orchestration:latest
else
"${TOOL_DIR}/buildutils/build_packages.sh" -r "${BAZEL_REMOTE_CACHE}" -c "${CACHE_VERSION}"

# Add test user to the kokoro group so it has access to the source dir
"${TOOL_DIR}/testutils/prepare_host.sh" -d "${REPO_DIR}" -u testrunner -g kokoro
fi

# Allow kokoro group to the source dir:
sudo chmod -R g+w /tmpfs/src

# Run as different user without sudo privileges
sudo -u testrunner CREDENTIAL_SOURCE=gce "${TOOL_DIR}/testutils/runcvde2etests.sh" \
"${ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS}"
${ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS}
14 changes: 14 additions & 0 deletions .kokoro/presubmit_podcvd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
build_file: "android-cuttlefish/.kokoro/presubmit.sh"
env_vars {
key: "ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS"
value: "-p"
}

action {
define_artifacts {
regex: "github/android-cuttlefish/*.deb"

# Matches all files regardless of directory depth:
regex: "kokoro_test_results/**"
}
}
33 changes: 24 additions & 9 deletions tools/testutils/prepare_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ function create_test_user() {
PKG_DIR=""
TEST_USER=""
EXTRA_GROUPS=""
while getopts "d:u:g:" opt; do
PODCVD_MODE=false
while getopts "d:u:g:p" opt; do
case "${opt}" in
u)
TEST_USER="${OPTARG}"
Expand All @@ -55,9 +56,12 @@ while getopts "d:u:g:" opt; do
d)
PKG_DIR="${OPTARG}"
;;
p)
PODCVD_MODE=true
;;
*)
echo "Invalid option: -${opt}"
echo "Usage: $0 -d PACKAGE_DIR [-u TEST_USER [-g EXTRA_GROUPS]]"
echo "Usage: $0 -d PACKAGE_DIR [-u TEST_USER [-g EXTRA_GROUPS]] [-p]"
exit 1
;;
esac
Expand All @@ -69,13 +73,24 @@ if [[ "${PKG_DIR}" == "" ]] || ! [[ -d "${PKG_DIR}" ]]; then
fi

sudo apt-get update
install_pkgs "${PKG_DIR}" cuttlefish-base cuttlefish-metrics cuttlefish-user

check_service_started cuttlefish-host-resources
load_kernel_modules kvm vhost-vsock vhost-net bridge
grant_device_access vhost-vsock vhost-net kvm
check_service_started cuttlefish-operator
if [[ "${PODCVD_MODE}" == true ]]; then
install_pkgs "${PKG_DIR}" cuttlefish-podcvd
load_kernel_modules kvm vhost-vsock vhost-net bridge
grant_device_access vhost-vsock vhost-net kvm
if [[ "${TEST_USER}" != "" ]]; then
create_test_user "${TEST_USER}" "${EXTRA_GROUPS}"
sudo /usr/bin/podcvd-setup "${TEST_USER}"
fi
else
install_pkgs "${PKG_DIR}" cuttlefish-base cuttlefish-metrics cuttlefish-user

check_service_started cuttlefish-host-resources
load_kernel_modules kvm vhost-vsock vhost-net bridge
grant_device_access vhost-vsock vhost-net kvm
check_service_started cuttlefish-operator

if [[ "${TEST_USER}" != "" ]]; then
create_test_user "${TEST_USER}" "${EXTRA_GROUPS}"
if [[ "${TEST_USER}" != "" ]]; then
create_test_user "${TEST_USER}" "${EXTRA_GROUPS}"
fi
fi
10 changes: 8 additions & 2 deletions tools/testutils/runcvde2etests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ OUTPUT_DIR="$(pwd)"
CREDENTIAL_SOURCE="${CREDENTIAL_SOURCE:-}"

bazel_test_tag_filter_arg="--test_tag_filters=-requires_gpu"
while getopts "g" opt; do
podcvd_arg=""
while getopts "gp" opt; do
case "${opt}" in
g)
bazel_test_tag_filter_arg="--test_tag_filters=requires_gpu"
;;
p)
podcvd_arg="--test_env=USE_PODCVD=true --test_env=HOME=${HOME} --test_env=XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
;;
*)
echo "Invalid option: -${opt}"
echo "Usage: $0 [-g]"
echo "Usage: $0 [-g] [-p]"
echo ""
echo "Options"
echo " -g only run tests with the 'requires_gpu' tag"
echo " -p test podcvd instead of cvd"
exit 1
;;
esac
Expand Down Expand Up @@ -63,5 +68,6 @@ fi
bazel test \
${bazel_test_tag_filter_arg} \
${credential_arg} \
${podcvd_arg} \
--zip_undeclared_test_outputs \
cvd/...
Loading