Skip to content

Commit

Permalink
chore(ci) simplify tests to not rely on workflow image download (#985)
Browse files Browse the repository at this point in the history
## Done

- chore(ci) simplify tests to not rely on workflow image download

Related to canonical/lxd#14035
  • Loading branch information
edlerd authored Nov 15, 2024
2 parents 41cbfe9 + 31e0766 commit fe4fd9f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 32 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ dist/
tests/screenshots
tests/fixtures/image.tar.gz
tests/fixtures/instance.tar.gz
playwright-image-*.qcow2

haproxy-local.cfg
13 changes: 7 additions & 6 deletions tests/images.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
16 changes: 8 additions & 8 deletions tests/instances.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
deleteInstance,
editInstance,
migrateInstanceRootStorage,
randomImageName,
randomInstanceName,
renameInstance,
saveInstance,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fe4fd9f

Please sign in to comment.