Skip to content

Commit e9fa679

Browse files
authored
Fix flaky test for vis-augmenter (#1038)
* wait for dashboard to be searchable Signed-off-by: Hailong Cui <ihailong@amazon.com> * refresh private tenant kibana index also Signed-off-by: Hailong Cui <ihailong@amazon.com> * Add one more filter for core ft Signed-off-by: Hailong Cui <ihailong@amazon.com> * Add CYPRESS_NO_COMMAND_LOG flag Signed-off-by: Hailong Cui <ihailong@amazon.com> * only run vis-augmenter for debug Signed-off-by: Hailong Cui <ihailong@amazon.com> * only run vis-augmenter for debug Signed-off-by: Hailong Cui <ihailong@amazon.com> * only run vis-augmenter for debug Signed-off-by: Hailong Cui <ihailong@amazon.com> * wait for page load Signed-off-by: Hailong Cui <ihailong@amazon.com> * firefox Signed-off-by: Hailong Cui <ihailong@amazon.com> * revert test code Signed-off-by: Hailong Cui <ihailong@amazon.com> * wait for page load Signed-off-by: Hailong Cui <ihailong@amazon.com> * add more timeout Signed-off-by: Hailong Cui <ihailong@amazon.com> * add more checks Signed-off-by: Hailong Cui <ihailong@amazon.com> * add vis to dashboard Signed-off-by: Hailong Cui <ihailong@amazon.com> * no command log Signed-off-by: Hailong Cui <ihailong@amazon.com> * use correct flag CYPRESS_NO_COMMAND_LOG Signed-off-by: Hailong Cui <ihailong@amazon.com> * set to global tenant when security enabled Signed-off-by: Hailong Cui <ihailong@amazon.com> --------- Signed-off-by: Hailong Cui <ihailong@amazon.com>
1 parent 2784d24 commit e9fa679

File tree

5 files changed

+44
-7
lines changed

5 files changed

+44
-7
lines changed

.github/workflows/cypress-workflow-bundle-snapshot-based-windows.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ jobs:
1717
filters: |
1818
tests:
1919
- 'cypress/**/core-opensearch-dashboards/**'
20+
- 'cypress/utils/dashboards/**'
2021
2122
tests-with-security:
2223
needs: changes
2324
if: ${{ needs.changes.outputs.tests == 'true' }}
2425
uses: ./.github/workflows/release-e2e-workflow-template-windows.yml
2526
with:
2627
test-name: Core Dashboards using Bundle Snapshot
27-
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'
28+
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'
2829
# not useful now as the windows e2e template currently do not allow serving parameters
2930
#osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true
3031

@@ -34,7 +35,7 @@ jobs:
3435
uses: ./.github/workflows/release-e2e-workflow-template-windows.yml
3536
with:
3637
test-name: Core Dashboards using Bundle Snapshot
37-
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'
38+
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'
3839
# not useful now as the windows e2e template currently do not allow serving parameters
3940
#osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true
4041
security-enabled: false

.github/workflows/cypress-workflow-bundle-snapshot-based.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ jobs:
1717
filters: |
1818
tests:
1919
- 'cypress/**/core-opensearch-dashboards/**'
20+
- 'cypress/utils/dashboards/**'
2021
2122
tests-with-security:
2223
needs: changes
2324
if: ${{ needs.changes.outputs.tests == 'true' }}
2425
uses: ./.github/workflows/release-e2e-workflow-template.yml
2526
with:
2627
test-name: Core Dashboards using Bundle Snapshot
27-
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'
28+
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'
2829
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true
2930

3031
tests-without-security:
@@ -33,6 +34,6 @@ jobs:
3334
uses: ./.github/workflows/release-e2e-workflow-template.yml
3435
with:
3536
test-name: Core Dashboards using Bundle Snapshot
36-
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'
37+
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'
3738
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true
3839
security-enabled: false

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis-augmenter/dashboard_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
deleteVisAugmenterData,
1313
bootstrapDashboard,
1414
} from '../../../../../utils/dashboards/vis-augmenter/helpers';
15+
import { CURRENT_TENANT } from '../../../../../utils/commands';
1516

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

8182
before(() => {
83+
CURRENT_TENANT.newTenant = 'global';
8284
// Create a dashboard and add some visualizations
8385
bootstrapDashboard(
8486
INDEX_SETTINGS_FILEPATH_SIMPLE,

cypress/utils/dashboards/vis-augmenter/commands.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ Cypress.Commands.add('getMenuItems', { prevSubject: 'optional' }, (menu) =>
3232
);
3333

3434
Cypress.Commands.add('visitDashboard', (dashboardName) => {
35+
cy.intercept('/api/saved_objects/_find*').as('loadDashboards');
3536
cy.visit(`${BASE_PATH}/app/dashboards`);
36-
cy.wait(2000);
37+
cy.wait('@loadDashboards', { timeout: 300000 });
3738
cy.get('.euiFieldSearch').type(dashboardName);
3839
cy.wait(2000);
3940
cy.get('[data-test-subj="itemsInMemTable"]').contains(dashboardName).click({

cypress/utils/dashboards/vis-augmenter/helpers.js

+34-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ const addMetric = (metric, index) => {
178178
force: true,
179179
}
180180
);
181-
cy.contains(`${metric.aggregation}`).click({ force: true });
182181
});
183182

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

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

262263
// Create several different visualizations
263264
visualizationSpecs.forEach((visualizationSpec) => {
@@ -267,9 +268,35 @@ export const bootstrapDashboard = (
267268
visualizationSpec.name,
268269
visualizationSpec.metrics
269270
);
271+
// wait for vis saved
272+
cy.contains(`Saved '${visualizationSpec.name}'`);
273+
cy.wait(5000);
274+
// cy.get(`[data-title="${visualizationSpec.name}"]`).should('have.length', 1);
275+
// somehow the visualization is not added to dashboard
276+
cy.get('body').then(($body) => {
277+
if ($body.find(`[data-title="${visualizationSpec.name}"]`).length === 0) {
278+
cy.getElementByTestId('dashboardAddPanelButton').click({ force: true });
279+
cy.getElementByTestId('savedObjectFinderSearchInput')
280+
.focus()
281+
.clear()
282+
.type(visualizationSpec.name);
283+
284+
cy.getElementByTestId(
285+
`savedObjectTitle${visualizationSpec.name}`
286+
).click();
287+
288+
cy.getElementByTestId('euiFlyoutCloseButton').click();
289+
290+
cy.get(`[data-title="${visualizationSpec.name}"]`).should(
291+
'have.length',
292+
1
293+
);
294+
}
295+
});
270296
});
271297

272-
cy.getElementByTestId('dashboardSaveMenuItem').click({
298+
/// wait for page load
299+
cy.getElementByTestId('dashboardSaveMenuItem', { timeout: 300000 }).click({
273300
force: true,
274301
});
275302

@@ -278,6 +305,11 @@ export const bootstrapDashboard = (
278305
cy.getElementByTestId('confirmSaveSavedObjectButton').click({
279306
force: true,
280307
});
308+
309+
cy.contains(`Dashboard '${dashboardName}' was saved`);
310+
311+
// make newly created dashboards searchable
312+
devToolsRequest('.kibana*/_refresh', 'POST');
281313
};
282314

283315
export const filterByObjectType = (type) => {

0 commit comments

Comments
 (0)