Skip to content

Commit

Permalink
Fix: flaky test on 2.14 (#1280)
Browse files Browse the repository at this point in the history
The security plugin underwent a logic change, rendering the current tenant setting code invalid. To rectify this, cy.fleshTenantSettings is being added to ensure that the tenant is properly configured, allowing all test cases to pass as they did previously.
Issues Resolved

opensearch-project/OpenSearch-Dashboards#6472

---------

Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe authored May 8, 2024
1 parent f0ecd77 commit 55a7845
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CURRENT_TENANT } from '../../../../../utils/commands';
describe('Before', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteAllIndices();
cy.deleteSavedObjectByType('index-pattern');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ const indexSet = [
describe('discover app', { scrollBehavior: false }, () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
if (Cypress.env('SECURITY_ENABLED')) {
/**
* Security plugin is using private tenant as default.
* So here we'd need to set global tenant as default manually.
*/
cy.changeDefaultTenant({
multitenancy_enabled: true,
private_tenant_enabled: true,
default_tenant: 'global',
});
}
// import logstash functional
testFixtureHandler.importJSONDocIfNeeded(
indexSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const indexSet = [
describe('discover_advanced_setting', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
// import logstash functional
testFixtureHandler.importJSONDocIfNeeded(
indexSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const testFixtureHandler = new TestFixtureHandler(
describe('index pattern without field spec', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/mappings.json.txt'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const indexSet = [
describe('shared links', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.mappings.json.txt'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('Vis augmenter - existing dashboards work as expected', () => {

before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
// Create a dashboard and add some visualizations
bootstrapDashboard(
INDEX_SETTINGS_FILEPATH_SIMPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Visualization Builder Base Tests', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Visualization Builder Dashboard Tests', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Vis Builder: Area Chart', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Vis Builder: Bar Chart', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Vis Builder: Line Chart', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Vis Builder: Metric Chart', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Vis Builder: Table Chart', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { CURRENT_TENANT } from '../../../../../utils/commands';
describe('table visualization basic functions', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(TABLE_INDEX_ID);
cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const commonUI = new CommonUI(cy);
describe('table visualization data', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(TABLE_INDEX_ID);
cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('table visualization in embedded mode', () => {

before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(TABLE_INDEX_ID);
cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { CURRENT_TENANT } from '../../../../../utils/commands';
describe('Table visualization options', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.fleshTenantSettings();
cy.deleteIndex(TABLE_INDEX_ID);
cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);
Expand Down
6 changes: 6 additions & 0 deletions cypress/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,3 +587,9 @@ Cypress.Commands.add('loadSampleData', (type) => {
url: `${BASE_PATH}/api/sample_data/${type}`,
});
});

Cypress.Commands.add('fleshTenantSettings', () => {
// Go to the home page to flesh the tenant settings
cy.visit(`/app/home`);
cy.waitForLoader();
});

0 comments on commit 55a7845

Please sign in to comment.