Skip to content

Commit

Permalink
[Tests] Set default tenancy to global for data explorer tests (#959) (#…
Browse files Browse the repository at this point in the history
…963)

Signed-off-by: manasvinibs <[email protected]>
(cherry picked from commit e7647a1)

Co-authored-by: Manasvini B Suryanarayana <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and manasvinibs authored Jan 22, 2024
1 parent 73f6db1 commit 860444c
Show file tree
Hide file tree
Showing 21 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { CURRENT_TENANT } from '../../../../../utils/commands';

/// <reference types="cypress" />

describe('Before', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.deleteAllIndices();
cy.deleteSavedObjectByType('index-pattern');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
TestFixtureHandler,
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const testFixtureHandler = new TestFixtureHandler(
cy,
Cypress.env('openSearchUrl')
Expand All @@ -18,6 +20,7 @@ describe('date_nanos', () => {
const fromTime = 'Sep 21, 2019 @ 20:31:44.000';
const toTime = 'Sep 23, 2019 @ 03:31:44.000';
before(() => {
CURRENT_TENANT.newTenant = 'global';
// import date nanos
testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/date_nanos/mappings.json.txt'
Expand All @@ -29,7 +32,6 @@ describe('date_nanos', () => {
cy.setAdvancedSetting({
defaultIndex: 'date-nanos',
});

miscUtils.visitPage('app/data-explorer/discover#/');
cy.waitForLoader();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TestFixtureHandler,
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -16,6 +17,7 @@ const testFixtureHandler = new TestFixtureHandler(

describe('date_nanos_mixed', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
//import date nanos
testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/date_nanos_mix/mappings.json.txt'
Expand All @@ -27,7 +29,6 @@ describe('date_nanos_mixed', () => {
cy.setAdvancedSetting({
defaultIndex: 'timestamp-*',
});

miscUtils.visitPage('app/data-explorer/discover#/');
cy.waitForLoader();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DE_DEFAULT_END_TIME,
DE_DEFAULT_START_TIME,
} from '../../../../../utils/constants';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -25,6 +26,7 @@ const indexSet = [

describe('discover app', { scrollBehavior: false }, () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
// import logstash functional
testFixtureHandler.importJSONDocIfNeeded(
indexSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TestFixtureHandler,
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -21,6 +22,7 @@ const indexSet = [

describe('discover histogram', { scrollBehavior: false }, () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.log('load opensearch-dashboards index with default index pattern');

// import long window logstash index pattern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MiscUtils,
TestFixtureHandler,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -21,6 +22,7 @@ const indexSet = [

describe('doc link in discover', () => {
beforeEach(() => {
CURRENT_TENANT.newTenant = 'global';
// import logstash functional
testFixtureHandler.importJSONDocIfNeeded(
indexSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MiscUtils,
TestFixtureHandler,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -21,6 +22,7 @@ const indexSet = [

describe('discover doc table', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
// import logstash functional
testFixtureHandler.importJSONDocIfNeeded(
indexSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DE_DEFAULT_END_TIME,
DE_DEFAULT_START_TIME,
} from '../../../../../utils/constants';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -20,6 +21,7 @@ const testFixtureHandler = new TestFixtureHandler(

describe('errors', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
// import invalid_scripted_field
testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/invalid_scripted_field/mappings.json.txt'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TestFixtureHandler,
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -21,6 +22,7 @@ const indexSet = [

describe('discover tab', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
// import logstash functional
testFixtureHandler.importJSONDocIfNeeded(
indexSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MiscUtils,
TestFixtureHandler,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -21,6 +22,7 @@ const indexSet = [

describe('discover field visualize button', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
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 @@ -7,6 +7,7 @@ import {
MiscUtils,
TestFixtureHandler,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -21,6 +22,7 @@ const indexSet = [

describe('discover filter editor', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
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 @@ -11,6 +11,7 @@ import {
DE_DEFAULT_END_TIME,
DE_DEFAULT_START_TIME,
} from '../../../../../utils/constants';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -20,6 +21,7 @@ const testFixtureHandler = new TestFixtureHandler(

describe('index pattern with encoded id', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_with_encoded_id/mappings.json.txt'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TestFixtureHandler,
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -16,6 +17,7 @@ const testFixtureHandler = new TestFixtureHandler(

describe('index pattern without field spec', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
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 @@ -11,6 +11,7 @@ import {
DE_DEFAULT_END_TIME,
DE_DEFAULT_START_TIME,
} from '../../../../../utils/constants';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -25,6 +26,7 @@ const indexSet = [

describe('inspector', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
// import logstash functional
testFixtureHandler.importJSONDocIfNeeded(
indexSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TestFixtureHandler,
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -16,6 +17,7 @@ const testFixtureHandler = new TestFixtureHandler(

describe('test large strings', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/empty_opensearch_dashboards/mappings.json.txt'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DE_DEFAULT_END_TIME,
DE_DEFAULT_START_TIME,
} from '../../../../../utils/constants';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -27,6 +28,7 @@ describe('saved queries saved objects', () => {
const fromTime = 'Sep 20, 2015 @ 08:00:00.000';
const toTime = 'Sep 21, 2015 @ 08:00:00.000';
before(() => {
CURRENT_TENANT.newTenant = 'global';
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 @@ -11,6 +11,7 @@ import {
DE_DEFAULT_END_TIME,
DE_DEFAULT_START_TIME,
} from '../../../../../utils/constants';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -25,6 +26,7 @@ const indexSet = [

describe('shared links', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
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 @@ -7,6 +7,7 @@ import {
MiscUtils,
TestFixtureHandler,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -21,6 +22,7 @@ const indexSet = [

describe('discover sidebar', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
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 @@ -7,6 +7,7 @@ import {
TestFixtureHandler,
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
const testFixtureHandler = new TestFixtureHandler(
Expand All @@ -16,6 +17,7 @@ const testFixtureHandler = new TestFixtureHandler(

describe('source filters', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/visualize_source-filters/mappings.json.txt'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/// <reference types="cypress" />

import { TestFixtureHandler } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const testFixtureHandler = new TestFixtureHandler(
cy,
Expand All @@ -14,6 +15,7 @@ const testFixtureHandler = new TestFixtureHandler(

describe('After', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
//cy.deleteAllIndices();
testFixtureHandler.clearJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt'
Expand Down
5 changes: 5 additions & 0 deletions cypress/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ Cypress.Commands.add('setAdvancedSetting', (changes) => {
.request({
method: 'POST',
url,
qs: Cypress.env('SECURITY_ENABLED')
? {
security_tenant: CURRENT_TENANT.defaultTenant,
}
: {},
headers: {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
Expand Down

0 comments on commit 860444c

Please sign in to comment.