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

Fix flaky test for vis-augmenter #1038

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6535e28
wait for dashboard to be searchable
Hailong-am Feb 1, 2024
3310d81
refresh private tenant kibana index also
Hailong-am Feb 2, 2024
d8beb4c
Merge remote-tracking branch 'upstream/main' into vis-augmenter-flaky…
Hailong-am Feb 2, 2024
244732f
Add one more filter for core ft
Hailong-am Feb 2, 2024
c0cebdc
Add CYPRESS_NO_COMMAND_LOG flag
Hailong-am Feb 4, 2024
915ad0b
Merge branch 'main' into vis-augmenter-flaky-test
Hailong-am Feb 4, 2024
020d899
only run vis-augmenter for debug
Hailong-am Feb 7, 2024
eb02278
Merge branch 'main' into vis-augmenter-flaky-test
Hailong-am Feb 7, 2024
850eff2
only run vis-augmenter for debug
Hailong-am Feb 7, 2024
209c6f8
Merge remote-tracking branch 'origin/vis-augmenter-flaky-test' into v…
Hailong-am Feb 7, 2024
0524bc2
only run vis-augmenter for debug
Hailong-am Feb 7, 2024
8d872f6
Merge branch 'main' into vis-augmenter-flaky-test
Hailong-am Feb 19, 2024
8fd18cf
wait for page load
Hailong-am Feb 19, 2024
dd3f561
firefox
Hailong-am Feb 19, 2024
d0eff55
revert test code
Hailong-am Feb 19, 2024
e2efd7d
wait for page load
Hailong-am Feb 20, 2024
5763609
add more timeout
Hailong-am Feb 21, 2024
7cfcf3e
Merge branch 'main' into vis-augmenter-flaky-test
Hailong-am Feb 21, 2024
1571be4
add more checks
Hailong-am Feb 21, 2024
aa033e8
add vis to dashboard
Hailong-am Feb 21, 2024
6f9d602
no command log
Hailong-am Feb 22, 2024
91bf0f1
use correct flag CYPRESS_NO_COMMAND_LOG
Hailong-am Feb 22, 2024
ef19dad
set to global tenant when security enabled
Hailong-am Feb 22, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ jobs:
filters: |
tests:
- 'cypress/**/core-opensearch-dashboards/**'
- 'cypress/utils/dashboards/**'

tests-with-security:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template-windows.yml
with:
test-name: Core Dashboards using Bundle Snapshot
test-command: env CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chrome --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chrome --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
# not useful now as the windows e2e template currently do not allow serving parameters
#osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true

Expand All @@ -34,7 +35,7 @@ jobs:
uses: ./.github/workflows/release-e2e-workflow-template-windows.yml
with:
test-name: Core Dashboards using Bundle Snapshot
test-command: env CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-without-security --browser chrome --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-without-security --browser chrome --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
# not useful now as the windows e2e template currently do not allow serving parameters
#osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true
security-enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ jobs:
filters: |
tests:
- 'cypress/**/core-opensearch-dashboards/**'
- 'cypress/utils/dashboards/**'

tests-with-security:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: Core Dashboards using Bundle Snapshot
test-command: env CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true

tests-without-security:
Expand All @@ -33,6 +34,6 @@ jobs:
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: Core Dashboards using Bundle Snapshot
test-command: env CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-without-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-without-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true
security-enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
deleteVisAugmenterData,
bootstrapDashboard,
} from '../../../../../utils/dashboards/vis-augmenter/helpers';
import { CURRENT_TENANT } from '../../../../../utils/commands';

describe('Vis augmenter - existing dashboards work as expected', () => {
describe('dashboard with ineligible, eligible, and vega visualizations', () => {
Expand Down Expand Up @@ -79,6 +80,7 @@ describe('Vis augmenter - existing dashboards work as expected', () => {
);

before(() => {
CURRENT_TENANT.newTenant = 'global';
// Create a dashboard and add some visualizations
bootstrapDashboard(
INDEX_SETTINGS_FILEPATH_SIMPLE,
Expand Down
3 changes: 2 additions & 1 deletion cypress/utils/dashboards/vis-augmenter/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ Cypress.Commands.add('getMenuItems', { prevSubject: 'optional' }, (menu) =>
);

Cypress.Commands.add('visitDashboard', (dashboardName) => {
cy.intercept('/api/saved_objects/_find*').as('loadDashboards');
cy.visit(`${BASE_PATH}/app/dashboards`);
cy.wait(2000);
cy.wait('@loadDashboards', { timeout: 300000 });
cy.get('.euiFieldSearch').type(dashboardName);
cy.wait(2000);
cy.get('[data-test-subj="itemsInMemTable"]').contains(dashboardName).click({
Expand Down
36 changes: 34 additions & 2 deletions cypress/utils/dashboards/vis-augmenter/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ const addMetric = (metric, index) => {
force: true,
}
);
cy.contains(`${metric.aggregation}`).click({ force: true });
});

// non-count aggregations will have an additional field value to set
Expand Down Expand Up @@ -257,7 +256,9 @@ export const bootstrapDashboard = (
sampleDataFilepath
);

cy.intercept('/api/saved_objects/*').as('savedObjectsApis');
miscUtils.visitPage('app/dashboards#/create');
cy.wait(['@savedObjectsApis'], { timeout: 300000 });

// Create several different visualizations
visualizationSpecs.forEach((visualizationSpec) => {
Expand All @@ -267,9 +268,35 @@ export const bootstrapDashboard = (
visualizationSpec.name,
visualizationSpec.metrics
);
// wait for vis saved
cy.contains(`Saved '${visualizationSpec.name}'`);
cy.wait(5000);
// cy.get(`[data-title="${visualizationSpec.name}"]`).should('have.length', 1);
// somehow the visualization is not added to dashboard
cy.get('body').then(($body) => {
if ($body.find(`[data-title="${visualizationSpec.name}"]`).length === 0) {
cy.getElementByTestId('dashboardAddPanelButton').click({ force: true });
cy.getElementByTestId('savedObjectFinderSearchInput')
.focus()
.clear()
.type(visualizationSpec.name);

cy.getElementByTestId(
`savedObjectTitle${visualizationSpec.name}`
).click();

cy.getElementByTestId('euiFlyoutCloseButton').click();

cy.get(`[data-title="${visualizationSpec.name}"]`).should(
'have.length',
1
);
}
});
});

cy.getElementByTestId('dashboardSaveMenuItem').click({
/// wait for page load
cy.getElementByTestId('dashboardSaveMenuItem', { timeout: 300000 }).click({
force: true,
});

Expand All @@ -278,6 +305,11 @@ export const bootstrapDashboard = (
cy.getElementByTestId('confirmSaveSavedObjectButton').click({
force: true,
});

cy.contains(`Dashboard '${dashboardName}' was saved`);

// make newly created dashboards searchable
devToolsRequest('.kibana*/_refresh', 'POST');
};

export const filterByObjectType = (type) => {
Expand Down
Loading