Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelroquetto committed Aug 22, 2024
1 parent 114d3f4 commit 38c75fd
Show file tree
Hide file tree
Showing 6 changed files with 5,118 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/pull_request_integration_tests_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Pull request integration tests on VM

on:
push:
branches: [ 'main', 'release-*' ]
pull_request:
branches: [ 'main', 'release-*' ]

jobs:
test:
name: test
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.22' ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Clean up disk space
run: |
docker system prune -af
docker volume prune -f
- name: Install QEMU
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends qemu-utils qemu-system-x86
- name: Run VM integration tests
run: |
sudo make -C test/vm
sudo make -C test/vm change-owner
timeout-minutes: 60
- name: Upload integration test logs
uses: actions/upload-artifact@v3
if: always()
with:
name: Test Logs
path: |
testoutput/*.log
testoutput/kind
- name: Report coverage
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./testoutput/itest-covdata.txt
flags: integration-test
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ run-integration-test-k8s:
go clean -testcache
go test -p 1 -failfast -v -timeout 60m -mod vendor -a ./test/integration/... --tags=integration_k8s

.PHONY: run-integration-test-vm
run-integration-test-vm:
@echo "### Running integration tests"
go test -p 1 -failfast -v -timeout 60m -mod vendor -a ./test/integration/... --tags=integration -run "^TestMultiProcess"

.PHONY: integration-test
integration-test: prereqs prepare-integration-test
$(MAKE) run-integration-test || (ret=$$?; $(MAKE) cleanup-integration-test && exit $$ret)
Expand Down
71 changes: 71 additions & 0 deletions test/vm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
FROM alpine:latest

ARG target=run-integration-test-vm

RUN apk update
RUN apk add --no-cache openrc
RUN apk add --no-cache go
RUN apk add --no-cache docker
RUN apk add --no-cache docker-compose
RUN apk add --no-cache git
RUN apk add --no-cache make
RUN apk add --no-cache agetty
RUN apk add --no-cache openssh
RUN apk add --no-cache shadow
RUN ssh-keygen -A

RUN echo "root:root" | chpasswd
RUN sed -i 's/^#PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config

RUN rc-update add localmount default
RUN rc-update add docker default
RUN rc-update add sshd default

RUN echo ttyS0::respawn:/sbin/agetty --autologin root ttyS0 vt100 >> /etc/inittab

RUN mkdir -p /overlay/upper/testoutput /overlay/work
RUN mkdir /build
RUN mkdir /beyla

RUN cat <<EOF >> /etc/fstab
beyla /beyla 9p trans=virtio,version=9p2000.L 0 0
overlay /build overlay lowerdir=/beyla,upperdir=/overlay/upper,workdir=/overlay/work 0 0
tmpfs /tmp tmpfs rw,nodev,nosuid 0 0
devpts /dev/pts devpts defaults 0 0
tmpfs /run tmpfs defaults,size=4G 0 0
testout /build/testoutput 9p trans=virtio,version=9p2000.L 0 0
EOF

RUN echo export GOPATH=/run/go >> /etc/profile
RUN echo export GOCACHE=/run/goache >> /etc/profile

RUN echo beyla > /etc/hostname

RUN cat <<EOF > /etc/network/interfaces
auto eth0
iface eth0 inet dhcp

auto lo
iface lo inet loopback
EOF

RUN rc-update add networking default

RUN cat <<EOF > /etc/init.d/startup
#!/sbin/openrc-run

command="sh /startup.sh"
EOF

RUN chmod +x /etc/init.d/startup

RUN rc-update add startup default

RUN cat <<EOF > /startup.sh
#!/bin/sh

cd /build && make $target
poweroff
EOF

RUN chmod +x /startup.sh
Loading

0 comments on commit 38c75fd

Please sign in to comment.