From 9fd86d78545187fc64c3e11458a537ba8e8614d4 Mon Sep 17 00:00:00 2001
From: Anan Zhuang <ananzh@amazon.com>
Date: Mon, 15 Apr 2024 14:16:54 -0700
Subject: [PATCH] Use global tenant in vis_type_table and other tests (#1210)

Flaky tests due to loading time due to switch tenant. Currently set default tenant to global.
* remove tenant fix for MD

Partially resolves: opensearch-project/opensearch-build#4433

Signed-off-by: Anan <ananzh@amazon.com>
Co-authored-by: Hailong Cui <ihailong@amazon.com>
(cherry picked from commit 7b82031d288d3f0337b1175e6ce1f3b737fd88f6)
---
 cypress/integration/common/dashboard_sample_data_spec.js     | 5 ++++-
 .../opensearch-dashboards/apps/vis_type_table/basic.spec.js  | 2 ++
 .../opensearch-dashboards/apps/vis_type_table/data.spec.js   | 2 ++
 .../opensearch-dashboards/apps/vis_type_table/embed.spec.js  | 2 ++
 .../apps/vis_type_table/options.spec.js                      | 2 ++
 5 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/cypress/integration/common/dashboard_sample_data_spec.js b/cypress/integration/common/dashboard_sample_data_spec.js
index 7d7afa310..1ff84814e 100644
--- a/cypress/integration/common/dashboard_sample_data_spec.js
+++ b/cypress/integration/common/dashboard_sample_data_spec.js
@@ -7,6 +7,7 @@ import {
   CommonUI,
   MiscUtils,
 } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
+import { CURRENT_TENANT } from '../../utils/commands';
 
 /**
  * dashboard_sample_data test suite description:
@@ -22,7 +23,9 @@ export function dashboardSanityTests() {
   const path = baseURL.pathname.replace(/\/$/, '');
 
   describe('dashboard sample data validation', () => {
-    before(() => {});
+    before(() => {
+      CURRENT_TENANT.newTenant = 'global';
+    });
 
     after(() => {});
 
diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/basic.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/basic.spec.js
index f2d822d23..3c03693b2 100644
--- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/basic.spec.js
+++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/basic.spec.js
@@ -13,6 +13,7 @@ import {
   TABLE_VIS_APP_PATH,
   TABLE_VIS_TYPE,
 } from '../../../../../utils/constants';
+import { CURRENT_TENANT } from '../../../../../utils/commands';
 
 /**
  * Basic test suite description:
@@ -25,6 +26,7 @@ import {
 
 describe('table visualization basic functions', () => {
   before(() => {
+    CURRENT_TENANT.newTenant = 'global';
     cy.deleteIndex(TABLE_INDEX_ID);
     cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
     cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);
diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/data.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/data.spec.js
index 7f3f8aa54..b49940a09 100644
--- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/data.spec.js
+++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/data.spec.js
@@ -16,6 +16,7 @@ import {
   TABLE_INDEX_END_TIME,
   toTestId,
 } from '../../../../../utils/constants';
+import { CURRENT_TENANT } from '../../../../../utils/commands';
 
 const commonUI = new CommonUI(cy);
 
@@ -24,6 +25,7 @@ const commonUI = new CommonUI(cy);
 
 describe('table visualization data', () => {
   before(() => {
+    CURRENT_TENANT.newTenant = 'global';
     cy.deleteIndex(TABLE_INDEX_ID);
     cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
     cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);
diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js
index d83130597..d330e444d 100644
--- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js
+++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js
@@ -16,6 +16,7 @@ import {
   TABLE_INDEX_END_TIME,
   toTestId,
 } from '../../../../../utils/constants';
+import { CURRENT_TENANT } from '../../../../../utils/commands';
 
 const commonUI = new CommonUI(cy);
 
@@ -49,6 +50,7 @@ describe('table visualization in embedded mode', () => {
   ];
 
   before(() => {
+    CURRENT_TENANT.newTenant = 'global';
     cy.deleteIndex(TABLE_INDEX_ID);
     cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
     cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);
diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/options.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/options.spec.js
index e7b9575e6..c3ec93848 100644
--- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/options.spec.js
+++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/options.spec.js
@@ -15,9 +15,11 @@ import {
   TABLE_INDEX_END_TIME,
   toTestId,
 } from '../../../../../utils/constants';
+import { CURRENT_TENANT } from '../../../../../utils/commands';
 
 describe('Table visualization options', () => {
   before(() => {
+    CURRENT_TENANT.newTenant = 'global';
     cy.deleteIndex(TABLE_INDEX_ID);
     cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
     cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);