Skip to content

Commit 467223b

Browse files
opensearch-trigger-bot[bot]github-actions[bot]Kishore Kumaar Natarajanansjcy
authored
Add version-aware settings support (#407) (#427)
* Added version-aware changes * adding local datasource logic * adding local datasource logic * adding local datasource logic * adding local datasource logic * adding local datasource logic * Removed _cat/plugins * hide live queries in 3.3 below * updated tests * updated tests * updated tests * Updated tests * Fixed comments * Lint fix --------- (cherry picked from commit 8192a9b) Signed-off-by: Kishore Kumaar Natarajan <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kishore Kumaar Natarajan <[email protected]> Co-authored-by: Chenyang Ji <[email protected]>
1 parent f3772f2 commit 467223b

File tree

17 files changed

+801
-305
lines changed

17 files changed

+801
-305
lines changed

common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const DEFAULT_EXPORTER_TYPE = EXPORTER_TYPE.localIndex;
6868
export const DEFAULT_DELETE_AFTER_DAYS = '7';
6969
export const DEFAULT_REFRESH_INTERVAL = 30000; // default 30s
7070
export const TOP_N_DISPLAY_LIMIT = 9;
71+
export const DEFAULT_SHOW_LIVE_QUERIES_ON_ERROR = false;
7172
export const WLM_GROUP_ID_PARAM = 'wlmGroupId';
7273
export const ALL_WORKLOAD_GROUPS_TEXT = 'All workload groups';
7374
export const CHART_COLORS = [

cypress/e2e/5_live_queries.cy.js

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -358,75 +358,90 @@ describe('Inflight Queries Dashboard - WLM Enabled', () => {
358358
}).as('getLiveQueries');
359359
});
360360

361-
cy.fixture('stub_wlm_stats.json').then((wlmStatsResponse) => {
361+
// WLM stats
362+
cy.fixture('stub_wlm_stats.json').then((wlmStats) => {
362363
cy.intercept('GET', '**/api/_wlm/stats', {
363364
statusCode: 200,
364-
body: wlmStatsResponse,
365+
body: wlmStats.body,
365366
}).as('getWlmStats');
366367
});
367368

368-
cy.intercept('GET', '**/api/cat_plugins', {
369-
statusCode: 200,
370-
body: { hasWlm: true },
371-
}).as('getPluginsEnabled');
372-
373369
cy.intercept('GET', '**/api/_wlm/workload_group', {
374370
statusCode: 200,
375371
body: {
376372
workload_groups: [
377373
{ _id: 'ANALYTICS_WORKLOAD_GROUP', name: 'ANALYTICS_WORKLOAD_GROUP' },
378-
{ _id: 'DEFAULT_QUERY_GROUP', name: 'DEFAULT_QUERY_GROUP' },
374+
{ _id: 'DEFAULT_WORKLOAD_GROUP', name: 'DEFAULT_WORKLOAD_GROUP' },
379375
],
380376
},
381377
}).as('getWorkloadGroups');
382-
cy.intercept('GET', '**/api/cat_plugins', {
378+
379+
cy.intercept('GET', '**/api/cluster/version', {
383380
statusCode: 200,
384-
body: { hasWlm: true },
385-
}).as('getPluginsEnabled');
381+
body: { version: '3.3.0' },
382+
}).as('getClusterVersion');
386383

384+
// Navigate AFTER all intercepts are ready, then wait initial snapshot
387385
cy.navigateToLiveQueries();
388-
cy.wait('@getLiveQueries');
389386
});
390387

391388
it('displays WLM group links when WLM is enabled', () => {
392389
cy.wait('@getWorkloadGroups');
393-
cy.wait('@getPluginsEnabled');
394390

395391
cy.get('tbody tr')
396392
.first()
397393
.within(() => {
398-
cy.get('td').contains('ANALYTICS_WORKLOAD_GROUP').click({ force: true });
394+
cy.contains('td', 'ANALYTICS_WORKLOAD_GROUP').click({ force: true });
399395
});
400396
});
401397

