Repository navigation
STOR-2991: VolumeGroupSnapshots UI #17527
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
Open
dfajmon
wants to merge
2
commits into
openshift:main
Choose a base branch
from
dfajmon:volume-group-snapshot
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
frontend/e2e/tests/console/storage/volume-group-snapshot.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| import { test, expect } from '../../../fixtures'; | ||
| import { ListPage } from '../../../pages/list-page'; | ||
| import { ModalPage } from '../../../pages/modal-page'; | ||
| import { | ||
| findGroupSnapshotCapableStorageClass, | ||
| getVGSFixtures, | ||
| isGroupSnapshotApiAvailable, | ||
| } from '../../../mocks/storage'; | ||
|
|
||
| const VALIDATION_ERROR = | ||
| 'Selected PVCs have different storage provisioners. All PVCs must have StorageClasses with the same provisioner.'; | ||
|
|
||
| test.describe('VolumeGroupSnapshot Tests', { tag: ['@admin', '@storage'] }, () => { | ||
| test('creates, lists, and deletes a VolumeGroupSnapshot from a label selector', async ({ | ||
| page, | ||
| k8sClient, | ||
| cleanup, | ||
| }) => { | ||
| // Group-snapshot support depends on a CSI driver/snapshot-controller with the | ||
| // CSIVolumeGroupSnapshot feature gate enabled, which isn't implied by the CRDs being | ||
| // installed or by any particular platform. Discover a StorageClass/VolumeGroupSnapshotClass | ||
| // pairing the cluster has actually been configured with, and skip otherwise. | ||
| const capable = await findGroupSnapshotCapableStorageClass(k8sClient); | ||
| test.skip( | ||
| !capable, | ||
| 'No StorageClass with a provisioner matching an existing VolumeGroupSnapshotClass was found', | ||
| ); | ||
| const { storageClassName, vgsClassName } = capable!; | ||
|
|
||
| const ns = `test-vgs-${Date.now()}`; | ||
| const fixtures = getVGSFixtures(`${Date.now()}`, storageClassName); | ||
| const { | ||
| TEST_PVC_A, | ||
| TEST_PVC_B, | ||
| PVC_SAME_PROVISIONER_A, | ||
| PVC_SAME_PROVISIONER_B, | ||
| getDeployment, | ||
| } = fixtures; | ||
| const vgsName = 'vgs-group-snapshot'; | ||
| const listPage = new ListPage(page); | ||
| const modal = new ModalPage(page); | ||
|
|
||
| await test.step('Set up namespace and PVCs', async () => { | ||
| await k8sClient.createNamespace(ns); | ||
| cleanup.trackNamespace(ns); | ||
| await k8sClient.createPVC(ns, { | ||
| ...PVC_SAME_PROVISIONER_A, | ||
| metadata: { ...PVC_SAME_PROVISIONER_A.metadata, namespace: ns }, | ||
| } as any); | ||
| await k8sClient.createPVC(ns, { | ||
| ...PVC_SAME_PROVISIONER_B, | ||
| metadata: { ...PVC_SAME_PROVISIONER_B.metadata, namespace: ns }, | ||
| } as any); | ||
| await k8sClient.createDeployment(ns, getDeployment(ns, [TEST_PVC_A, TEST_PVC_B]) as any); | ||
| }); | ||
|
|
||
| await test.step('Wait for both PVCs to be Bound', async () => { | ||
| for (const pvcName of [TEST_PVC_A, TEST_PVC_B]) { | ||
| await page.goto(`/k8s/ns/${ns}/persistentvolumeclaims`); | ||
| await listPage.waitForRows(); | ||
| await listPage.filterByName(pvcName); | ||
| const pvcRow = listPage.getCell(pvcName).locator('xpath=ancestor::tr'); | ||
| await expect(pvcRow.locator('[data-test="status-text"]')).toContainText('Bound', { | ||
| timeout: 120_000, | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| await test.step('Create VolumeGroupSnapshot from a label selector', async () => { | ||
| await page.goto(`/k8s/ns/${ns}/groupsnapshot.storage.k8s.io~v1~VolumeGroupSnapshot`); | ||
| await listPage.clickCreateButton(); | ||
| await page.getByTestId('snapshot-name').fill(vgsName); | ||
| await page.getByTestId('tags-input').fill('vgs-test=true'); | ||
| await page.getByTestId('tags-input').press('Enter'); | ||
| await page.getByTestId('snapshot-class-dropdown').click(); | ||
| await page.getByRole('option', { name: vgsClassName }).click(); | ||
| await page.locator('#save-changes').click(); | ||
| }); | ||
|
|
||
| await test.step('Verify VolumeGroupSnapshot details show the source PVCs', async () => { | ||
| await expect(page).toHaveURL( | ||
| new RegExp( | ||
| `groupsnapshot\\.storage\\.k8s\\.io~v1~VolumeGroupSnapshot/${vgsName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`, | ||
| ), | ||
| ); | ||
| await expect(page.getByTestId('page-heading')).toContainText(vgsName); | ||
| await expect( | ||
| page.getByTestId('resource-summary').locator('[data-test="status-text"]'), | ||
| ).toContainText('Ready', { timeout: 120_000 }); | ||
| await expect(page.getByTestId(TEST_PVC_A)).toBeVisible(); | ||
| await expect(page.getByTestId(TEST_PVC_B)).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Verify VolumeGroupSnapshot in list', async () => { | ||
| await page.goto(`/k8s/ns/${ns}/groupsnapshot.storage.k8s.io~v1~VolumeGroupSnapshot`); | ||
| await listPage.waitForRows(); | ||
| await expect(listPage.getCell(vgsName)).toBeVisible({ timeout: 30_000 }); | ||
| }); | ||
|
|
||
| await test.step('Delete VolumeGroupSnapshot', async () => { | ||
| await listPage.clickKebabAction(vgsName, 'Delete VolumeGroupSnapshot'); | ||
| await modal.waitForOpen(); | ||
| await expect(modal.getSubmitButton()).toBeEnabled({ timeout: 10_000 }); | ||
| await modal.submit(); | ||
| await modal.waitForClosed(); | ||
| await expect(listPage.getCell(vgsName)).not.toBeAttached({ timeout: 90_000 }); | ||
| }); | ||
| }); | ||
|
|
||
| test('blocks VolumeGroupSnapshot creation when matched PVCs have different provisioners', async ({ | ||
| page, | ||
| k8sClient, | ||
| cleanup, | ||
| }) => { | ||
| // The create form watches VolumeGroupSnapshotClass; if the CRDs aren't installed that | ||
| // watch errors and the error takes priority over the mismatch message this test checks | ||
| // for. This test otherwise doesn't need a working snapshot-capable driver - just the API. | ||
| test.skip( | ||
| !(await isGroupSnapshotApiAvailable(k8sClient)), | ||
| 'groupsnapshot.storage.k8s.io v1 CRDs are not installed on this cluster', | ||
| ); | ||
|
|
||
| const ns = `test-vgs-mixed-${Date.now()}`; | ||
| // This test only needs PVCs that declare different provisioners; it never creates a | ||
| // VolumeGroupSnapshot, so it doesn't depend on any real StorageClass/platform - both | ||
| // PVCs use throwaway StorageClasses with distinct fake provisioners. | ||
| const fixtures = getVGSFixtures(`${Date.now()}`, 'unused'); | ||
| const { | ||
| PVC_MIXED_FAKE_PROVISIONER_A, | ||
| PVC_MIXED_FAKE_PROVISIONER_B, | ||
| FAKE_STORAGE_CLASS_A, | ||
| FAKE_STORAGE_CLASS_B, | ||
| } = fixtures; | ||
|
|
||
| await test.step('Set up namespace and mismatched-provisioner PVCs', async () => { | ||
| await k8sClient.createNamespace(ns); | ||
| cleanup.trackNamespace(ns); | ||
| for (const fakeStorageClass of [FAKE_STORAGE_CLASS_A, FAKE_STORAGE_CLASS_B]) { | ||
| await k8sClient.createClusterCustomResource( | ||
| 'storage.k8s.io', | ||
| 'v1', | ||
| 'storageclasses', | ||
| fakeStorageClass as any, | ||
| ); | ||
| cleanup.trackClusterCustomResource( | ||
| fakeStorageClass.metadata.name, | ||
| 'storage.k8s.io', | ||
| 'v1', | ||
| 'storageclasses', | ||
| ); | ||
| } | ||
| await k8sClient.createPVC(ns, { | ||
| ...PVC_MIXED_FAKE_PROVISIONER_A, | ||
| metadata: { ...PVC_MIXED_FAKE_PROVISIONER_A.metadata, namespace: ns }, | ||
| } as any); | ||
| await k8sClient.createPVC(ns, { | ||
| ...PVC_MIXED_FAKE_PROVISIONER_B, | ||
| metadata: { ...PVC_MIXED_FAKE_PROVISIONER_B.metadata, namespace: ns }, | ||
| } as any); | ||
| }); | ||
|
|
||
| await test.step('Select both PVCs via a label selector and verify validation blocks submit', async () => { | ||
| await page.goto(`/k8s/ns/${ns}/volumegroupsnapshots/~new/form`); | ||
|
dfajmon marked this conversation as resolved.
Resolved
|
||
| await page.getByTestId('snapshot-name').fill('vgs-mixed-provisioner-test'); | ||
| await page.getByTestId('tags-input').fill('vgs-mixed-test=true'); | ||
| await page.getByTestId('tags-input').press('Enter'); | ||
|
|
||
| await expect(page.getByText(VALIDATION_ERROR)).toBeVisible({ timeout: 30_000 }); | ||
| await expect(page.locator('#save-changes')).toBeDisabled(); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.