Skip to content

Commit

Permalink
✅ test: test for validate the physical cluster on akamai creation was…
Browse files Browse the repository at this point in the history
… added (#5)

* ⬆️ chore: update Node.js version to v22.12.0 in .nvmrc

* ♻️ feat: refactor physical cluster creation tests and introduce PhysicalCluster class

* ✅ feat: update physical cluster creation tests to support Akamai and refactor form handling

* ✅ test: test for create physical cluster on vultr was added

* ✅ test: continue to add the test for vultr

* ✅ feat: add Digital Ocean form handling and validation tests for physical cluster creation

* ✅ test: enable physical cluster creation tests for Digital Ocean and VULTR

* ♻️ refactor: update physical cluster creation tests to remove async and improve logging

* 🔧 chore: update dependencies to latest versions in package.json and package-lock.json

* 🔧 chore: update Dockerfile to use Bitnami Cypress image and optimize dependency installation

* 🔧 chore: update Dockerfile to use cypress/included image

* 🔧 chore: update Dockerfile to copy both package.json and package-lock.json

* 🔧 chore: downgrade Cypress version to 13.17.0 and update imports for physical cluster utilities
  • Loading branch information
futjesus authored Jan 23, 2025
1 parent ff97a8b commit 23db7a6
Show file tree
Hide file tree
Showing 14 changed files with 661 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.15.1
v20.18.1
10 changes: 2 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# Use the Cypress image as the base image
FROM cypress/included:13.17.0

# Set the working directory
WORKDIR /tests

RUN apt-get update
RUN apt install gh

# Copy necessary files into the container
COPY ./package.json .
COPY ./package*.json .
COPY ./cypress.config.ts .
COPY ./cypress ./cypress
COPY ./tsconfig.json .

# Install dependencies
RUN npm install
RUN npm ci
RUN find ./cypress -type f -name "*.sh" -exec chmod +x {} \;

# Define the entrypoint for running Cypress tests
ENTRYPOINT ["npx", "cypress", "run"]

10 changes: 5 additions & 5 deletions cypress/e2e/atlantis.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Test atlantis is working correctly", () => {
});