402398
it('calls different API when WLM group selection changes', () => {
403-
// Intercept all live_queries calls
404-
cy.intercept('GET', '**/api/live_queries*').as('liveQueries');
399+
// Robust spies that tolerate extra query params & any order
400+
cy.intercept('GET', /\/api\/live_queries\?(?=.*\bwlmGroupId=ANALYTICS_WORKLOAD_GROUP\b).*/).as(
401+
'liveQueriesAnalytics'
402+
);
403+
404+
cy.intercept('GET', /\/api\/live_queries\?(?=.*\bwlmGroupId=DEFAULT_WORKLOAD_GROUP\b).*/).as(
405+
'liveQueriesDefault'
406+
);
405407

406-
// 1) Select ANALYTICS first
407-
cy.get('#wlm-group-select').should('exist').select('ANALYTICS_WORKLOAD_GROUP');
408+
cy.get('#wlm-group-select').should('exist');
408409

409-
cy.wait('@liveQueries')
410+
// 1) Select ANALYTICS
411+
cy.get('#wlm-group-select').select('ANALYTICS_WORKLOAD_GROUP');
412+
cy.wait('@liveQueriesAnalytics')
410413
.its('request.url')
411-
.should('include', 'wlmGroupId=ANALYTICS_WORKLOAD_GROUP');
414+
.should((urlStr) => {
415+
const url = new URL(urlStr);
416+
expect(url.searchParams.get('wlmGroupId')).to.eq('ANALYTICS_WORKLOAD_GROUP');
417+
});
412418

413-
// Component re-fetches workload groups after selection — wait for that
419+
// Component re-fetches groups after selection
414420
cy.wait('@getWorkloadGroups');
415421

416-
// 2) Select DEFAULT_WORKLOAD_GROUP explicitly
422+
// 2) Select DEFAULT
417423
cy.get('#wlm-group-select').select('DEFAULT_WORKLOAD_GROUP');
418424

419-
cy.wait('@liveQueries')
425+
cy.wait('@liveQueriesDefault')
420426
.its('request.url')
421-
.should('include', 'wlmGroupId=DEFAULT_WORKLOAD_GROUP');
427+
.should((urlStr) => {
428+
const url = new URL(urlStr);
429+
expect(url.searchParams.get('wlmGroupId')).to.eq('DEFAULT_WORKLOAD_GROUP');
430+
});
422431
});
423432

424433
it('displays total completion, cancellation, and rejection metrics correctly', () => {
425-
// Trigger a refresh to ensure WLM stats are loaded
426-
cy.get('[data-test-subj="live-queries-refresh-button"]').click();
434+
// Wait for version check to complete
435+
cy.wait('@getClusterVersion');
436+
437+
// Wait for WLM groups to be fetched
438+
cy.wait('@getWorkloadGroups');
439+
440+
// Wait for WLM stats to be fetched
427441
cy.wait('@getWlmStats');
428442

429-
cy.contains('Total completions')
443+
// Wait for the panels to be rendered with data
444+
cy.contains('Total completions', { timeout: 10000 })
430445
.closest('.euiPanel')
431446
.within(() => {
432447
cy.get('h2').should('contain.text', '300');

opensearch_dashboards.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"server": true,
66
"ui": true,
77
"requiredPlugins": [
8-
"navigation"
8+
"navigation",
9+
"opensearchDashboardsUtils"
910
],
1011
"optionalPlugins": [
1112
"dataSource",

public/application.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,45 @@ import { AppMountParameters, CoreStart } from '../../../src/core/public';
1010
import { QueryInsightsDashboardsApp } from './components/app';
1111
import { QueryInsightsDashboardsPluginStartDependencies } from './types';
1212
import { DataSourceManagementPluginSetup } from '../../../src/plugins/data_source_management/public';
13+
import {
14+
setCore,
15+
setSavedObjectsClient,
16+
setRouteService,
17+
setDataSourceManagementPlugin,
18+
setDataSourceEnabled,
19+
setNotifications,
20+
setUISettings,
21+
setApplication,
22+
setNavigationUI,
23+
setHeaderActionMenu,
24+
} from './service';
25+
import { RouteService } from './route_service';
1326

1427
export const renderApp = (
1528
core: CoreStart,
1629
depsStart: QueryInsightsDashboardsPluginStartDependencies,
1730
params: AppMountParameters,
1831
dataSourceManagement?: DataSourceManagementPluginSetup
1932
) => {
33+
// Initialize services
34+
setCore(core);
35+
setSavedObjectsClient(core.savedObjects.client);
36+
setRouteService(new RouteService(core.http));
37+
setNotifications(core.notifications);
38+
setUISettings(core.uiSettings);
39+
setApplication(core.application);
40+
setHeaderActionMenu(params.setHeaderActionMenu);
41+
42+
if (dataSourceManagement) {
43+
setDataSourceManagementPlugin(dataSourceManagement);
44+
}
45+
46+
if (depsStart.navigation) {
47+
setNavigationUI(depsStart.navigation.ui);
48+
}
49+
50+
setDataSourceEnabled({ enabled: !!dataSourceManagement });
51+
2052
ReactDOM.render(
2153
<Router>
2254
<QueryInsightsDashboardsApp

0 commit comments

Comments
 (0)