Skip to content

Commit

Permalink
chore(ci) add workflow to run e2e tests from lxd-ui
Browse files Browse the repository at this point in the history
Signed-off-by: David Edler <[email protected]>
  • Loading branch information
edlerd committed Nov 22, 2024
1 parent 3c2809b commit eae5054
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .github/actions/install-lxd-runtimedeps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,3 @@ runs:
xz-utils \
zfsutils-linux
# reclaim some space
sudo apt-get clean
155 changes: 154 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ jobs:
tics:
name: Tiobe TICS
runs-on: ubuntu-22.04
needs: system-tests
needs: [system-tests, ui-e2e-tests]
env:
CGO_CFLAGS: "-I/home/runner/go/bin/dqlite/include/"
CGO_LDFLAGS: "-L/home/runner/go/bin/dqlite/libs/"
Expand Down Expand Up @@ -445,6 +445,159 @@ jobs:
name: lxd-clients-${{ runner.os }}
path: bin/

ui-e2e-tests:
name: UI e2e tests
runs-on: ubuntu-latest
needs: [code-tests, documentation]
if: ${{ github.repository == 'canonical/lxd' && github.event_name == 'push' }}
env:
GOCOVERDIR: "/home/runner/work/lxd/lxd/coverage"
LD_LIBRARY_PATH: "/home/runner/go/bin/dqlite/libs/"
LXD_DIR: "/var/lib/lxd"
LXD_OIDC_CLIENT_ID: ${{ secrets.LXD_UI_OIDC_CLIENT_ID }}
LXD_OIDC_ISSUER: ${{ secrets.LXD_UI_OIDC_ISSUER }}
LXD_OIDC_AUDIENCE: ${{ secrets.LXD_UI_OIDC_AUDIENCE }}
LXD_OIDC_USER: ${{ secrets.LXD_UI_OIDC_TEST_USER }}
LXD_OIDC_PASSWORD: ${{ secrets.LXD_UI_OIDC_TEST_PASSWORD }}
LXD_OIDC_GROUPS_CLAIM: "lxd-idp-groups"
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Tune disk performance
uses: ./.github/actions/tune-disk-performance

- name: Install runtime dependencies
uses: ./.github/actions/install-lxd-runtimedeps

- name: Download minio/mc to add to system test dependencies
uses: ./.github/actions/download-minio

- name: Download system test dependencies
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: system-test-deps
merge-multiple: true
path: /home/runner/go/bin

- name: Set exec perms on LXD binaries
run: |
set -eux
ls -lR /home/runner/go/bin/
chmod uog+x /home/runner/go/bin/*
- name: Download docs (for the objects.inv.txt file to be available for the e2e tests)
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: documentation
merge-multiple: true
path: doc/_build

- name: Make GOCOVERDIR
run: |
set -eux
mkdir -p "${GOCOVERDIR}"
if: env.GOCOVERDIR != ''

- name: Run LXD daemon
run: |
set -eux
echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid
export LXD_DOCUMENTATION="/home/runner/work/lxd/lxd/doc/_build/"
export PATH="/home/runner/go/bin:$PATH"
sudo rm -rf /var/lib/lxd
sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,LD_LIBRARY_PATH,LXD_DOCUMENTATION $(go env GOPATH)/bin/lxd --group sudo &
- name: Checkout LXD-UI
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: 'canonical/lxd-ui'
ref: main
path: lxd-ui

- name: Install Dotrun
run: sudo pip3 install dotrun

- name: Install LXD-UI dependencies
run: |
set -eux
sudo chmod 0777 ./lxd-ui
cd lxd-ui
dotrun install
- name: Run LXD-UI
env:
ENVIRONMENT: devel
PORT: 8407
LXD_UI_BACKEND_IP: 172.17.0.1
run: |
set -eux
cd lxd-ui
dotrun &
curl --head --fail --retry-delay 2 --retry 100 --retry-connrefused --insecure https://localhost:${{ env.PORT }}
- name: Setup LXD
shell: bash
run: |
set -eux
export PATH="/home/runner/go/bin:$PATH"
sudo -E LXD_DIR=/var/lib/lxd lxc storage create default zfs
sudo -E LXD_DIR=/var/lib/lxd lxc profile device add default root disk path=/ pool=default
sudo -E LXD_DIR=/var/lib/lxd lxc network create local-network
sudo -E LXD_DIR=/var/lib/lxd lxc profile device add default eth0 nic network=local-network
sudo -E LXD_DIR=/var/lib/lxd lxc config set core.https_address "[::]:8443"
sudo -E LXD_DIR=/var/lib/lxd lxc config set cluster.https_address "127.0.0.1"
sudo -E LXD_DIR=/var/lib/lxd lxc cluster enable local
sudo -E LXD_DIR=/var/lib/lxd lxc config set user.show_permissions=true
sudo -E LXD_DIR=/var/lib/lxd lxc config trust add lxd-ui/keys/lxd-ui.crt
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Playwright Browsers
run: |
set -eux
cd lxd-ui
npx playwright install --with-deps chromium
- name: Setup for LXD-UI tests
shell: bash
run: |
set -eux
sudo -E LXD_DIR=/var/lib/lxd PATH=/home/runner/go/bin:$PATH ./lxd-ui/tests/scripts/setup_test
- name: Run Playwright tests
run: |
set -eux
cd lxd-ui
sudo chown $USER -R /home/runner/.config
sudo chown $USER /var/lib/lxd/unix.socket
CI=true DISABLE_VM_TESTS=true LXD_DIR=/var/lib/lxd PATH=/home/runner/go/bin:$PATH npx playwright test --project chromium:lxd-latest-edge
#npx playwright test --project chromium:lxd-5.21-edge
#npx playwright test --project lxd-5.0-edge
- name: Upload lxd-ui test artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: always()
with:
name: lxd-ui-test-report
path: lxd-ui/blob-report
retention-days: 14

- name: Shutdown LXD daemon
run: |
set -eux
export PATH="/home/runner/go/bin:$PATH"
sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,LD_LIBRARY_PATH $(go env GOPATH)/bin/lxd shutdown
- name: Upload coverage data
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: coverage-ui-e2e-tests
path: ${{env.GOCOVERDIR}}
if: env.GOCOVERDIR != ''

documentation:
name: Documentation
runs-on: ubuntu-latest
Expand Down

0 comments on commit eae5054

Please sign in to comment.