-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust default values for ClickHousePlugin parameters
Calculate the default value for max_concurrent_ parameters based on the number of Clickhouse nodes.
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Copyright (c) 2023 Aiven Ltd | ||
See LICENSE for details | ||
""" | ||
from astacus.coordinator.plugins.clickhouse.config import ClickHouseConfiguration, ClickHouseNode | ||
from astacus.coordinator.plugins.clickhouse.plugin import ClickHousePlugin | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"property", | ||
[ | ||
"max_concurrent_create_databases", | ||
"max_concurrent_drop_databases", | ||
"max_concurrent_restart_replica", | ||
"max_concurrent_restore_replica", | ||
"max_concurrent_attach", | ||
"max_concurrent_sync", | ||
], | ||
) | ||
def test_max_concurrent_queries_params_have_default_values(property: str) -> None: | ||
plugin = ClickHousePlugin( | ||
clickhouse=ClickHouseConfiguration( | ||
nodes=[ | ||
ClickHouseNode(host="host", port=4242), | ||
ClickHouseNode(host="host", port=4242), | ||
ClickHouseNode(host="host", port=4242), | ||
] | ||
) | ||
) | ||
assert getattr(plugin, property) == 30 | ||
|
||
|
||
def test_max_concurrent_queries_params_accept_explicit_values() -> None: | ||
plugin = ClickHousePlugin( | ||
max_concurrent_create_databases=1, | ||
max_concurrent_drop_databases=2, | ||
max_concurrent_restart_replica=3, | ||
max_concurrent_restore_replica=4, | ||
max_concurrent_attach=5, | ||
max_concurrent_sync=6, | ||
clickhouse=ClickHouseConfiguration( | ||
nodes=[ | ||
ClickHouseNode(host="host", port=4242), | ||
ClickHouseNode(host="host", port=4242), | ||
ClickHouseNode(host="host", port=4242), | ||
] | ||
), | ||
) | ||
assert plugin.max_concurrent_create_databases == 1 | ||
assert plugin.max_concurrent_drop_databases == 2 | ||
assert plugin.max_concurrent_restart_replica == 3 | ||
assert plugin.max_concurrent_restore_replica == 4 | ||
assert plugin.max_concurrent_attach == 5 | ||
assert plugin.max_concurrent_sync == 6 |