8000 test(e2e/pipelines): run tests on qemu runner by maxgio92 · Pull Request #1999 · chainguard-dev/melange · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test(e2e/pipelines): run tests on qemu runner #1999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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: 23 additions & 2 deletions .github/workflows/melange-test-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
name: Test packages
needs:
- build-melange
runs-on: ubuntu-latest
runs-on: ubuntu-latest-8-core

permissions:
contents: read
Expand Down Expand Up @@ -74,6 +74,27 @@ jobs:
go-version-file: './go.mod'
check-latest: true

- name: Download kernel for VMs
run: |
KERNEL_PKG="$(curl -sL https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | tar -Oxz APKINDEX | awk -F':' '$1 == "P" {printf "%s-", $2} $1 == "V" {printf "%s.apk\n", $2}' | grep "linux-virt" | grep -v dev)"
curl -LSo linux-virt.apk "https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/$KERNEL_PKG"
Comment on lines +79 to +80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to pin to a version here? and verify the checksum?

Copy link
Contributor Author
@maxgio92 maxgio92 May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point @joshrwolf. I think that would be easier to take the latest, to reduce maintenance since we're not really depending on specific kernel features for these tests. Also the one provided by linux-virt for virtualization is based on LTS https://wiki.alpinelinux.org/wiki/Kernels

mkdir -p /tmp/kernel
tar -xf ./linux-virt.apk -C /tmp/kernel/

- name: Install QEMU/KVM
run: |
sudo apt-get update
sudo apt-get -y install qemu-system-x86-64 qemu-kvm

- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Run e2e-tests
run: |
make test-e2e
make \
QEMU_KERNEL_IMAGE=/tmp/kernel/boot/vmlinuz-virt \
QEMU_KERNEL_MODULES=/tmp/kernel/lib/modules/ \
test-e2e
6 changes: 6 additions & 0 deletions e2e-tests/capabilities-add-drop-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ environment:
pipeline:
- name: Test default effective capability
runs: |
# Skip test if on QEMU runner, since the runner does not support process capabilities add/drop Melange feature.
{ test -f /sys/class/dmi/id/sys_vendor && grep -E "^QEMU$" /sys/class/dmi/id/sys_vendor && exit 0; } || true
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -i cap_dac_override

- name: Test added non-default effective capability
runs: |
# Skip test if on QEMU runner, since the runner does not support process capabilities add/drop Melange feature.
{ test -f /sys/class/dmi/id/sys_vendor && grep -E "^QEMU$" /sys/class/dmi/id/sys_vendor && exit 0; } || true
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -i cap_net_admin

- name: Test dropped default effective capability
runs: |
# Skip test if on QEMU runner, since the runner does not support process capabilities add/drop Melange feature.
{ test -f /sys/class/dmi/id/sys_vendor && grep -E "^QEMU$" /sys/class/dmi/id/sys_vendor && exit 0; } || true
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -vi cap_sys_chroot
6 changes: 6 additions & 0 deletions e2e-tests/capabilities-add-drop-nopkg-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ test:
pipeline:
- name: Test default effective capability
runs: |
# Skip test if on QEMU runner, since the runner does not support process capabilities add/drop Melange feature.
{ test -f /sys/class/dmi/id/sys_vendor && grep -E "^QEMU$" /sys/class/dmi/id/sys_vendor && exit 0; } || true
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -i cap_dac_override

- name: Test added non-default effective capability
runs: |
# Skip test if on QEMU runner, since the runner does not support process capabilities add/drop Melange feature.
{ test -f /sys/class/dmi/id/sys_vendor && grep -E "^QEMU$" /sys/class/dmi/id/sys_vendor && exit 0; } || true
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -i cap_net_admin

- name: Test dropped default effective capability
runs: |
# Skip test if on QEMU runner, since the runner does not support process capabilities add/drop Melange feature.
{ test -f /sys/class/dmi/id/sys_vendor && grep -E "^QEMU$" /sys/class/dmi/id/sys_vendor && exit 0; } || true
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -vi cap_sys_chroot
6 changes: 4 additions & 2 deletions e2e-tests/git-checkout-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,16 @@ pipeline:
else
# Ownership of existing files is not changed.
expected_runner=42
expected_melange=6
expected_melange=1
fi
exclude_args="! -regex ^\.\/\.ssh.*$ ! -regex ^./.gitconfig$"
found_runner=$(find . -user $runner_user $exclude_args | wc -l)
mismatch=""
if [[ $found_runner != $expected_runner ]]; then
echo "Expected $expected_runner files owned by $runner_user, found $found_runner"
echo "Expected $expected_runner files owned by the runner user $runner_user, found $found_runner"
find . -user $runner_user $exclude_args
echo "files owned by Melange user $melange_user:"
find . -user $melange_user $exclude_args
mismatch=true
fi
if [[ $melange_user != $runner_user ]]; then
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/greeter-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package:
epoch: 0
dependencies:
runtime:
- dash-binsh
- busybox

environment:
contents:
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ for yaml in "$@"; do
vrc "Testing $base from $yaml for $op" \
${MELANGE} "$op" \
--arch=x86_64 --source-dir=./test-fixtures \
--runner=qemu \
"$yaml" \
${args} $opargs \
"--keyring-append=$PWD/$key.pub" \
Expand Down
Loading
0