forked from TraceMachina/nativelink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate integration tests to Bazel and K8s
Remove the broken docker-compose workflows, rewrite the tests to be rootlessly runnable via bazel and pin infrastructure outside of Bazel's build graph in Nix. Each integration test now spins up a nativelink deployment in K8s, runs the test and removes the deployment again. All integration tests now have timeouts to provide faster feedback on failing tests. Apart from a few dynamically declared IPs the new approach is fully reproducible and can reuse containers from the existing nix workflow. The "build nativelink with nativelink" test has been removed as the LRE/Remote test already covers that usecase.
- Loading branch information
1 parent
df6f5b9
commit 827436b
Showing
28 changed files
with
563 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
name: Integration tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
remote: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-22.04] | ||
name: Integration tests / ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout | ||
uses: >- # v4.1.1 | ||
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
- name: Install Nix | ||
uses: >- #v7 | ||
DeterminateSystems/nix-installer-action@5620eb4af6b562c53e4d4628c0b6e4f9d9ae8612 | ||
- name: Cache Nix derivations | ||
uses: >- # Custom commit, last pinned at 2023-11-17. | ||
DeterminateSystems/magic-nix-cache-action@a04e6275a6bea232cd04fc6f3cbf20d4cb02a3e1 | ||
- name: Start Kubernetes cluster | ||
run: > | ||
nix develop --impure --command | ||
bash -c "./deployment-examples/kubernetes/00_infra.sh \ | ||
&& ./deployment-examples/kubernetes/01_operations.sh" | ||
- name: Run warmup tests (intentionally fail) | ||
continue-on-error: true | ||
run: | | ||
nix develop --impure --command | ||
bash -c "bazel test integration_tests \ | ||
--platforms=@rules_nixpkgs_core//platforms:host" | ||
- name: Clean outer directories | ||
run: > | ||
nix develop --impure --command | ||
bash -c "bazel clean" | ||
- name: Run integration tests | ||
run: > | ||
nix develop --impure --command | ||
bash -c "bazel test integration_tests \ | ||
--platforms=@rules_nixpkgs_core//platforms:host" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module( | ||
name = "nativelink", | ||
version = "0.0.0", | ||
) | ||
|
||
bazel_dep( | ||
name = "rules_bazel_integration_test", | ||
version = "0.20.0", | ||
dev_dependency = True, | ||
) | ||
|
||
bazel_binaries = use_extension( | ||
"@rules_bazel_integration_test//:extensions.bzl", | ||
"bazel_binaries", | ||
dev_dependency = True, | ||
) | ||
bazel_binaries.download(version_file = "//:.bazelversion") | ||
use_repo( | ||
bazel_binaries, | ||
"bazel_binaries", | ||
"bazel_binaries_bazelisk", | ||
"build_bazel_bazel_.bazelversion", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
sh_library( | ||
name = "kustomization", | ||
srcs = [ | ||
"cas.json", | ||
"cas.yaml", | ||
"example-do-not-use-in-prod-key.pem", | ||
"example-do-not-use-in-prod-rootca.crt", | ||
"kustomization.yaml", | ||
"routes.yaml", | ||
"scheduler.json", | ||
"scheduler.yaml", | ||
"worker.json.template", | ||
"worker.yaml", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
# This target is used by end-to-end tests running under k8s. To deploy a test | ||
# envirionment, make sure to have a k8s cluster running before invoking the test | ||
# and add this to the testscript: | ||
# | ||
# source $(rlocation nativelink/deployment-examples/kubernetes/k8s) | ||
# | ||
sh_library( | ||
name = "bazel_k8s_prelude", | ||
srcs = ["bazel_k8s_prelude.sh"], | ||
data = [ | ||
":kustomization", | ||
], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@bazel_tools//tools/bash/runfiles", | ||
"@nativelink//:current_tag", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2022 The Native Link Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# --- begin runfiles.bash initialization v3 --- | ||
# Copy-pasted from the Bazel Bash runfiles library v3. | ||
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash | ||
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ | ||
source "$0.runfiles/$f" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e | ||
# --- end runfiles.bash initialization v3 --- | ||
|
||
NATIVELINK_TAG=$(cat "$(rlocation nativelink-current-tag/bin/nativelink-current-tag)") | ||
KUSTOMIZE_DIR=$(rlocation nativelink/deployment-examples/kubernetes) | ||
|
||
remove_resources() { | ||
kubectl kustomize \ | ||
--load-restrictor LoadRestrictionsNone \ | ||
"$KUSTOMIZE_DIR" \ | ||
| kubectl delete -f - \ | ||
|| echo "Resource cleanup failed. Manually verify your cluster." >&2 | ||
} | ||
|
||
trap remove_resources EXIT | ||
|
||
sed "s/__NATIVELINK_TOOLCHAIN_TAG__/${NATIVELINK_TAG}/g" \ | ||
"$KUSTOMIZE_DIR/worker.json.template" \ | ||
> "$KUSTOMIZE_DIR/worker.json" | ||
|
||
kubectl kustomize \ | ||
--load-restrictor LoadRestrictionsNone \ | ||
"$KUSTOMIZE_DIR" \ | ||
| kubectl apply -f - | ||
|
||
kubectl rollout status deploy/nativelink-cas | ||
kubectl rollout status deploy/nativelink-scheduler | ||
kubectl rollout status deploy/nativelink-worker | ||
|
||
# Application code will run here. |
Oops, something went wrong.