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

Add workflow to run e2e tests from lxd-ui #14035

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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"
edlerd marked this conversation as resolved.
Show resolved Hide resolved
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
edlerd marked this conversation as resolved.
Show resolved Hide resolved
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

Copy link
Member

Choose a reason for hiding this comment

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

We should probably have a step here to cleanly stop LXD via lxd shutdown so we can be sure all coverage data is written before sending it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the lxd shutdown, but the coverage data for the ui is empty on this run on my fork. I set up the secrets over there and the e2e test suite completed just fine. Any idea what could be missing is welcome.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is an updated run on my fork. It still reports no coverage though.

Copy link
Member

@tomponline tomponline Nov 22, 2024

Choose a reason for hiding this comment

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

I wonder if the GOCOVERDIR env var isn't being set in your fork's run because of this line

GOCOVERDIR: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && '/home/runner/work/lxd/lxd/coverage' || '' }}

Because its that env var that indicates to the lxd binary where to store the coverage files.

Copy link
Contributor Author

@edlerd edlerd Nov 22, 2024

Choose a reason for hiding this comment

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

I wonder if the GOCOVERDIR env var isn't being set in your fork's run because of this line

Yeah, I saw that and explicitly set GOCOVERDIR for the ui step in recent versions of the workflow.

Copy link
Member

Choose a reason for hiding this comment

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

ah, ok, but was that env var present in the lxd build step too, as that is used by LXD's makefile to build lxd with go coverage support.

Copy link
Member

@tomponline tomponline Nov 22, 2024

Choose a reason for hiding this comment

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

then relies on that env var being set here:

https://github.com/canonical/lxd/blob/main/Makefile#L43

- name: Upload lxd-ui test artifacts
edlerd marked this conversation as resolved.
Show resolved Hide resolved
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
Loading