Skip to content

Pagination for wlm/stats api #17638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add support for linux riscv64 platform ([#18156](https://github.com/opensearch-project/OpenSearch/pull/18156))
- [Rule based auto-tagging] Add get rule API ([#17336](https://github.com/opensearch-project/OpenSearch/pull/17336))
- [Rule based auto-tagging] Add Delete Rule API ([#18184](https://github.com/opensearch-project/OpenSearch/pull/18184))
- Add paginated wlm/stats API ([#17638](https://github.com/opensearch-project/OpenSearch/pull/17638))
- Implement parallel shard refresh behind cluster settings ([#17782](https://github.com/opensearch-project/OpenSearch/pull/17782))
- Bump OpenSearch Core main branch to 3.0.0 ([#18039](https://github.com/opensearch-project/OpenSearch/pull/18039))
- Update API of Message in index to add the timestamp for lag calculation in ingestion polling ([#17977](https://github.com/opensearch-project/OpenSearch/pull/17977/))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,8 @@ public void testApiNamingConventions() throws Exception {
"cluster.delete_weighted_routing",
"cluster.put_decommission_awareness",
"cluster.get_decommission_awareness",
"cluster.delete_decommission_awareness", };
"cluster.delete_decommission_awareness",
"wlm_stats_list" };
List<String> booleanReturnMethods = Arrays.asList("security.enable_user", "security.disable_user", "security.change_password");
Set<String> deprecatedMethods = new HashSet<>();
deprecatedMethods.add("indices.force_merge");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"wlm_stats_list": {
"stability": "experimental",
"documentation": {
"url": "https://docs.opensearch.org/docs/latest/tuning-your-cluster/availability-and-recovery/workload-management/wlm-feature-overview/",
"description": "This API endpoint returns a list of WLM stats with pagination support."
},
"url": {
"paths": [
{
"path": "/_list/wlm_stats",
"methods": ["GET"]
}
]
},
"params": {
"size": {
"type": "int",
"required": false,
"description": "Number of results per page"
},
"next_token": {
"type": "string",
"required": false,
"description": "Pagination token for next page"
},
"sort": {
"type": "string",
"required": false,
"description": "Sort field"
},
"order": {
"type": "string",
"required": false,
"description": "Sort order (asc or desc)"
},
"v": {
"type": "boolean",
"required": false,
"description": "Whether to include headers"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
"Custom size param still returns headers":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
wlm_stats_list:
size: 1
v: true
- is_true: $body
- match:
$body: /TOTAL_REJECTIONS/

---
"Sort by node_id asc does not error":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
wlm_stats_list:
sort: node_id
order: asc
- is_true: $body
- match:
$body: /DEFAULT_WORKLOAD_GROUP/

---
"Sort by workload_group_id desc does not error":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
wlm_stats_list:
sort: workload_group
order: desc
- is_true: $body
- match:
$body: /DEFAULT_WORKLOAD_GROUP/

---
"Invalid sort field returns error":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
catch: bad_request
wlm_stats_list:
sort: memory_usage
order: desc
- match:
error.reason: "Invalid value for 'sort'. Allowed: 'node_id', 'workload_group'"

---
"Invalid sort order returns error":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
catch: bad_request
wlm_stats_list:
order: upside_down
- match:
error.reason: "Invalid value for 'order'. Allowed: 'asc', 'desc'"

---
"Invalid token returns 400":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
catch: bad_request
wlm_stats_list:
next_token: "abcdef123456"

- match: { error: "Pagination state has changed (e.g., new workload groups added or removed). Please restart pagination from the beginning by omitting the 'next_token' parameter." }

---
"Default request returns 200 and contains expected keys":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
wlm_stats_list:
v: true
- is_true: $body
- match:
$body: /WORKLOAD_GROUP_ID/

---
"Max allowed size param returns success":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
wlm_stats_list:
size: 100
- is_true: $body

---
"Too large page size returns error":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
catch: bad_request
wlm_stats_list:
size: 1000
- match:
error.reason: "Invalid value for 'size'. Allowed range: 1 to 100"

---
"Negative page size returns error":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
catch: bad_request
wlm_stats_list:
size: -1
- match:
error.reason: "Invalid value for 'size'. Allowed range: 1 to 100"


---
"Sort param omitted uses default 'node_id'":
- skip:
version: " - 3.0.0"
reason: "wlm_stats_list API added after 3.0.0"
- do:
wlm_stats_list:
size: 1
v: true
- is_true: $body
- match:
$body: /NODE_ID/
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class WlmStatsResponse extends BaseNodesResponse<WlmStats> implements ToX
super(in);
}

WlmStatsResponse(ClusterName clusterName, List<WlmStats> nodes, List<FailedNodeException> failures) {
public WlmStatsResponse(ClusterName clusterName, List<WlmStats> nodes, List<FailedNodeException> failures) {
super(clusterName, nodes, failures);
}

Expand Down
Loading
Loading