Skip to content

Commit

Permalink
Test kubernetes deployment locally
Browse files Browse the repository at this point in the history
Requires 'minikube' available in the environment.
  • Loading branch information
stagnation committed Jan 10, 2024
1 parent 7a75b74 commit c2e4d0d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tools/diff-docker-and-k8s-configs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -eu -o pipefail
set -eu -o pipefail -E

function diff_config() {
k8s_config="$1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eEuxo pipefail

set -eux -o pipefail -E

bazel_version="$1"

Expand Down
2 changes: 1 addition & 1 deletion tools/remote-toolchains/extract-bazel-auto-toolchains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# `.bazelversion` in the repository root.
#
# Example usage: ./extract-bazel-auto-toolchains.sh ubuntu-act-22-04 ghcr.io/catthehacker/ubuntu:act-22.04
set -eu -o pipefail
set -eu -o pipefail -E

script_dir="$(dirname "${BASH_SOURCE[0]}")"

Expand Down
2 changes: 1 addition & 1 deletion tools/test-deployment-docker-compose.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# Verifies that the docker-compose deployment works.
set -eux -o pipefail
set -eux -o pipefail -E

script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "${script_dir}/../docker-compose"
Expand Down
62 changes: 62 additions & 0 deletions tools/test-deployment-minikube
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Verifies that the kuberenetes deployment works.

set -eux -o pipefail -E

script_dir=$(dirname "${BASH_SOURCE[0]}")
root="$(realpath "$script_dir"/..)"
cd "$root"

abseil_output_base="abseil_output_base"

working_directory="$(realpath tmp-test-bare)"
mkdir "$working_directory"
cd "$working_directory"

# --- Launch kubernetes deployment with 'minikube' ---

# NB: Minikube retains the persistent volume date between restarts
# so we must delete the entire deployment.
minikube delete
minikube start
minikube kubectl -- apply -k "$root"/kubernetes

# Wait for pods to start
# TODO: find a sophisticated solution
sleep 50

minikube kubectl -- -n buildbarn port-forward service/frontend 8980 &
# NB: With kubectl and the minikube daemon
# finding the pid of the port-forward
# is a little bit involved.
# It is not sufficient to take the job process id '$?'
# TODO: Find a better 'ps' invocation to find the process.
# TODO: This is only valid if no one had the port open before,
# we do not want to kill unrelated programs.
# # sleep 5
# # port_forward_pid=$(lsof -i | grep 8980 | awk '{print $2}' | head -1)
sleep 25

cleanup() {
EXIT_STATUS=$?
# # kill "$port_forward_pid" || true
# # wait "$port_forward_pid" || true
rm -rf "$abseil_output_base"
rm -rf "$working_directory"
return "$EXIT_STATUS"
}
trap cleanup EXIT

# --- Run remote execution ---
bazel --output_base="$abseil_output_base" clean
bazel --output_base="$abseil_output_base" \
test --color=no --curses=no --config=remote-local --disk_cache= \
--remote_instance_name= \
--remote_default_exec_properties OSFamily=linux \
--remote_default_exec_properties container-image="docker://ghcr.io/catthehacker/ubuntu:act-22.04@sha256:5f9c35c25db1d51a8ddaae5c0ba8d3c163c5e9a4a6cc97acd409ac7eae239448" \
@abseil-hello//:hello_test
# Make sure there are remote executions but no cache hits.
# INFO: 39 processes: 9 internal, 30 remote.
grep -E '^INFO: [0-9]+ processes: .*[0-9]+ remote[.,]' \
"$abseil_output_base/command.log" \
| grep -v 'remote cache hit'
4 changes: 3 additions & 1 deletion tools/update-container-image-versions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
set -eu -o pipefail

set -eu -o pipefail -E

# Updates the image version in the Docker Compose and Kubernetes deployments.
#
# Run this script as soon as go.mod has been updated.
Expand Down

0 comments on commit c2e4d0d

Please sign in to comment.