beforeEach(() => {
cy.wait(2000);
cy.wait(2_000);

cy.request({
method: "GET",
Expand Down Expand Up @@ -55,7 +55,7 @@ describe("Test atlantis is working correctly", () => {
const { gitToken, gitOwner, gitUsername } = camelcaseKeys(git_auth);

cy.visit("/");
cy.wait(2000);
cy.wait(2_000);

cy.get(".management-cluster").click();

Expand Down Expand Up @@ -85,7 +85,7 @@ describe("Test atlantis is working correctly", () => {
git_auth: git,
} = cluster;

cy.wait(20000);
cy.wait(20_000);

if (subdomain) {
cy.visit(`https://atlantis.${subdomain}.${domain}`);
Expand All @@ -97,7 +97,7 @@ describe("Test atlantis is working correctly", () => {
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");

cy.wait(50000);
cy.wait(50_000);

cy.task("applyAtlantisPlan", {
gitOwner,
Expand All @@ -106,7 +106,7 @@ describe("Test atlantis is working correctly", () => {
baseRepository,
}).then(({ apply }: any) => {
if (apply) {
cy.wait(50000);
cy.wait(50_000);
cy.reload();
cy.findAllByText(
new RegExp(`${git.git_owner}/gitops`, "i")
Expand Down
84 changes: 84 additions & 0 deletions cypress/e2e/create/physical-cluster.akamai.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import ms from "ms";

import { PhysicalCluster } from "../../utils/create-cluster";

const CLUSTER_NAME = Cypress.env("CLUSTER_NAME");
const cloudProvider = Cypress.env("CLOUD_PROVIDER");
const MAX_TIME_TO_WAIT = Cypress.env("MAX_TIME_TO_WAIT");
const isAkamai = cloudProvider === "akamai";

describe("Test to validate physical cluster creation on AKAMAI", () => {
const physicalCluster = new PhysicalCluster();

beforeEach(function () {
if (!isAkamai) {
cy.log("This test is only for AKAMAI");

this.skip();
}
});

beforeEach(() => {
const username = Cypress.env("USERNAME");
const password = Cypress.env("PASSWORD");

physicalCluster.login(username, password);
});

it("should create a physical cluster", () => {
physicalCluster.visitClusterPage();

physicalCluster.clickOnWorkloadClusterButton();

const region = physicalCluster.getRegion(cloudProvider);

region.then((region) => {
physicalCluster.filloutAkamaiForm({
name: CLUSTER_NAME,
region: new RegExp(region, "i"),
intanceSize: new RegExp("g6-standard-6", "i"),
});

physicalCluster.clickOnCreateCluster();

cy.wait(2_000);

cy.findByRole("heading", {
name: new RegExp(CLUSTER_NAME, "i"),
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");

cy.contains(/provisioning/i).should("exist");
});
});

it("should validate the cluster is provisioning", () => {
physicalCluster.visitClusterPage();

const provisioningButton =
physicalCluster.getClusterProvisioningStatusButton(CLUSTER_NAME);

provisioningButton.should("exist");

provisioningButton.within(() => {
cy.findByText(/provisioning/i, {
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");
});
});

it("should validate the cluster is provisioned", { retries: 3 }, () => {
physicalCluster.visitClusterPage();

const provisioningButton =
physicalCluster.getClusterProvisioningStatusButton(CLUSTER_NAME);

provisioningButton.should("exist");

provisioningButton.within(() => {
cy.findByText(/available/i, {
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");
});
});
});
99 changes: 49 additions & 50 deletions cypress/e2e/create/physical-cluster.aws.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import ms from "ms";

import { Account } from "../../../types/accouts";

import { fillOutForm } from "../../utils";
import { PhysicalCluster } from "../../utils/create-cluster";

const CLUSTER_NAME = Cypress.env("CLUSTER_NAME");
const isAWS = Cypress.env("CLOUD_PROVIDER") === "aws";
const MAX_TIME_TO_WAIT = Cypress.env("MAX_TIME_TO_WAIT");

describe("Test to validate physical cluster creation on AWS", () => {
const physicalCluster = new PhysicalCluster();

beforeEach(function () {
if (!isAWS) {
cy.log("This test is only for AWS");
Expand All @@ -21,83 +23,80 @@ describe("Test to validate physical cluster creation on AWS", () => {
const username = Cypress.env("USERNAME");
const password = Cypress.env("PASSWORD");

cy.login(username, password);
physicalCluster.login(username, password);
});

it("should create a physical cluster", () => {
cy.visit("/");
cy.findByRole("button", { name: /add workload cluster/i }).as("button");

cy.request("GET", "/api/proxy?url=%2Fcloud-account").then(
({ status, body }) => {
expect(status).to.eq(200);
const cloudAccounts = physicalCluster.getClodAccounts();
const region = physicalCluster.getRegion("aws");
const instanceSize = physicalCluster.getInstanceSize();

const { cloud_accounts: cloudAccounts } = body;
cy.wrap(cloudAccounts as Account[]).as("accounts");
}
);
region.then((region) => {
cloudAccounts.then((cloudAccounts: Account[]) => {
instanceSize.then((instanceSize) => {
expect(cloudAccounts).to.be.an("array");
expect(cloudAccounts).to.have.length.greaterThan(0);

cy.get("@accounts").then((accounts) => {
const cloudAccounts = accounts as unknown as Account[];
expect(cloudAccounts).to.be.an("array");
expect(cloudAccounts).to.have.length.greaterThan(0);
const defaultAccount = cloudAccounts.find(
(account) => account.name === "default"
);

const defaultAccount = cloudAccounts.find(
(account) => account.name === "default"
);
expect(defaultAccount).to.exist;

expect(defaultAccount).to.exist;
});
cy.get("@button").click();

cy.get("@button").click();
physicalCluster.filloutAWSForm({
name: CLUSTER_NAME,
region: new RegExp(region, "i"),
intanceSize: new RegExp(instanceSize, "i"),
// TODO: We need to find a way to get the AMI type from the UI
amiType: /al2_x86_64/i,
});

fillOutForm({
name: CLUSTER_NAME,
region: /us-east-1/i,
intanceSize: /t2.nano/i,
});
cy.findByRole("button", {
name: /create cluster/i,
}).click();

cy.findByRole("button", {
name: /create cluster/i,
}).click();
cy.wait(2_000);

cy.wait(2000);
cy.findByRole("heading", {
name: new RegExp(CLUSTER_NAME, "i"),
}).should("exist");

cy.findByRole("heading", { name: new RegExp(CLUSTER_NAME, "i") }).should(
"exist"
);
cy.contains("Provisioning").should("exist");
cy.contains(/provisioning/i).should("exist");
});
});
});
});

it("should validate the cluster is provisioning", () => {
cy.visit("/");
physicalCluster.visitClusterPage();

cy.goClusters();
const provisioningButton =
physicalCluster.getClusterProvisioningStatusButton(CLUSTER_NAME);

cy.findAllByRole("button", { name: new RegExp(CLUSTER_NAME, "i") })
.eq(0)
.as("clusterProvisioningButton");
provisioningButton.should("exist");

cy.get("@clusterProvisioningButton").should("exist");

cy.get("@clusterProvisioningButton").within(() => {
cy.findByText(/provisioning/i).should("exist");
provisioningButton.within(() => {
cy.findByText(/provisioning/i, {
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");
});
});

it("should validate the cluster is provisioned", { retries: 3 }, () => {
cy.visit("/");

cy.goClusters();
physicalCluster.visitClusterPage();

cy.findAllByRole("button", { name: new RegExp(CLUSTER_NAME, "i") })
.eq(0)
.as("clusterProvisionedButton");
const provisioningButton =
physicalCluster.getClusterProvisioningStatusButton(CLUSTER_NAME);

cy.get("@clusterProvisionedButton").should("exist");
provisioningButton.should("exist");

cy.get("@clusterProvisionedButton").within(() => {
cy.findByText(/provisioned/i, {
provisioningButton.within(() => {
cy.findByText(/available/i, {
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");
});
Expand Down
Loading

0 comments on commit 23db7a6

Please sign in to comment.