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

chore(test): tag k8s e2e tests #9781

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
"test:e2e:run": "xvfb-maybe --auto-servernum --server-args='-screen 0 1280x960x24' -- npx playwright test tests/playwright/src/specs/ --grep-invert @update-install",
"test:e2e:smoke": "npm run test:e2e:build && npm run test:e2e:smoke:run",
"test:e2e:smoke:run": "xvfb-maybe --auto-servernum --server-args='-screen 0 1280x960x24' -- npx playwright test tests/playwright/src/specs/ -g @smoke",
"test:e2e:k8s": "npm run test:e2e:build && npm run test:e2e:k8s:run",
"test:e2e:k8s:run": "xvfb-maybe --auto-servernum --server-args='-screen 0 1280x960x24' -- npx playwright test tests/playwright/src/specs/ -g @k8s_e2e",
"test:e2e:extension": "npm run test:e2e:build && npm run test:e2e:extension:run",
"test:e2e:extension:run": "xvfb-maybe --auto-servernum --server-args='-screen 0 1280x960x24' -- npx playwright test tests/playwright/src/specs/extension-installation.spec.ts",
"test:e2e:pw": "npm run test:e2e:build && npm run test:e2e:pw:run",
Expand Down
53 changes: 27 additions & 26 deletions tests/playwright/src/specs/deploy-to-kubernetes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const IMAGE_TAG: string = 'latest';
const CONTAINER_NAME: string = 'alpine-container';
const NAMESPACE: string = 'default';
const DEPLOYED_POD_NAME: string = `${CONTAINER_NAME} ${KIND_CONTAINER_NAME} ${NAMESPACE}`;
const CONTAINER_START_PARAMS: ContainerInteractiveParams = { attachTerminal: false };
const CONTAINER_START_PARAMS: ContainerInteractiveParams = {
attachTerminal: false,
};

const skipKindInstallation = process.env.SKIP_KIND_INSTALL ? process.env.SKIP_KIND_INSTALL : false;

Expand Down Expand Up @@ -74,31 +76,30 @@ test.skip(
'Tests suite should not run on Linux platform',
);

