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

EVEREST-1558 Add PITR UI E2E test #808

Merged
merged 11 commits into from
Nov 7, 2024
179 changes: 95 additions & 84 deletions ui/apps/everest/.e2e/release/demand-backup.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ test.describe.configure({ retries: 0 });
test.describe(
'Demand backup',
{
// Create cluster, add data, create backup, destroy data and do restore
tag: '@release',
},
() => {
Expand Down Expand Up @@ -108,7 +107,7 @@ test.describe.configure({ retries: 0 });
}
});

test(`Cluster creation with ${db} and size ${size}`, async ({
test(`Cluster creation [${db} size ${size}]`, async ({
page,
request,
}) => {
Expand All @@ -118,94 +117,106 @@ test.describe.configure({ retries: 0 });
await page.getByTestId('toggle-button-group-input-db-type').waitFor();
await page.getByTestId('select-input-db-version').waitFor();

// basic info
await populateBasicInformation(
page,
db,
storageClasses[0],
clusterName
);
await moveForward(page);

// resources
await page
.getByRole('button')
.getByText(size + ' node')
.click();
await expect(page.getByText('Nº nodes: ' + size)).toBeVisible();
await populateResources(page, 0.6, 1, 1, size);
await moveForward(page);

// backups
await moveForward(page);

// advanced
await populateAdvancedConfig(page, db, '', true, '');
await moveForward(page);

// monitoring modal form
await populateMonitoringModalForm(
page,
monitoringName,
namespace,
MONITORING_URL,
MONITORING_USER,
MONITORING_PASSWORD
);
await page.getByTestId('switch-input-monitoring').click();
await expect(
page.getByTestId('text-input-monitoring-instance')
).toHaveValue(monitoringName);
await submitWizard(page);
await test.step('Populate basic information', async () => {
await populateBasicInformation(
page,
db,
storageClasses[0],
clusterName
);
await moveForward(page);
});

await test.step('Populate resources', async () => {
await page
.getByRole('button')
.getByText(size + ' node')
.click();
await expect(page.getByText('Nº nodes: ' + size)).toBeVisible();
await populateResources(page, 0.6, 1, 1, size);
await moveForward(page);
});

await test.step('Populate backups', async () => {
await moveForward(page);
});

await test.step('Populate advanced db config', async () => {
await populateAdvancedConfig(page, db, '', true, '');
await moveForward(page);
});

await test.step('Populate monitoring', async () => {
await populateMonitoringModalForm(
page,
monitoringName,
namespace,
MONITORING_URL,
MONITORING_USER,
MONITORING_PASSWORD
);
await page.getByTestId('switch-input-monitoring').click();
await expect(
page.getByTestId('text-input-monitoring-instance')
).toHaveValue(monitoringName);
});

await expect(
page.getByText('Awesome! Your database is being created!')
).toBeVisible();
await test.step('Submit wizard', async () => {
await submitWizard(page);

// go to db list and check status
await page.goto('/databases');
await waitForStatus(page, clusterName, 'Initializing', 15000);
await waitForStatus(page, clusterName, 'Up', 600000);
await expect(
page.getByText('Awesome! Your database is being created!')
).toBeVisible();
});

const response = await request.get(
`/v1/namespaces/${namespace}/database-clusters`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
// go to db list and check status
await test.step('Check db list and status', async () => {
await page.goto('/databases');
await waitForStatus(page, clusterName, 'Initializing', 15000);
await waitForStatus(page, clusterName, 'Up', 600000);
});

await test.step('Check db cluster k8s object options', async () => {
const response = await request.get(
`/v1/namespaces/${namespace}/database-clusters`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);

await checkError(response);
await checkError(response);

// TODO: replace with correct payload typings from GET DB Clusters
const { items: clusters } = await response.json();
// TODO: replace with correct payload typings from GET DB Clusters
const { items: clusters } = await response.json();

const addedCluster = clusters.find(
(cluster) => cluster.metadata.name === clusterName
);
const addedCluster = clusters.find(
(cluster) => cluster.metadata.name === clusterName
);

expect(addedCluster).not.toBeUndefined();
expect(addedCluster?.spec.engine.type).toBe(db);
expect(addedCluster?.spec.engine.replicas).toBe(size);
expect(['600m', '0.6']).toContain(
addedCluster?.spec.engine.resources?.cpu.toString()
);
expect(addedCluster?.spec.engine.resources?.memory.toString()).toBe(
'1G'
);
expect(addedCluster?.spec.engine.storage.size.toString()).toBe('1Gi');
expect(addedCluster?.spec.proxy.expose.type).toBe('internal');
expect(addedCluster?.spec.proxy.replicas).toBe(size);
expect(addedCluster).not.toBeUndefined();
expect(addedCluster?.spec.engine.type).toBe(db);
expect(addedCluster?.spec.engine.replicas).toBe(size);
expect(['600m', '0.6']).toContain(
addedCluster?.spec.engine.resources?.cpu.toString()
);
expect(addedCluster?.spec.engine.resources?.memory.toString()).toBe(
'1G'
);
expect(addedCluster?.spec.engine.storage.size.toString()).toBe('1Gi');
expect(addedCluster?.spec.proxy.expose.type).toBe('internal');
if (db != 'psmdb') {
expect(addedCluster?.spec.proxy.replicas).toBe(size);
}
});
});

test(`Add data with ${db} and size ${size}`, async () => {
test(`Add data [${db} size ${size}]`, async () => {
await prepareTestDB(clusterName, namespace);
});

test(`Create demand backup with ${db} and size ${size}`, async ({
page,
}) => {
test(`Create demand backup [${db} size ${size}]`, async ({ page }) => {
await gotoDbClusterBackups(page, clusterName);
await clickOnDemandBackup(page);
await page.getByTestId('text-input-name').fill(baseBackupName + '-1');
Expand All @@ -218,11 +229,11 @@ test.describe.configure({ retries: 0 });
await waitForStatus(page, baseBackupName + '-1', 'Succeeded', 240000);
});

test(`Delete data with ${db} and size ${size}`, async () => {
test(`Delete data [${db} size ${size}]`, async () => {
await dropTestDB(clusterName, namespace);
});

test(`Restore cluster with ${db} and size ${size}`, async ({ page }) => {
test(`Restore cluster [${db} size ${size}]`, async ({ page }) => {
await gotoDbClusterBackups(page, clusterName);
await findRowAndClickActions(
page,
Expand All @@ -244,7 +255,7 @@ test.describe.configure({ retries: 0 });
await waitForStatus(page, baseBackupName + '-1', 'Succeeded', 120000);
});

test(`Check data after restore with ${db} and size ${size}`, async () => {
test(`Check data after restore [${db} size ${size}]`, async () => {
const result = await queryTestDB(clusterName, namespace);
switch (db) {
case 'pxc':
Expand All @@ -259,23 +270,23 @@ test.describe.configure({ retries: 0 });
}
});

test(`Delete restore with ${db} and size ${size}`, async ({ page }) => {
test(`Delete restore [${db} size ${size}]`, async ({ page }) => {
await gotoDbClusterRestores(page, clusterName);
await findRowAndClickActions(page, baseBackupName + '-1', 'Delete');
await expect(page.getByLabel('Delete restore')).toBeVisible();
await page.getByTestId('confirm-dialog-delete').click();
await waitForDelete(page, baseBackupName + '-1', 15000);
});

test(`Delete backup with ${db} and size ${size}`, async ({ page }) => {
test(`Delete backup [${db} size ${size}]`, async ({ page }) => {
await gotoDbClusterBackups(page, clusterName);
await findRowAndClickActions(page, baseBackupName + '-1', 'Delete');
await expect(page.getByLabel('Delete backup')).toBeVisible();
await page.getByTestId('form-dialog-delete').click();
await waitForDelete(page, baseBackupName + '-1', 30000);
});

test(`Delete cluster with ${db} and size ${size}`, async ({ page }) => {
test(`Delete cluster [${db} size ${size}]`, async ({ page }) => {
await deleteDbCluster(page, clusterName);
await waitForStatus(page, clusterName, 'Deleting', 15000);
await waitForDelete(page, clusterName, 120000);
Expand Down
Loading
Loading