Skip to content

Commit

Permalink
[DNM] .github/ci.yml: use bluebox for kerneltest
Browse files Browse the repository at this point in the history
This allows integration tests to be run using qemu at an
arbitrary kernel version. Note that the integration tests
which rely on tools like `bpftool` do not work because
there is nothing in the image.
  • Loading branch information
ajwerner committed Aug 2, 2023
1 parent 8f825f0 commit cc26ffa
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 534 deletions.
79 changes: 58 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ jobs:
with:
toolchain: nightly
components: rust-src
targets: x86_64-unknown-linux-musl

- uses: Swatinem/rust-cache@v2

Expand All @@ -174,53 +175,89 @@ jobs:
sudo apt-get update
sudo apt-get -y install clang gcc-multilib llvm
- uses: actions/setup-go@v4

- name: Install bluebox
run: go install github.com/florianl/bluebox@latest

- name: Build
run: |
set -euxo pipefail
mkdir -p integration-test-binaries
mkdir -p integration-test-images
# See https://doc.rust-lang.org/cargo/reference/profiles.html for the
# names of the builtin profiles. Note that dev builds "debug" targets.
cargo xtask build-integration-test --cargo-arg=--profile=dev | xargs -I % cp % integration-test-binaries/dev
cargo xtask build-integration-test --cargo-arg=--profile=release | xargs -I % cp % integration-test-binaries/release
for profile in dev release; do
cargo xtask build-integration-test \
--cargo-arg=--profile=$profile \
--cargo-arg=--target=x86_64-unknown-linux-musl \
| xargs -I {} bluebox -e {}:--test-threads=1 -o integration-test-images/$profile.initramfs.cpio
done
- uses: actions/upload-artifact@v3
with:
name: integration-test-binaries
path: integration-test-binaries
name: integration-test-images
path: integration-test-images

run-integration-test:
runs-on: macos-latest
needs: ["build-integration-test"]
strategy:
fail-fast: false
matrix:
kernel-version:
- 6.1
steps:
- uses: actions/checkout@v3
with:
path: kernel-images
repository: cilium/ci-kernels
sparse-checkout: |
test/run.sh
test/cloud-localds
linux-${{ matrix.kernel-version }}.bz
- name: Install Pre-requisites
run: |
brew install qemu gnu-getopt coreutils cdrtools
- name: Cache tmp files
uses: actions/cache@v3
with:
path: |
.tmp/*.qcow2
.tmp/test_rsa
.tmp/test_rsa.pub
key: tmp-files-${{ hashFiles('test/run.sh') }}
brew install qemu
- uses: actions/download-artifact@v3
with:
name: integration-test-binaries
path: integration-test-binaries
name: integration-test-images
path: integration-test-images

- name: Run integration tests
run: |
set -euxo pipefail
find integration-test-binaries -type f -exec chmod +x {} \;
test/run.sh integration-test-binaries
mkdir -p logs
# Use '%f\0' to print just the filename and then a NUL byte.
for image in integration-test-images/*; do
IMAGE_NAME="$(basename $image)"
echo "::group:: Running $IMAGE_NAME"
LOG_NAME="logs/integration-test-$IMAGE_NAME.log"
qemu-system-x86_64 \
-no-reboot \
-append 'printk.devkmsg=on kernel.panic=-1 crashkernel=256M' \
-kernel kernel-images/linux-${{ matrix.kernel-version }}.bz \
-initrd $image \
-nographic \
-append 'console=ttyS0' \
-m 512M \
| tee -a "$LOG_NAME"
grep -o -e 'integration_test-[[:alphanum:]]+ exited, exit status [0-9]\+' \
"$LOG_NAME" \
| awk '
BEGIN { exit_code = 0 };
{ exit_code=$NF };
END {
if (NR == 0) {
printf("::error failed to find test exit code");
exit(1);
}
if (exit_code != 0) {
printf("::error test failed with exit code %d", exit_code);
exit(exit_code);
}
}'
echo "::endgroup::"
done
# Provides a single status check for the entire build workflow.
# This is used for merge automation, like Mergify, since GH actions
Expand Down
8 changes: 0 additions & 8 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ From the root of this repository:
cargo xtask integration-test
```

### Virtualized

```
mkdir -p integration-test-binaries
cargo xtask build-integration-test | xargs -I % cp % integration-test-binaries
./test/run.sh integration-test-binaries
```

### Writing an integration test

Tests should follow these guidelines:
Expand Down
264 changes: 0 additions & 264 deletions test/cloud-localds

This file was deleted.

Loading

0 comments on commit cc26ffa

Please sign in to comment.