Skip to content
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

[Release-1.27] Docker and E2E Test Backports #9708

Merged
merged 12 commits into from
Mar 8, 2024
5 changes: 0 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,6 @@ steps:
- vagrant destroy -f
- go test -v -timeout=30m ./secretsencryption_test.go -ci -local
- cp ./coverage.out /tmp/artifacts/se-coverage.out
- cd ../startup
- vagrant destroy -f
- go test -v -timeout=30m ./startup_test.go -ci -local
- cp ./coverage.out /tmp/artifacts/startup-coverage.out
- |
if [ "$DRONE_BUILD_EVENT" = "pull_request" ]; then
cd ../upgradecluster
Expand All @@ -673,7 +669,6 @@ steps:
files:
- /tmp/artifacts/validate-coverage.out
- /tmp/artifacts/se-coverage.out
- /tmp/artifacts/startup-coverage.out
- /tmp/artifacts/upgrade-coverage.out
flags:
- e2etests
Expand Down
10 changes: 9 additions & 1 deletion .github/actions/vagrant-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ runs:
run: |
sudo apt-get build-dep -y vagrant ruby-libvirt
sudo apt-get install -y --no-install-recommends libxslt-dev libxml2-dev libvirt-dev ruby-bundler ruby-dev zlib1g-dev
# This is a workaround for the libvirt group not being available in the current shell
# https://github.com/actions/runner-images/issues/7670#issuecomment-1900711711
- name: Make the libvirt socket rw accessible to everyone
shell: bash
run: |
sudo chmod a+rw /var/run/libvirt/libvirt-sock


- name: Install vagrant-libvirt plugin
shell: bash
run: sudo vagrant plugin install vagrant-libvirt
run: vagrant plugin install vagrant-libvirt
16 changes: 13 additions & 3 deletions .github/workflows/build-k3s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
type: boolean
required: false
default: false
upload-image:
type: boolean
required: false
default: false

permissions:
contents: read
Expand All @@ -18,25 +22,31 @@ jobs:
timeout-minutes: 20
steps:
- name: Checkout K3s
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build K3s binary
run: |
DOCKER_BUILDKIT=1 SKIP_IMAGE=1 SKIP_AIRGAP=1 SKIP_VALIDATE=1 GOCOVER=1 make
sha256sum dist/artifacts/k3s | sed 's|dist/artifacts/||' > dist/artifacts/k3s.sha256sum
- name: Build K3s image
if: inputs.upload-image == true
run: make package-image
- name: bundle repo
if: inputs.upload-repo == true
run: |
tar -czvf ../k3s-repo.tar.gz .
mv ../k3s-repo.tar.gz .
- name: "Upload K3s directory"
if: inputs.upload-repo == true
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: k3s-repo.tar.gz
path: k3s-repo.tar.gz
- name: "Save K3s image"
if: inputs.upload-image == true
run: docker image save rancher/k3s -o ./dist/artifacts/k3s-image.tar
- name: "Upload K3s binary"
if: inputs.upload-repo == false
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: k3s
path: dist/artifacts/k3s*
115 changes: 115 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: E2E Test Coverage
on:
push:
paths-ignore:
- "**.md"
- "channel.yaml"
- "install.sh"
- "tests/**"
- "!tests/e2e**"
- ".github/**"
- "!.github/workflows/e2e.yaml"
pull_request:
paths-ignore:
- "**.md"
- "channel.yaml"
- "install.sh"
- "tests/**"
- "!tests/e2e**"
- ".github/**"
- "!.github/workflows/e2e.yaml"
workflow_dispatch: {}

permissions:
contents: read

jobs:
build:
uses: ./.github/workflows/build-k3s.yaml
with:
upload-image: true
e2e:
name: "E2E Tests"
needs: build
runs-on: ubuntu-latest
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
# TODO fix embeddedmirror and add it to the matrix
etest: [startup, s3, btrfs, externalip, privateregistry]
max-parallel: 3
steps:
- name: "Checkout"
uses: actions/checkout@v4
with: {fetch-depth: 1}

- name: Set up vagrant and libvirt
uses: ./.github/actions/vagrant-setup
- name: "Vagrant Cache"
uses: actions/cache@v4
with:
path: |
~/.vagrant.d/boxes
key: vagrant-box-ubuntu-2204
- name: "Vagrant Plugin(s)"
run: vagrant plugin install vagrant-k3s vagrant-reload vagrant-scp

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: false
- name: "Download k3s binary"
uses: actions/download-artifact@v4
with:
name: k3s
path: ./dist/artifacts

- name: Run ${{ matrix.etest }} Test
env:
E2E_GOCOVER: "true"
run: |
chmod +x ./dist/artifacts/k3s
cd tests/e2e/${{ matrix.etest }}
go test -v -timeout=45m ./${{ matrix.etest}}_test.go -ci -local
- name: On Failure, Launch Debug Session
uses: lhotari/action-upterm@v1
if: ${{ failure() }}
with:
## If no one connects after 5 minutes, shut down server.
wait-timeout-minutes: 5
- name: Upload Results To Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: tests/e2e/${{ matrix.etest }}/coverage.out
flags: e2etests # optional
verbose: true # optional (default = false)
docker:
needs: build
name: Docker Tests
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
dtest: [basics, bootstraptoken, cacerts, lazypull, upgrade]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: "Download k3s image"
uses: actions/download-artifact@v4
with:
name: k3s
path: ./dist/artifacts
- name: Load k3s image
run: docker image load -i ./dist/artifacts/k3s-image.tar
- name: Run ${{ matrix.dtest }} Test
run: |
chmod +x ./dist/artifacts/k3s
. ./tests/docker/test-helpers
. ./tests/docker/test-run-${{ matrix.dtest }}
echo "Did test-run-${{ matrix.dtest }} pass $?"
51 changes: 20 additions & 31 deletions .github/workflows/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,72 +39,61 @@ jobs:
INSTALL_K3S_SKIP_DOWNLOAD: binary
steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4
with: {fetch-depth: 1}
- name: Set up vagrant and libvirt
uses: ./.github/actions/vagrant-setup

