Skip to content

Commit fb1c9f0

Browse files
Merge branch 'main' into MDS-inflight-queries
2 parents e589257 + 848b0e4 commit fb1c9f0

File tree

10 files changed

+379
-176
lines changed

10 files changed

+379
-176
lines changed

opensearch_dashboards.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "queryInsightsDashboards",
3-
"version": "3.3.0.0",
4-
"opensearchDashboardsVersion": "3.3.0",
3+
"version": "3.4.0.0",
4+
"opensearchDashboardsVersion": "3.4.0",
55
"server": true,
66
"ui": true,
77
"requiredPlugins": [

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "opensearch_query_insights_dashboards",
3-
"version": "3.3.0.0",
3+
"version": "3.4.0.0",
44
"description": "OpenSearch Dashboards plugin for Query Insights",
55
"main": "index.js",
66
"opensearchDashboards": {
7-
"version": "3.3.0",
8-
"templateVersion": "3.3.0"
7+
"version": "3.4.0",
8+
"templateVersion": "3.4.0"
99
},
1010
"license": "Apache-2.0",
1111
"homepage": "https://github.com/opensearch-project/query-insights-dashboards",
@@ -60,7 +60,8 @@
6060
"@babel/runtime": "^7.26.10",
6161
"@babel/runtime-corejs3": "^7.22.9",
6262
"pbkdf2": "3.1.5",
63-
"form-data": "4.0.4"
63+
"form-data": "4.0.4",
64+
"sha.js": "^2.4.12"
6465
},
6566
"devDependencies": {
6667
"@cypress/webpack-preprocessor": "^6.0.1",

public/pages/WorkloadManagement/WLMDetails/WLMDetails.test.tsx

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,17 @@ const mockDataSourceManagement = {
5151
(mockCore.http.get as jest.Mock).mockImplementation((url: string) => {
5252
if (url === '/api/_wlm/workload_group') {
5353
return Promise.resolve({
54-
body: {
55-
workload_groups: [{ name: 'test-group', _id: 'abc123' }],
56-
},
54+
workload_groups: [{ name: 'test-group', _id: 'abc123' }],
5755
});
5856
}
5957

6058
if (url === '/api/_wlm/stats/abc123') {
6159
return Promise.resolve({
62-
body: {
63-
'node-1': {
64-
workload_groups: {
65-
abc123: {
66-
cpu: { current_usage: 0.5 },
67-
memory: { current_usage: 0.3 },
68-
},
60+
'node-1': {
61+
workload_groups: {
62+
abc123: {
63+
cpu: { current_usage: 0.5 },
64+
memory: { current_usage: 0.3 },
6965
},
7066
},
7167
},
@@ -115,37 +111,33 @@ describe('WLMDetails Component', () => {
115111
(mockCore.http.get as jest.Mock).mockImplementation((path: string) => {
116112
if (path.startsWith('/api/_wlm/workload_group/test-group')) {
117113
return Promise.resolve({
118-
body: {
119-
workload_groups: [
120-
{
121-
_id: 'wg-123',
122-
name: 'test-group',
123-
resource_limits: { cpu: 0.5, memory: 0.5 },
124-
resiliency_mode: 'SOFT',
125-
},
126-
],
127-
},
114+
workload_groups: [
115+
{
116+
_id: 'wg-123',
117+
name: 'test-group',
118+
resource_limits: { cpu: 0.5, memory: 0.5 },
119+
resiliency_mode: 'SOFT',
120+
},
121+
],
128122
});
129123
}
130124
// 2) GET existing rules
131125
if (path === '/api/_rules/workload_group') {
132126
return Promise.resolve({
133-
body: {
134-
rules: [
135-
{
136-
id: 'keep-me',
137-
description: 'd',
138-
index_pattern: ['keep-*'],
139-
workload_group: 'wg-123',
140-
},
141-
{
142-
id: 'remove-me',
143-
description: 'd',
144-
index_pattern: ['remove-*'],
145-
workload_group: 'wg-123',
146-
},
147-
],
148-
},
127+
rules: [
128+
{
129+
id: 'keep-me',
130+
description: 'd',
131+
index_pattern: ['keep-*'],
132+
workload_group: 'wg-123',
133+
},
134+
{
135+
id: 'remove-me',
136+
description: 'd',
137+
index_pattern: ['remove-*'],
138+
workload_group: 'wg-123',
139+
},
140+
],
149141
});
150142
}
151143
// 3) GET stats (ignored here)
@@ -184,7 +176,7 @@ describe('WLMDetails Component', () => {
184176
it('handles no stats returned gracefully', async () => {
185177
(mockCore.http.get as jest.Mock)
186178
.mockImplementationOnce(() =>
187-
Promise.resolve({ body: { workload_groups: [{ name: 'test-group', _id: 'abc123' }] } })
179+
Promise.resolve({ workload_groups: [{ name: 'test-group', _id: 'abc123' }] })
188180
)
189181
.mockImplementationOnce(() => Promise.resolve({ body: {} }));
190182

@@ -220,7 +212,7 @@ describe('WLMDetails Component', () => {
220212
mockCore.http.get = jest.fn((path: string) => {
221213
if (path === '/api/_wlm/workload_group') {
222214
return Promise.resolve({
223-
body: { workload_groups: [{ name: 'test-group', _id: 'abc123' }] },
215+
workload_groups: [{ name: 'test-group', _id: 'abc123' }],
224216
});
225217
}
226218
if (path === '/api/_wlm/stats/abc123') {
@@ -243,16 +235,14 @@ describe('WLMDetails Component', () => {
243235
(mockCore.http.get as jest.Mock).mockImplementation((path: string) => {
244236
if (path.startsWith('/api/_wlm/workload_group')) {
245237
return Promise.resolve({
246-
body: {
247-
workload_groups: [
248-
{
249-
name: 'test-group',
250-
_id: 'abc123',
251-
resource_limits: { cpu: 0.5, memory: 0.5 },
252-
resiliency_mode: 'soft',
253-
},
254-
],
255-
},
238+
workload_groups: [
239+
{
240+
name: 'test-group',
241+
_id: 'abc123',
242+
resource_limits: { cpu: 0.5, memory: 0.5 },
243+
resiliency_mode: 'soft',
244+
},
245+
],
256246
});
257247
}
258248
if (path.startsWith('/api/_wlm/stats/abc123')) {
@@ -295,7 +285,7 @@ describe('WLMDetails Component', () => {
295285
(mockCore.http.get as jest.Mock).mockImplementation((path: string) => {
296286
if (path.includes('/_wlm/workload_group')) {
297287
return Promise.resolve({
298-
body: { workload_groups: [{ name: 'test-group', _id: 'abc123' }] },
288+
workload_groups: [{ name: 'test-group', _id: 'abc123' }],
299289
});
300290
}
301291
if (path.includes('/_wlm/stats/abc123')) {
@@ -661,15 +651,16 @@ describe('WLMDetails Component', () => {
661651
const [, options] = updateCalls[0];
662652
expect(options).toEqual(
663653
expect.objectContaining({
664-
query: { dataSourceId: 'default' },
665654
headers: { 'Content-Type': 'application/json' },
666-
body: JSON.stringify({
667-
description: 'd',
668-
index_pattern: ['keep-updated-*'],
669-
workload_group: 'wg-123',
670-
}),
655+
query: { dataSourceId: 'default' },
671656
})
672657
);
658+
const body = JSON.parse(options.body);
659+
expect(body).toEqual({
660+
description: '-',
661+
index_pattern: ['keep-updated-*'],
662+
workload_group: 'wg-123',
663+
});
673664
});
674665

675666
expect(mockCore.notifications.toasts.addSuccess).toHaveBeenCalled();

public/pages/WorkloadManagement/WLMDetails/WLMDetails.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ interface WorkloadGroup {
8585
}
8686

8787
interface WorkloadGroupByNameResponse {
88-
body: {
89-
workload_groups: WorkloadGroup[];
90-
};
91-
statusCode: number;
92-
headers: Record<string, string>;
93-
meta: any;
88+
workload_groups: WorkloadGroup[];
9489
}
9590

9691
interface NodeStats {
@@ -253,7 +248,7 @@ export const WLMDetails = ({
253248
const response = await core.http.get(`/api/_wlm/workload_group/${groupName}`, {
254249
query: { dataSourceId: dataSource.id },
255250
});
256-
const workload = response?.body?.workload_groups?.[0];
251+
const workload = response?.workload_groups?.[0];
257252
if (workload) {
258253
setGroupDetails({
259254
name: workload.name,
@@ -288,8 +283,7 @@ export const WLMDetails = ({
288283
query: { dataSourceId: dataSource.id },
289284
}
290285
);
291-
const matchedGroup = response.body?.workload_groups?.[0];
292-
286+
const matchedGroup = response?.workload_groups?.[0];
293287
if (!matchedGroup?._id) {
294288
throw new Error('Group ID not found');
295289
}
@@ -309,7 +303,7 @@ export const WLMDetails = ({
309303
const rulesRes = await core.http.get('/api/_rules/workload_group', {
310304
query: { dataSourceId: dataSource.id },
311305
});
312-
const allRules = rulesRes?.body?.rules ?? [];
306+
const allRules = rulesRes?.rules ?? [];
313307

314308
const matchedRules = allRules.filter((rule: any) => rule.workload_group === groupId);
315309

@@ -340,8 +334,7 @@ export const WLMDetails = ({
340334
const statsRes = await core.http.get(`/api/_wlm/stats/${groupId}`, {
341335
query: { dataSourceId: dataSource.id },
342336
});
343-
const stats: StatsResponse = statsRes.body ?? statsRes;
344-
337+
const stats: StatsResponse = statsRes;
345338
const nodeStatsList: NodeUsageData[] = [];
346339

347340
for (const [nodeId, data] of Object.entries(stats)) {

public/pages/WorkloadManagement/WLMMain/WLMMain.test.tsx

Lines changed: 36 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -52,61 +52,53 @@ beforeEach(() => {
5252
(mockCore.http.get as jest.Mock).mockImplementation((url: string) => {
5353
if (url === '/api/_wlm/workload_group') {
5454
return Promise.resolve({
55-
body: {
56-
workload_groups: [
57-
{ _id: 'group1', name: 'Group One', resource_limits: { cpu: 0.4, memory: 0.5 } },
58-
{ _id: 'group2', name: 'Group Two', resource_limits: { cpu: 0.6, memory: 0.7 } },
59-
{ _id: 'group3', name: 'Group Three', resource_limits: { cpu: 0.1, memory: 0.1 } },
60-
],
61-
},
55+
workload_groups: [
56+
{ _id: 'group1', name: 'Group One', resource_limits: { cpu: 0.4, memory: 0.5 } },
57+
{ _id: 'group2', name: 'Group Two', resource_limits: { cpu: 0.6, memory: 0.7 } },
58+
{ _id: 'group3', name: 'Group Three', resource_limits: { cpu: 0.1, memory: 0.1 } },
59+
],
6260
});
6361
}
6462
if (url === '/api/_wlm/stats') {
6563
return Promise.resolve({
66-
body: {
67-
node1: {
68-
workload_groups: {
69-
group1: {
70-
total_completions: 10,
71-
total_rejections: 2,
72-
total_cancellations: 1,
73-
cpu: { current_usage: 0.4 },
74-
memory: { current_usage: 0.3 },
75-
},
76-
group2: {
77-
total_completions: 5,
78-
total_rejections: 1,
79-
total_cancellations: 0,
80-
cpu: { current_usage: 0.5 },
81-
memory: { current_usage: 0.6 },
82-
},
83-
group3: {
84-
total_completions: 5,
85-
total_rejections: 1,
86-
total_cancellations: 0,
87-
cpu: { current_usage: 0.5 },
88-
memory: { current_usage: 0.6 },
89-
},
64+
node1: {
65+
workload_groups: {
66+
group1: {
67+
total_completions: 10,
68+
total_rejections: 2,
69+
total_cancellations: 1,
70+
cpu: { current_usage: 0.4 },
71+
memory: { current_usage: 0.3 },
72+
},
73+
group2: {
74+
total_completions: 5,
75+
total_rejections: 1,
76+
total_cancellations: 0,
77+
cpu: { current_usage: 0.5 },
78+
memory: { current_usage: 0.6 },
79+
},
80+
group3: {
81+
total_completions: 5,
82+
total_rejections: 1,
83+
total_cancellations: 0,
84+
cpu: { current_usage: 0.5 },
85+
memory: { current_usage: 0.6 },
9086
},
9187
},
92-
node2: {
93-
workload_groups: {
94-
group1: {
95-
total_completions: 5,
96-
total_rejections: 1,
97-
total_cancellations: 2,
98-
cpu: { current_usage: 0.25 },
99-
memory: { current_usage: 0.45 },
100-
},
88+
},
89+
node2: {
90+
workload_groups: {
91+
group1: {
92+
total_completions: 5,
93+
total_rejections: 1,
94+
total_cancellations: 2,
95+
cpu: { current_usage: 0.25 },
96+
memory: { current_usage: 0.45 },
10197
},
10298
},
10399
},
104100
});
105101
}
106-
if (url.startsWith('/api/_wlm/stats/')) {
107-
return Promise.resolve({ body: {} });
108-
}
109-
return Promise.resolve({ body: {} });
110102
});
111103
});
112104

@@ -207,21 +199,6 @@ describe('WorkloadManagementMain', () => {
207199
});
208200
});
209201

210-
it('handles case when no node is selected', async () => {
211-
(mockCore.http.get as jest.Mock).mockImplementation((url: string) => {
212-
if (url === '/api/_wlm_proxy/_nodes') {
213-
return Promise.resolve({ body: { nodes: {} } });
214-
}
215-
return Promise.resolve({ body: {} });
216-
});
217-
218-
renderComponent();
219-
220-
await waitFor(() => {
221-
expect(screen.getByPlaceholderText(/search workload groups/i)).toBeInTheDocument();
222-
});
223-
});
224-
225202
it('handles empty workload group list', async () => {
226203
(mockCore.http.get as jest.Mock).mockImplementation((url: string) => {
227204
if (url.includes('/workload_group')) {

public/pages/WorkloadManagement/WLMMain/WLMMain.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ export const WorkloadManagementMain = ({
283283
cpuRejectionThreshold: number;
284284
memoryRejectionThreshold: number;
285285
}>('/api/_wlm/thresholds');
286-
287286
const cpuThreshold = thresholds?.cpuRejectionThreshold ?? 1;
288287
const memoryThreshold = thresholds?.memoryRejectionThreshold ?? 1;
289288

@@ -336,14 +335,14 @@ export const WorkloadManagementMain = ({
336335
query: { dataSourceId: dataSource.id },
337336
});
338337

339-
return res.body as Record<string, NodeStats>;
338+
return res as Record<string, NodeStats>;
340339
}, [dataSource]);
341340

342341
const fetchWorkloadGroups = async () => {
343342
const res = await core.http.get('/api/_wlm/workload_group', {
344343
query: { dataSourceId: dataSource.id },
345344
});
346-
return res.body?.workload_groups ?? [];
345+
return res?.workload_groups ?? [];
347346
};
348347

349348
const computeBoxStats = (arr: number[]): number[] => {

0 commit comments

Comments
 (0)