From 8a8eaa00a7304abadbd4d18f61a14b8d1b7924c7 Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Thu, 13 Jun 2024 02:03:24 +0800 Subject: [PATCH] fix data source flaky tests (#1383) * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe * troubleshoot Signed-off-by: SuZhou-Joe --------- Signed-off-by: SuZhou-Joe (cherry picked from commit ba9ac55ae56d3b35ddbd7a6d9206a6d28b42840f) --- .../1_create_datasource.spec.js | 4 ++++ .../datasource-management-plugin/2_datasource_table.spec.js | 6 ++++++ .../3_update_datasource.spec.js | 4 ++++ .../4_set_default_datasource.spec.js | 6 +++++- .../datasource-management-dashboards-plugin/commands.js | 3 ++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index f377475b5..a086df790 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -43,6 +43,10 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { after(() => { // Clean up after all test are run cy.deleteAllDataSources(); + // remove the default data source + cy.setAdvancedSetting({ + defaultDataSource: '', + }); }); it('should successfully load the page', () => { diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js index d49621ee9..eed5c7566 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js @@ -24,6 +24,12 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { after(() => { // Clean up after all test are run cy.deleteAllDataSources(); + // clear cache + cy.clearCache(); + // remove the default data source + cy.setAdvancedSetting({ + defaultDataSource: '', + }); }); it('should successfully load the page', () => { diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js index e525c6b17..007de4d04 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js @@ -51,6 +51,10 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { after(() => { // Clean up after all test are run cy.deleteAllDataSources(); + // remove the default data source + cy.setAdvancedSetting({ + defaultDataSource: '', + }); }); it('should successfully load the listing page & have 2 records in table', () => { diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/4_set_default_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/4_set_default_datasource.spec.js index 1c9d90478..822609dd5 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/4_set_default_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/4_set_default_datasource.spec.js @@ -26,7 +26,11 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { }); after(() => { // Clean up after all test are run - cy.deleteAllDataSourcesOnUI(); + cy.deleteAllDataSources(); + // remove the default data source + cy.setAdvancedSetting({ + defaultDataSource: '', + }); }); it('The first data source is the default data source', () => { cy.visitDataSourcesListingPage(); diff --git a/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js b/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js index d8ac088ce..9982232f1 100644 --- a/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js +++ b/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js @@ -302,7 +302,8 @@ Cypress.Commands.add('singleDeleteDataSourceByTitle', (dataSourceTitle) => { .should('exist') // Ensure the button exists .should('be.visible') // Ensure the button is visible .click({ force: true }); // Click the button - cy.wait(1000); + + cy.wait(2000); cy.visitDataSourcesListingPage(); });