- name: "Vagrant Cache"
uses: actions/cache@v4
with:
path: |
/tmp/boxes
~/.vagrant.d/boxes
key: vagrant-box-${{ matrix.vm }}
# Workaround for https://github.com/actions/cache/issues/1319
- name: Move vagrant cache to /root
run: |
mkdir -p /tmp/boxes
sudo rm -rf /root/.vagrant.d/boxes
sudo mv -f /tmp/boxes /root/.vagrant.d
- name: "Vagrant Plugin(s)"
run: sudo vagrant plugin install vagrant-k3s vagrant-reload vagrant-scp
run: vagrant plugin install vagrant-k3s vagrant-reload vagrant-scp
- name: "Download k3s binary"
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: k3s
path: tests/install/${{ matrix.vm }}
- name: "Vagrant Up"
run: sudo vagrant up --no-provision
run: vagrant up --no-provision
- name: "Upload k3s binary to VM"
run: |
chmod +x k3s
sudo vagrant scp k3s /tmp/k3s
sudo vagrant ssh -c "sudo mv /tmp/k3s /usr/local/bin/k3s"
sudo vagrant provision --provision-with=k3s-upload
vagrant scp k3s /tmp/k3s
vagrant ssh -c "sudo mv /tmp/k3s /usr/local/bin/k3s"
vagrant provision --provision-with=k3s-upload
- name: Add binary to PATH
if: matrix.vm == 'centos-7' || matrix.vm == 'rocky-8' || matrix.vm == 'rocky-9' || matrix.vm == 'opensuse-leap'
run: sudo vagrant provision --provision-with=add-bin-path
run: vagrant provision --provision-with=add-bin-path
- name: "⏩ Install K3s"
run: |
sudo vagrant provision --provision-with=k3s-prepare
sudo vagrant provision --provision-with=k3s-install
vagrant provision --provision-with=k3s-prepare
vagrant provision --provision-with=k3s-install
if [ ${{ matrix.vm }} = 'opensuse-microos' ]; then vagrant reload --no-provision; fi
- name: "⏳ Node"
run: sudo vagrant provision --provision-with=k3s-wait-for-node
run: vagrant provision --provision-with=k3s-wait-for-node
- name: "⏳ CoreDNS"
run: sudo vagrant provision --provision-with=k3s-wait-for-coredns
run: vagrant provision --provision-with=k3s-wait-for-coredns
- name: "⏳ Local Storage"
run: sudo vagrant provision --provision-with=k3s-wait-for-local-storage
run: vagrant provision --provision-with=k3s-wait-for-local-storage
continue-on-error: true
- name: "⏳ Metrics Server"
run: sudo vagrant provision --provision-with=k3s-wait-for-metrics-server
run: vagrant provision --provision-with=k3s-wait-for-metrics-server
continue-on-error: true
- name: "⏳ Traefik"
run: sudo vagrant provision --provision-with=k3s-wait-for-traefik
run: vagrant provision --provision-with=k3s-wait-for-traefik
continue-on-error: true
- name: "k3s-status"
run: sudo vagrant provision --provision-with=k3s-status
run: vagrant provision --provision-with=k3s-status
- name: "k3s-procps"
run: sudo vagrant provision --provision-with=k3s-procps
run: vagrant provision --provision-with=k3s-procps
- name: Cleanup VM
run: sudo vagrant destroy -f
run: vagrant destroy -f
- name: On Failure, launch debug session
uses: lhotari/action-upterm@v1
if: ${{ failure() }}
with:
## If no one connects after 5 minutes, shut down server.
wait-timeout-minutes: 5
- name: Copy out vagrant boxes for cache
run: |
sudo mv -f /root/.vagrant.d/boxes /tmp/boxes
sudo chmod -R 777 /tmp/boxes
wait-timeout-minutes: 5
8 changes: 4 additions & 4 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ env:
jobs:
build:
uses: ./.github/workflows/build-k3s.yaml
test:
itest:
needs: build
name: Integration Tests
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
Expand All @@ -43,13 +43,13 @@ jobs:
max-parallel: 3
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Go
uses: ./.github/actions/setup-go
- name: "Download k3s binary"
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: k3s
path: ./dist/artifacts
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/nightly-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,15 @@ jobs:
INSTALL_K3S_CHANNEL: ${{ matrix.channel }}
steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4
with: {fetch-depth: 1}
- name: Set up vagrant and libvirt
uses: ./.github/actions/vagrant-setup
# Workaround for https://github.com/actions/cache/issues/1319
- name: Move vagrant cache to /root
run: |
mkdir -p /tmp/boxes
sudo rm -rf /root/.vagrant.d/boxes
sudo mv -f /tmp/boxes /root/.vagrant.d
- name: "Vagrant Cache"
uses: actions/cache@v4
with:
path: |
/tmp/boxes
~/.vagrant.d/boxes
key: vagrant-box-${{ matrix.vm }}
id: vagrant-cache
- name: "Vagrant Plugin(s)"
Expand All @@ -62,8 +56,4 @@ jobs:
- name: "k3s-status"
run: vagrant provision --provision-with=k3s-status
- name: "k3s-procps"
run: vagrant provision --provision-with=k3s-procps
- name: Copy out vagrant boxes for cache
run: |
sudo mv -f /root/.vagrant.d/boxes /tmp/boxes
sudo chmod -R 777 /tmp/boxes
run: vagrant provision --provision-with=k3s-procps
Loading
Loading