From 31e07667a394782d62b2d9b3347584464a626cb6 Mon Sep 17 00:00:00 2001 From: David Edler Date: Fri, 15 Nov 2024 13:06:13 +0100 Subject: [PATCH] chore(ci) simplify tests to not rely on workflow image download Signed-off-by: David Edler --- .github/workflows/coverage.yaml | 9 --------- .github/workflows/pr.yaml | 9 --------- .gitignore | 1 + tests/images.spec.ts | 13 +++++++------ tests/instances.spec.ts | 16 ++++++++-------- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 15915f5de1..8e72923b35 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -70,15 +70,6 @@ jobs: sudo lxc cluster enable local sudo lxc config set user.show_permissions=true - - name: Create and download custom images - shell: bash - run: | - set -x - curl -L -o ubuntu-minimal.qcow2 https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img & - sudo lxc launch ubuntu-minimal:22.04 my-instance - sudo lxc publish my-instance --alias my-custom-image --force - sudo lxc delete my-instance --force - - uses: actions/setup-node@v4 with: node-version: 20 diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 08d78b93c4..bca8a07db1 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -135,15 +135,6 @@ jobs: sudo lxc cluster enable local sudo lxc config set user.show_permissions=true - - name: Create and download custom images - shell: bash - run: | - set -x - curl -L -o ubuntu-minimal.qcow2 https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img & - sudo lxc launch ubuntu-minimal:22.04 my-instance - sudo lxc publish my-instance --alias my-custom-image --force - sudo lxc delete my-instance --force - - uses: actions/setup-node@v4 with: node-version: 20 diff --git a/.gitignore b/.gitignore index ef8cd0a369..38ec22f5b2 100644 --- a/.gitignore +++ b/.gitignore @@ -83,5 +83,6 @@ dist/ tests/screenshots tests/fixtures/image.tar.gz tests/fixtures/instance.tar.gz +playwright-image-*.qcow2 haproxy-local.cfg diff --git a/tests/images.spec.ts b/tests/images.spec.ts index a7609f377c..c01fb44440 100644 --- a/tests/images.spec.ts +++ b/tests/images.spec.ts @@ -11,23 +11,24 @@ import { gotoURL } from "./helpers/navigate"; test("search for custom image and create an instance from it", async ({ page, }) => { - test.skip( - Boolean(!process.env.CI), - "Skipping test locally for custom image creation", - ); const customInstance = randomInstanceName(); - const image = "my-custom-image"; // this is created in pr.yaml and coverage.yaml + const instance = randomInstanceName(); + await createInstance(page, instance); + const imageAlias = await createImageFromInstance(page, instance); + const imageName = await getImageNameFromAlias(page, imageAlias); + await deleteInstance(page, instance); await gotoURL(page, "/ui/"); await page.getByRole("link", { name: "Images", exact: true }).click(); await page.getByPlaceholder("Search").click(); - await page.getByPlaceholder("Search").fill(image); + await page.getByPlaceholder("Search").fill(imageAlias); await page.getByRole("button", { name: "Create instance" }).first().click(); await page.getByLabel("Instance name").fill(customInstance); await page.getByRole("button", { name: "Create", exact: true }).click(); await page.waitForSelector(`text=Created instance ${customInstance}.`); await deleteInstance(page, customInstance); + await deleteImage(page, imageName); }); test("Export and Upload an image", async ({ page }) => { diff --git a/tests/instances.spec.ts b/tests/instances.spec.ts index 1ea1556644..83cd6bf2fe 100644 --- a/tests/instances.spec.ts +++ b/tests/instances.spec.ts @@ -5,6 +5,7 @@ import { deleteInstance, editInstance, migrateInstanceRootStorage, + randomImageName, randomInstanceName, renameInstance, saveInstance, @@ -32,6 +33,7 @@ import { deleteImage, getImageNameFromAlias } from "./helpers/images"; import { createPool, deletePool, randomPoolName } from "./helpers/storagePool"; import { isServerClustered } from "./helpers/cluster"; import { gotoURL } from "./helpers/navigate"; +import { execSync } from "child_process"; let instance = randomInstanceName(); let vmInstance = randomInstanceName(); @@ -363,28 +365,26 @@ test("Create instance from external instance file", async ({ lxdVersion, }) => { test.skip( - lxdVersion === "5.0-edge", + lxdVersion !== "latest-edge", "External instance file conversion is only supported in newer versions of LXD", ); - test.skip( - Boolean(!process.env.CI), - "Skipping test locally for external instance file creation", - ); - test.skip( Boolean(process.env.DISABLE_VM_TESTS), "deactivated due to DISABLE_VM_TESTS environment variable", ); - const INSTANCE_FILE = "ubuntu-minimal.qcow2"; + const instanceFile = `${randomImageName()}.qcow2`; + execSync( + `curl -L -o ${instanceFile} https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img`, + ); await gotoURL(page, "/ui/"); await page.getByRole("button", { name: "Create instance" }).click(); await page.getByRole("button", { name: "Upload instance file" }).click(); await page.getByText("External format (.qcow2, .").click(); await page .getByRole("textbox", { name: "External format (.qcow2, ." }) - .setInputFiles(INSTANCE_FILE); + .setInputFiles(instanceFile); const instanceName = randomInstanceName(); await page.getByRole("textbox", { name: "Enter name" }).fill(instanceName); await page