Skip to content
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

Added runners for enabling concurrent segment search via settings #591

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
15 changes: 15 additions & 0 deletions osbenchmark/worker_coordinator/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def register_default_runners():
register_runner(workload.OperationType.DeployMlModel, Retry(DeployMlModel()), async_runner=True)
register_runner(workload.OperationType.TrainKnnModel, Retry(TrainKnnModel()), async_runner=True)
register_runner(workload.OperationType.DeleteKnnModel, Retry(DeleteKnnModel()), async_runner=True)
register_runner(workload.OperationType.EnableConcurrentSegmentSearch, Retry(EnableConcurrentSegmentSearch()), async_runner=True)

def runner_for(operation_type):
try:
Expand Down Expand Up @@ -2696,3 +2697,17 @@ async def __call__(self, opensearch, params):

def __repr__(self, *args, **kwargs):
return "deploy-ml-model"

class EnableConcurrentSegmentSearch(Runner):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: What do you think about naming as UpdateConcurrentSegmentSearchClusterSettings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, makes sense if we're adding the slice count param

@time_func
async def __call__(self, opensearch, params):
enable_setting = params.get("enable", "false")
body = {
"persistent": {
"search.concurrent_segment_search.enabled": enable_setting
}
}
await opensearch.cluster.put_settings(body=body)

def __repr__(self, *args, **kwargs):
return "enable-concurrent-segment-search"
3 changes: 3 additions & 0 deletions osbenchmark/workload/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ class OperationType(Enum):
DeleteMlModel = 1041
RegisterMlModel = 1042
DeployMlModel = 1043
EnableConcurrentSegmentSearch = 1044

@property
def admin_op(self):
Expand Down Expand Up @@ -752,6 +753,8 @@ def from_hyphenated_string(cls, v):
return OperationType.TrainKnnModel
elif v == "delete-knn-model":
return OperationType.DeleteKnnModel
elif v == "enable-concurrent-segment-search":
return OperationType.EnableConcurrentSegmentSearch
else:
raise KeyError(f"No enum value for [{v}]")

Expand Down
20 changes: 20 additions & 0 deletions tests/worker_coordinator/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6785,3 +6785,23 @@ async def test_param_id_mandatory(self, opensearch, on_client_request_start, on_
await r(opensearch, params)

self.assertEqual(0, opensearch.transport.perform_request.call_count)

class EnableConcurrentSegmentSearchTests(TestCase):
@mock.patch('osbenchmark.client.RequestContextHolder.on_client_request_end')
@mock.patch('osbenchmark.client.RequestContextHolder.on_client_request_start')
@mock.patch("opensearchpy.OpenSearch")
@run_async
async def test_enable_concurrent_segment_search(self, opensearch, on_client_request_start, on_client_request_end):
opensearch.cluster.put_settings.return_value = as_future()
params = {
"enable": "true"
}

r = runner.EnableConcurrentSegmentSearch()
await r(opensearch, params)

opensearch.cluster.put_settings.assert_called_once_with(body={
"persistent": {
"search.concurrent_segment_search.enabled": "true"
}
})
Loading