test.describe
.serial('Deploy a container to the Kind cluster', () => {
test('Pull an image and start a container', async ({ navigationBar }) => {
const imagesPage = await navigationBar.openImages();
const pullImagePage = await imagesPage.openPullImage();
await pullImagePage.pullImage(IMAGE_TO_PULL, IMAGE_TAG);
await playExpect.poll(async () => imagesPage.waitForImageExists(IMAGE_TO_PULL, 10000)).toBeTruthy();
const containersPage = await imagesPage.startContainerWithImage(
IMAGE_TO_PULL,
CONTAINER_NAME,
CONTAINER_START_PARAMS,
);
await playExpect.poll(async () => containersPage.containerExists(CONTAINER_NAME)).toBeTruthy();
const containerDetails = await containersPage.openContainersDetails(CONTAINER_NAME);
await playExpect(containerDetails.heading).toBeVisible();
await playExpect.poll(async () => containerDetails.getState()).toBe(ContainerState.Running);
});
test.describe.serial('Deploy a container to the Kind cluster', { tag: '@k8s_e2e' }, () => {
test('Pull an image and start a container', async ({ navigationBar }) => {
const imagesPage = await navigationBar.openImages();
const pullImagePage = await imagesPage.openPullImage();
await pullImagePage.pullImage(IMAGE_TO_PULL, IMAGE_TAG);
await playExpect.poll(async () => imagesPage.waitForImageExists(IMAGE_TO_PULL, 10000)).toBeTruthy();
const containersPage = await imagesPage.startContainerWithImage(
IMAGE_TO_PULL,
CONTAINER_NAME,
CONTAINER_START_PARAMS,
);
await playExpect.poll(async () => containersPage.containerExists(CONTAINER_NAME)).toBeTruthy();
const containerDetails = await containersPage.openContainersDetails(CONTAINER_NAME);
await playExpect(containerDetails.heading).toBeVisible();
await playExpect.poll(async () => containerDetails.getState()).toBe(ContainerState.Running);
});

test('Deploy the container ', async ({ page, navigationBar }) => {
const containerDetailsPage = new ContainerDetailsPage(page, CONTAINER_NAME);
await playExpect(containerDetailsPage.heading).toBeVisible();
const deployToKubernetesPage = await containerDetailsPage.openDeployToKubernetesPage();
await deployToKubernetesPage.deployPod(CONTAINER_NAME, { useKubernetesServices: true }, KUBERNETES_CONTEXT);
test('Deploy the container ', async ({ page, navigationBar }) => {
const containerDetailsPage = new ContainerDetailsPage(page, CONTAINER_NAME);
await playExpect(containerDetailsPage.heading).toBeVisible();
const deployToKubernetesPage = await containerDetailsPage.openDeployToKubernetesPage();
await deployToKubernetesPage.deployPod(CONTAINER_NAME, { useKubernetesServices: true }, KUBERNETES_CONTEXT);

const podsPage = await navigationBar.openPods();
await playExpect.poll(async () => podsPage.deployedPodExists(DEPLOYED_POD_NAME, 'kubernetes')).toBeTruthy();
});
const podsPage = await navigationBar.openPods();
await playExpect.poll(async () => podsPage.deployedPodExists(DEPLOYED_POD_NAME, 'kubernetes')).toBeTruthy();
});
});
133 changes: 66 additions & 67 deletions tests/playwright/src/specs/kind.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,84 +57,83 @@ test.afterAll(async ({ runner, page }) => {
}
});

test.describe
.serial('Kind End-to-End Tests', () => {
test.describe
.serial('Kind installation', () => {
test('Install Kind CLI', async ({ page, navigationBar }) => {
test.skip(!!skipKindInstallation, 'Skipping Kind installation');
const settingsBar = await navigationBar.openSettings();
await settingsBar.cliToolsTab.click();
test.describe.serial('Kind End-to-End Tests', { tag: '@k8s_e2e' }, () => {
test.describe
.serial('Kind installation', () => {
test('Install Kind CLI', async ({ page, navigationBar }) => {
test.skip(!!skipKindInstallation, 'Skipping Kind installation');
const settingsBar = await navigationBar.openSettings();
await settingsBar.cliToolsTab.click();

await ensureKindCliInstalled(page);
});

test('Kind extension lifecycle', async ({ navigationBar }) => {
const extensionsPage = await navigationBar.openExtensions();
const kindExtension = await extensionsPage.getInstalledExtension('Kind extension', EXTENSION_LABEL);
await playExpect
.poll(async () => await extensionsPage.extensionIsInstalled(EXTENSION_LABEL), { timeout: 10000 })
.toBeTruthy();
await playExpect(kindExtension.status).toHaveText('ACTIVE');
await kindExtension.disableExtension();
await navigationBar.openSettings();
await playExpect.poll(async () => resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeFalsy();
await navigationBar.openExtensions();
await kindExtension.enableExtension();
await navigationBar.openSettings();
await playExpect.poll(async () => resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeTruthy();
});
await ensureKindCliInstalled(page);
});
test.describe('Kind cluster operations', () => {
test.skip(
!!process.env.GITHUB_ACTIONS && process.env.RUNNER_OS === 'Linux',
'Tests suite should not run on Linux platform',
);
test('Create a Kind cluster', async ({ page }) => {
test.setTimeout(CLUSTER_CREATION_TIMEOUT);
await createKindCluster(page, CLUSTER_NAME, true, CLUSTER_CREATION_TIMEOUT);

test('Kind extension lifecycle', async ({ navigationBar }) => {
const extensionsPage = await navigationBar.openExtensions();
const kindExtension = await extensionsPage.getInstalledExtension('Kind extension', EXTENSION_LABEL);
await playExpect
.poll(async () => await extensionsPage.extensionIsInstalled(EXTENSION_LABEL), { timeout: 10000 })
.toBeTruthy();
await playExpect(kindExtension.status).toHaveText('ACTIVE');
await kindExtension.disableExtension();
await navigationBar.openSettings();
await playExpect.poll(async () => resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeFalsy();
await navigationBar.openExtensions();
await kindExtension.enableExtension();
await navigationBar.openSettings();
await playExpect.poll(async () => resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeTruthy();
});
});
test.describe('Kind cluster operations', () => {
test.skip(
!!process.env.GITHUB_ACTIONS && process.env.RUNNER_OS === 'Linux',
'Tests suite should not run on Linux platform',
);
test('Create a Kind cluster', async ({ page }) => {
test.setTimeout(CLUSTER_CREATION_TIMEOUT);
await createKindCluster(page, CLUSTER_NAME, true, CLUSTER_CREATION_TIMEOUT);
});

test('Check resources added with the Kind cluster', async ({ page, navigationBar }) => {
const containersPage = await navigationBar.openContainers();
await playExpect.poll(async () => containersPage.containerExists(KIND_CONTAINER_NAME)).toBeTruthy();
const containerDetailsPage = await containersPage.openContainersDetails(KIND_CONTAINER_NAME);
await playExpect.poll(async () => await containerDetailsPage.getState()).toEqual(ContainerState.Running);
test('Check resources added with the Kind cluster', async ({ page, navigationBar }) => {
const containersPage = await navigationBar.openContainers();
await playExpect.poll(async () => containersPage.containerExists(KIND_CONTAINER_NAME)).toBeTruthy();
const containerDetailsPage = await containersPage.openContainersDetails(KIND_CONTAINER_NAME);
await playExpect.poll(async () => await containerDetailsPage.getState()).toEqual(ContainerState.Running);

const volumesPage = new VolumesPage(page);
const volumeName = await getVolumeNameForContainer(page, KIND_CONTAINER_NAME);
if (!volumeName) {
throw new Error(`Volume name for container "${KIND_CONTAINER_NAME}" is not defined.`);
}
const volumeDetailsPage = await volumesPage.openVolumeDetails(volumeName);
await playExpect.poll(async () => await volumeDetailsPage.isUsed()).toBeTruthy();
});
const volumesPage = new VolumesPage(page);
const volumeName = await getVolumeNameForContainer(page, KIND_CONTAINER_NAME);
if (!volumeName) {
throw new Error(`Volume name for container "${KIND_CONTAINER_NAME}" is not defined.`);
}
const volumeDetailsPage = await volumesPage.openVolumeDetails(volumeName);
await playExpect.poll(async () => await volumeDetailsPage.isUsed()).toBeTruthy();
});

test('Kind cluster operations - STOP', async ({ navigationBar }) => {
await navigationBar.openSettings();
await playExpect(kindResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Running);
await kindResourceCard.performConnectionAction(ResourceElementActions.Stop);
await playExpect(kindResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Off, {
timeout: 50000,
});
test('Kind cluster operations - STOP', async ({ navigationBar }) => {
await navigationBar.openSettings();
await playExpect(kindResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Running);
await kindResourceCard.performConnectionAction(ResourceElementActions.Stop);
await playExpect(kindResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Off, {
timeout: 50000,
});
});

test('Kind cluster operations - START', async () => {
await kindResourceCard.performConnectionAction(ResourceElementActions.Start);
await playExpect(kindResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Running, {
timeout: 50000,
});
test('Kind cluster operations - START', async () => {
await kindResourceCard.performConnectionAction(ResourceElementActions.Start);
await playExpect(kindResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Running, {
timeout: 50000,
});
});

test('Kind cluster operatioms - RESTART', async () => {
await kindResourceCard.performConnectionAction(ResourceElementActions.Restart);
await playExpect(kindResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Running, {
timeout: 50000,
});
test('Kind cluster operatioms - RESTART', async () => {
await kindResourceCard.performConnectionAction(ResourceElementActions.Restart);
await playExpect(kindResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Running, {
timeout: 50000,
});
});

test('Kind cluster operations - DELETE', async ({ page }) => {
await deleteKindCluster(page, KIND_CONTAINER_NAME, CLUSTER_NAME);
});
test('Kind cluster operations - DELETE', async ({ page }) => {
await deleteKindCluster(page, KIND_CONTAINER_NAME, CLUSTER_NAME);
});
});
});
143 changes: 75 additions & 68 deletions tests/playwright/src/specs/kubernetes-context-smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,78 +41,85 @@ test.beforeAll(async ({ runner, welcomePage }) => {
});

test.afterAll(async ({ runner }) => {
test.setTimeout(120000);
test.setTimeout(120_000);
await runner.close();
});

test.describe
.serial('Verification of kube context management @smoke', () => {
test('Load custom kubeconfig in Preferences', async ({ navigationBar }) => {
// open preferences page
const settingsBar = await navigationBar.openSettings();
await settingsBar.expandPreferencesTab();
const preferencesPage = await settingsBar.openTabPage(PreferencesPage);
await playExpect(preferencesPage.heading).toBeVisible();

const kubeConfigPathDst = path.resolve(__dirname, '..', '..', 'resources', 'kube-config');
await preferencesPage.selectKubeFile(kubeConfigPathDst);
});

test('Can load kube contexts in Kubernetes page', async ({ navigationBar }) => {
const settingsBar = await navigationBar.openSettings();
const kubePage = await settingsBar.openTabPage(KubeContextPage);
await playExpect(kubePage.heading).toBeVisible();

await playExpect.poll(async () => await kubePage.pageIsEmpty(), { timeout: 10000 }).toBeFalsy();
for (const context of testContexts) {
const row = await kubePage.getContextRowByName(context);
await playExpect(row).toBeVisible();
playExpect(await kubePage.getContextName(context)).toBe(context);
playExpect(await kubePage.getContextCluster(context)).toBe(context + '-cluster');
playExpect(await kubePage.getContextServer(context)).toBe(context + '-server');
playExpect(await kubePage.getContextUser(context)).toBe(context + '-user');

if (context === 'context-1') {
// check if the context is default
await playExpect.poll(async () => await kubePage.isContextDefault(context), { timeout: 10000 }).toBeTruthy();
await playExpect(await kubePage.getSetCurrentContextButton(context)).not.toBeVisible();
playExpect(await kubePage.getContextNamespace(context)).toBe(context + '-namespace');
} else {
await playExpect(await kubePage.getSetCurrentContextButton(context)).toBeVisible();
}
}
});

test('Can switch default context', async ({ navigationBar }) => {
const settingsBar = await navigationBar.openSettings();
const kubePage = await settingsBar.openTabPage(KubeContextPage);
await playExpect(kubePage.heading).toBeVisible();

await kubePage.setDefaultContext('context-2');
// check that switch worked - current context banner should be visible
playExpect(await kubePage.isContextDefault('context-1')).toBeFalsy();
await playExpect.poll(async () => await kubePage.isContextDefault('context-2'), { timeout: 10000 }).toBeTruthy();
playExpect(await kubePage.isContextDefault('context-3')).toBeFalsy();
});

test('Can delete all contexts from Kubernetes Contexts page', async ({ navigationBar }) => {
const settingsBar = await navigationBar.openSettings();
const kubePage = await settingsBar.openTabPage(KubeContextPage);
await playExpect(kubePage.heading).toBeVisible();

for (const context of testContexts) {
// confirmation only pops up if the context is default
if (await kubePage.isContextDefault(context)) {
await kubePage.deleteContext(context);
} else {
await kubePage.deleteContext(context, false);
}
test.describe.serial('Verification of kube context management', { tag: ['@k8s_e2e', '@smoke'] }, () => {
test('Load custom kubeconfig in Preferences', async ({ navigationBar }) => {
// open preferences page
const settingsBar = await navigationBar.openSettings();
await settingsBar.expandPreferencesTab();
const preferencesPage = await settingsBar.openTabPage(PreferencesPage);
await playExpect(preferencesPage.heading).toBeVisible();

const kubeConfigPathDst = path.resolve(__dirname, '..', '..', 'resources', 'kube-config');
await preferencesPage.selectKubeFile(kubeConfigPathDst);
});

test('Can load kube contexts in Kubernetes page', async ({ navigationBar }) => {
const settingsBar = await navigationBar.openSettings();
const kubePage = await settingsBar.openTabPage(KubeContextPage);
await playExpect(kubePage.heading).toBeVisible();

await playExpect.poll(async () => await kubePage.pageIsEmpty(), { timeout: 10_000 }).toBeFalsy();
for (const context of testContexts) {
const row = await kubePage.getContextRowByName(context);
await playExpect(row).toBeVisible();
playExpect(await kubePage.getContextName(context)).toBe(context);
playExpect(await kubePage.getContextCluster(context)).toBe(context + '-cluster');
playExpect(await kubePage.getContextServer(context)).toBe(context + '-server');
playExpect(await kubePage.getContextUser(context)).toBe(context + '-user');

if (context === 'context-1') {
// check if the context is default
await playExpect
.poll(async () => await kubePage.isContextDefault(context), {
timeout: 10000,
})
.toBeTruthy();
await playExpect(await kubePage.getSetCurrentContextButton(context)).not.toBeVisible();
playExpect(await kubePage.getContextNamespace(context)).toBe(context + '-namespace');
} else {
await playExpect(await kubePage.getSetCurrentContextButton(context)).toBeVisible();
}
}
});

for (const context of testContexts) {
await playExpect(await kubePage.getContextRowByName(context)).not.toBeVisible();
test('Can switch default context', async ({ navigationBar }) => {
const settingsBar = await navigationBar.openSettings();
const kubePage = await settingsBar.openTabPage(KubeContextPage);
await playExpect(kubePage.heading).toBeVisible();

await kubePage.setDefaultContext('context-2');
// check that switch worked - current context banner should be visible
playExpect(await kubePage.isContextDefault('context-1')).toBeFalsy();
await playExpect
.poll(async () => await kubePage.isContextDefault('context-2'), {
timeout: 10_000,
})
.toBeTruthy();
playExpect(await kubePage.isContextDefault('context-3')).toBeFalsy();
});

test('Can delete all contexts from Kubernetes Contexts page', async ({ navigationBar }) => {
const settingsBar = await navigationBar.openSettings();
const kubePage = await settingsBar.openTabPage(KubeContextPage);
await playExpect(kubePage.heading).toBeVisible();

for (const context of testContexts) {
// confirmation only pops up if the context is default
if (await kubePage.isContextDefault(context)) {
await kubePage.deleteContext(context);
} else {
await kubePage.deleteContext(context, false);
}
// check that the page is empty
await playExpect.poll(async () => await kubePage.pageIsEmpty(), { timeout: 10000 }).toBeTruthy();
});
}

for (const context of testContexts) {
await playExpect(await kubePage.getContextRowByName(context)).not.toBeVisible({ timeout: 10_000 });
}
// check that the page is empty
await playExpect.poll(async () => await kubePage.pageIsEmpty(), { timeout: 10_000 }).toBeTruthy();
});
});
Loading