Skip to content

Commit

Permalink
feature(adaptive_timeouts): collect number of db nodes
Browse files Browse the repository at this point in the history
since in some cases we will want to use that number
as a scale for selecting timeouts
so we'll start collecting it now
  • Loading branch information
fruch committed Jan 3, 2024
1 parent dfa8868 commit 0f1ff5d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions sdcm/utils/adaptive_timeouts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ class Operations(Enum):
("timeout", "service_level_for_test_step"))


class TestInfoServices: # pylint: disable=too-few-public-methods
@staticmethod
def get(node: "BaseNode") -> dict:
return dict(
n_db_nodes=len(node.parent_cluster.nodes),
)


@contextmanager
def adaptive_timeout(operation: Operations, node: "BaseNode", stats_storage: AdaptiveTimeoutStore = ESAdaptiveTimeoutStore(), **kwargs):
"""
Expand All @@ -87,6 +95,7 @@ def adaptive_timeout(operation: Operations, node: "BaseNode", stats_storage: Ada
assert arg in kwargs, f"Argument '{arg}' is required for operation {operation.name}"
args[arg] = kwargs[arg]
timeout, load_metrics = operation.value[1](node_info_service=NodeLoadInfoServices().get(node), **args)
load_metrics = load_metrics | TestInfoServices.get(node)
start_time = time.time()
timeout_occurred = False
try:
Expand Down
3 changes: 2 additions & 1 deletion unit_tests/test_adaptive_timeouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from sdcm.remote import RemoteCmdRunnerBase
from sdcm.utils.adaptive_timeouts.load_info_store import AdaptiveTimeoutStore
from sdcm.utils.adaptive_timeouts import Operations, adaptive_timeout
from unit_tests.lib.fake_remoter import FakeRemoter
from unit_tests.test_cluster import DummyDbCluster

LOGGER = logging.getLogger(__name__)

Expand All @@ -34,6 +34,7 @@ def __init__(self, name: str, remoter):
self.name = name
self.remoter = remoter
self.scylla_version_detailed = "2042.1.12-0.20220620.e23889f17"
self.parent_cluster = DummyDbCluster(nodes=[self], params={'n_db_nodes': 1})


class MemoryAdaptiveTimeoutStore(AdaptiveTimeoutStore):
Expand Down

0 comments on commit 0f1ff5d

Please sign in to comment.