generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 131
Update cypress tests for WLM dashboard #1809
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
Lindsay-00
wants to merge
6
commits into
opensearch-project:main
Choose a base branch
from
Lindsay-00:wlm_tests
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 2 commits
Commits
Show all changes
6 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
80 changes: 80 additions & 0 deletions
80
cypress/integration/plugins/query-insights-dashboards/6_WLM_main.cy.js
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,80 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| describe('WLM Main Page', () => { | ||
| beforeEach(() => { | ||
| cy.visit('/app/workload-management#/workloadManagement'); | ||
| cy.get('.euiBasicTable .euiTableRow').should('have.length.greaterThan', 0); | ||
| }); | ||
|
|
||
| it('should display the WLM page with the workload group table', () => { | ||
| cy.contains('Workload groups').should('be.visible'); | ||
| cy.get('.euiBasicTable').should('exist'); | ||
| cy.get('.euiTableRow').should('have.length.greaterThan', 0); | ||
| }); | ||
|
|
||
| it('should filter workload groups with the search bar', () => { | ||
| cy.get('.euiFieldSearch').type('DEFAULT_QUERY_GROUP'); | ||
| cy.get('.euiTableRow').should('have.length.at.least', 1); | ||
| cy.get('.euiFieldSearch').clear(); | ||
| cy.get('.euiTableRow').should('have.length.greaterThan', 0); | ||
| }); | ||
|
|
||
| it('should refresh stats on clicking the refresh button', () => { | ||
| return cy.get('.euiTableRow').then(() => { | ||
| cy.get('button').contains('Refresh').click(); | ||
|
|
||
| cy.get('.euiTableRow', { timeout: 10000 }).should(($newRows) => { | ||
| expect($newRows.length).to.be.greaterThan(0); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('should display the WLM main page with workload group table and summary stats', () => { | ||
| // Confirm table exists | ||
| cy.get('.euiBasicTable').should('be.visible'); | ||
| cy.get('.euiTableRow').should('have.length.greaterThan', 0); | ||
|
|
||
| // Confirm stat cards exist | ||
| const titles = ['Total workload groups', 'Total groups exceeding limits']; | ||
|
|
||
| titles.forEach((title) => { | ||
| cy.contains(title).should('be.visible'); | ||
| }); | ||
| }); | ||
|
|
||
| it('should filter workload groups by name in search', () => { | ||
| cy.get('.euiFieldSearch').type('DEFAULT_WORKLOAD_GROUP'); | ||
| cy.get('.euiTableRow').should('contain.text', 'DEFAULT_WORKLOAD_GROUP'); | ||
|
|
||
| cy.get('.euiFieldSearch').clear().type('nonexistent_group_12345'); | ||
| cy.get('.euiTableRow').should('contain.text', 'No items found'); | ||
| }); | ||
|
|
||
| it('should route to workload group detail page when clicking a group name', () => { | ||
| cy.get('.euiTableRow') | ||
| .first() | ||
| .within(() => { | ||
| cy.get('a').first().click({ force: true }); | ||
| }); | ||
|
|
||
| cy.contains('Workload group name', { timeout: 10000 }).should('exist'); | ||
| }); | ||
|
|
||
| it('should route to the Create Workload Group page when clicking the Create button', () => { | ||
| // Click the "Create workload group" button | ||
| cy.contains('Create workload group').click(); | ||
|
|
||
| // Confirm we are on the create page | ||
| cy.url().should('include', '/wlm-create'); | ||
|
|
||
| // Validate that the form elements exist | ||
| cy.contains('Resiliency mode').should('be.visible'); | ||
| cy.get('[data-testid="indexInput"]').should('exist'); | ||
| cy.get('button').contains('+ Add another rule').should('exist'); | ||
| cy.get('input[data-testid="cpu-threshold-input"]').should('exist'); | ||
| cy.get('input[data-testid="memory-threshold-input"]').should('exist'); | ||
| }); | ||
| }); |
99 changes: 99 additions & 0 deletions
99
cypress/integration/plugins/query-insights-dashboards/7_WLM_details.cy.js
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,99 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| describe('WLM Details Page', () => { | ||
| const groupName = `test_group_${Date.now()}`; | ||
|
|
||
| before(() => { | ||
| Cypress.env('groupName', groupName); | ||
|
|
||
| // Clean up existing non-default groups | ||
| cy.request({ | ||
| method: 'GET', | ||
| url: '/api/_wlm/workload_group', | ||
| headers: { 'osd-xsrf': 'true' }, | ||
| }).then((res) => { | ||
| const groups = res.body?.workload_groups ?? []; | ||
| groups.forEach((g) => { | ||
| if (g.name !== 'DEFAUL_WORKLOAD_GROUP') { | ||
| cy.request({ | ||
| method: 'DELETE', | ||
| url: `/api/_wlm/workload_group/${g.name}`, | ||
| headers: { 'osd-xsrf': 'true' }, | ||
| failOnStatusCode: false, | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| cy.request({ | ||
| method: 'PUT', | ||
| url: '/api/_wlm/workload_group', | ||
| headers: { 'osd-xsrf': 'true' }, | ||
| body: { | ||
| name: groupName, | ||
| resiliency_mode: 'soft', | ||
| resource_limits: { | ||
| cpu: 0.01, | ||
| memory: 0.01, | ||
| }, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| cy.visit(`/app/workload-management#/wlm-details?name=${groupName}`); | ||
| // Wait until rows render | ||
| cy.get('.euiBasicTable .euiTableRow').should('have.length.greaterThan', 0); | ||
| }); | ||
|
|
||
| it('should display workload group summary panel', () => { | ||
| cy.contains('Workload group name').should('exist'); | ||
| cy.contains('Resiliency mode').should('exist'); | ||
| cy.contains('CPU usage limit').should('exist'); | ||
| cy.contains('Memory usage limit').should('exist'); | ||
| cy.contains(groupName).should('exist'); | ||
| }); | ||
|
|
||
| it('should switch between tabs', () => { | ||
| // Switch to Settings tab | ||
| cy.get('[data-testid="wlm-tab-settings"]').click(); | ||
| cy.contains('Workload group settings').should('exist'); | ||
|
|
||
| // Switch to Resources tab | ||
| cy.get('[data-testid="wlm-tab-resources"]').click(); | ||
| cy.contains('Node ID').should('exist'); | ||
| }); | ||
|
|
||
| it('should display node resource usage table', () => { | ||
| cy.contains('Node ID').should('exist'); | ||
| cy.get('.euiTableRow').should('have.length.greaterThan', 0); | ||
| }); | ||
|
|
||
| it('should show delete modal', () => { | ||
| cy.contains('Delete').click(); | ||
| cy.contains('Delete workload group').should('exist'); | ||
| }); | ||
|
|
||
| it('should delete the workload group successfully', () => { | ||
| cy.contains('Delete').click(); // opens modal | ||
| cy.get('input[placeholder="delete"]').type('delete'); | ||
| cy.get('.euiModalFooter button').contains('Delete').click(); | ||
|
|
||
| // Confirm redirected back to WLM main page | ||
| cy.url().should('include', '/workloadManagement'); | ||
|
|
||
| // Confirm toast appears | ||
| cy.contains(`Deleted workload group "${groupName}"`).should('exist'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('WLM Details – DEFAULT_WORKLOAD_GROUP', () => { | ||
| it('should disable settings tab for DEFAULT_WORKLOAD_GROUP', () => { | ||
| cy.visit('/app/workload-management#/wlm-details?name=DEFAULT_WORKLOAD_GROUP'); | ||
| cy.get('[data-testid="wlm-tab-settings"]').click(); | ||
| cy.contains('Settings are not available for the DEFAULT_WORKLOAD_GROUP').should('exist'); | ||
| }); | ||
| }); | ||
75 changes: 75 additions & 0 deletions
75
cypress/integration/plugins/query-insights-dashboards/8_WLM_create.cy.js
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,75 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| describe('WLM Create Page', () => { | ||
| beforeEach(() => { | ||
| cy.visit('/app/workload-management#/wlm-create'); | ||
| }); | ||
|
|
||
| it('renders the full create form with required fields', () => { | ||
| cy.contains('h1', 'Create workload group').should('exist'); | ||
| cy.contains('h2', 'Overview').should('exist'); | ||
|
|
||
| // Form labels and fields | ||
| [ | ||
| 'Name', | ||
| 'Description – Optional', | ||
| 'Resiliency mode', | ||
| 'Index wildcard', | ||
| 'Reject queries when CPU usage exceeds', | ||
| 'Reject queries when memory usage exceeds', | ||
| ].forEach((label) => { | ||
| cy.contains(label).should('exist'); | ||
| }); | ||
|
|
||
| cy.contains('Soft').should('exist'); | ||
| cy.contains('Enforced').should('exist'); | ||
| cy.contains('+ Add another rule').should('exist'); | ||
| cy.get('button').contains('Create workload group').should('exist'); | ||
| }); | ||
|
|
||
| it('shows validation errors for CPU and memory thresholds', () => { | ||
| cy.get('[data-testid="cpu-threshold-input"]').clear().type('150'); | ||
| cy.contains('Value must be between 0 and 100').should('exist'); | ||
|
|
||
| cy.get('[data-testid="cpu-threshold-input"]').clear().type('-10'); | ||
| cy.contains('Value must be between 0 and 100').should('exist'); | ||
|
|
||
| cy.get('[data-testid="memory-threshold-input"]').clear().type('101'); | ||
| cy.contains('Value must be between 0 and 100').should('exist'); | ||
|
|
||
| cy.get('[data-testid="memory-threshold-input"]').clear().type('-1'); | ||
| cy.contains('Value must be between 0 and 100').should('exist'); | ||
| }); | ||
|
|
||
| it('creates a workload group successfully with valid inputs', () => { | ||
| const groupName = `wlm_test_${Date.now()}`; | ||
|
|
||
| cy.get('[data-testid="name-input"]').type(groupName); | ||
| cy.contains('Soft').click(); | ||
| cy.get('[data-testid="indexInput"]').type('test-index'); | ||
| cy.get('[data-testid="cpu-threshold-input"]').type('10'); | ||
| cy.get('[data-testid="memory-threshold-input"]').type('20'); | ||
|
|
||
| cy.intercept('PUT', '/api/_wlm/workload_group').as('createRequest'); | ||
| cy.get('button').contains('Create workload group').click(); | ||
|
|
||
| cy.url().should('include', '/workloadManagement'); | ||
| cy.contains(groupName).should('exist'); | ||
| }); | ||
|
|
||
| it('adds and deletes a rule block', () => { | ||
| cy.contains('+ Add another rule').click(); | ||
| cy.get('[data-testid="indexInput"]').should('have.length', 2); | ||
|
|
||
| cy.get('[aria-label="Delete rule"]').first().click(); | ||
| cy.get('[data-testid="indexInput"]').should('have.length', 1); | ||
| }); | ||
|
|
||
| it('navigates back to main page on Cancel', () => { | ||
| cy.get('button').contains('Cancel').click(); | ||
| cy.url().should('include', '/workloadManagement'); | ||
| }); | ||
| }); |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: should be
DEFAULT