mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-28 10:41:12 +00:00
test.py: dtest: make bypass_cache_test.py run using test.py
As a part of the porting process, copy missed utility functions from scylla-dtest, remove unused imports and markers, and add single_node marker description to pytest.ini Enable the test in suite.yaml (run in dev mode only)
This commit is contained in:
@@ -14,17 +14,13 @@ import pytest
|
||||
|
||||
from dtest_class import Tester, create_cf, create_ks, get_ip_from_node
|
||||
from tools.data import create_c1c2_table, insert_c1c2
|
||||
from tools.marks import issue_open
|
||||
from tools.metrics import get_node_metrics
|
||||
from tools.session import get_supported_features
|
||||
|
||||
logger = logging.getLogger(__file__)
|
||||
NUM_OF_QUERY_EXECUTIONS = 100
|
||||
|
||||
|
||||
@pytest.mark.dtest_full
|
||||
@pytest.mark.single_node
|
||||
@pytest.mark.next_gating
|
||||
class TestBypassCache(Tester):
|
||||
"""
|
||||
Test that will verify if the select statement will skip cache during its read
|
||||
@@ -175,7 +171,7 @@ class TestBypassCache(Tester):
|
||||
session.execute(query.format(idx, varchar_c, varchar_v))
|
||||
return session
|
||||
|
||||
@pytest.mark.skip_if(issue_open("#6045"))
|
||||
@pytest.mark.skip(reason="https://github.com/scylladb/scylladb/issues/6045")
|
||||
def test_range_scan_bypass_cache(self):
|
||||
session = self.insert_data_for_scan_range()
|
||||
node = self.cluster.nodelist()[0]
|
||||
|
||||
47
test/cluster/dtest/tools/data.py
Normal file
47
test/cluster/dtest/tools/data.py
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# Copyright (C) 2025-present ScyllaDB
|
||||
#
|
||||
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
||||
#
|
||||
|
||||
import logging
|
||||
|
||||
from cassandra import ConsistencyLevel
|
||||
from cassandra.concurrent import execute_concurrent_with_args
|
||||
|
||||
from test.cluster.dtest.dtest_class import create_cf
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def create_c1c2_table(session, cf="cf", read_repair=None, debug_query=True, compaction=None, caching=True, speculative_retry=None): # noqa: PLR0913
|
||||
create_cf(session, cf, columns={"c1": "text", "c2": "text"}, read_repair=read_repair, debug_query=debug_query, compaction=compaction, caching=caching, speculative_retry=speculative_retry)
|
||||
|
||||
|
||||
def insert_c1c2( # noqa: PLR0913
|
||||
session,
|
||||
keys=None,
|
||||
n=None,
|
||||
consistency=ConsistencyLevel.QUORUM,
|
||||
c1_values=None,
|
||||
c2_values=None,
|
||||
ks="ks",
|
||||
cf="cf",
|
||||
concurrency=20,
|
||||
):
|
||||
if (keys is None and n is None) or (keys is not None and n is not None):
|
||||
raise ValueError(f"Expected exactly one of 'keys' or 'n' arguments to not be None; got keys={keys}, n={n}")
|
||||
if (not c1_values and c2_values) or (c1_values and not c2_values):
|
||||
raise ValueError('Expected the "c1_values" and "c2_values" variables be empty or contain list of string')
|
||||
if n:
|
||||
keys = list(range(n))
|
||||
if c1_values and c2_values:
|
||||
statement = session.prepare(f"INSERT INTO {ks}.{cf} (key, c1, c2) VALUES (?, ?, ?)")
|
||||
statement.consistency_level = consistency
|
||||
execute_concurrent_with_args(session, statement, map(lambda x, y, z: [f"k{x}", y, z], keys, c1_values, c2_values), concurrency=concurrency)
|
||||
else:
|
||||
statement = session.prepare(f"INSERT INTO {ks}.{cf} (key, c1, c2) VALUES (?, 'value1', 'value2')")
|
||||
statement.consistency_level = consistency
|
||||
|
||||
execute_concurrent_with_args(session, statement, [[f"k{k}"] for k in keys], concurrency=concurrency)
|
||||
31
test/cluster/dtest/tools/metrics.py
Normal file
31
test/cluster/dtest/tools/metrics.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Copyright (C) 2025-present ScyllaDB
|
||||
#
|
||||
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
||||
#
|
||||
|
||||
import re
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def prometheus_get(ip, port="9180"):
|
||||
prometheus_url = f"http://{ip}:{port}/metrics"
|
||||
resp = requests.get(prometheus_url)
|
||||
resp.raise_for_status()
|
||||
return resp.text
|
||||
|
||||
|
||||
def get_node_metrics(node_ip: str, metrics: list[str], port="9180"):
|
||||
metrics_res = {k: 0 for k in metrics}
|
||||
filter_metrics = [metric for metric in prometheus_get(node_ip, port).splitlines() if not metric.startswith("#")]
|
||||
for metric in filter_metrics:
|
||||
for metric_name in metrics:
|
||||
if re.search(metric_name, metric):
|
||||
val = metric.split()[-1]
|
||||
try:
|
||||
val = int(val)
|
||||
except ValueError:
|
||||
val = float(val)
|
||||
metrics_res[metric_name] += val
|
||||
return metrics_res
|
||||
@@ -24,16 +24,12 @@ run_first:
|
||||
skip_in_release:
|
||||
- test_raft_cluster_features
|
||||
- test_cluster_features
|
||||
- dtest/bypass_cache_test
|
||||
skip_in_dev:
|
||||
- dtest/bypass_cache_test
|
||||
skip_in_debug:
|
||||
- test_shutdown_hang
|
||||
- test_replace
|
||||
- test_node_shutdown_waits_for_pending_requests
|
||||
- test_cdc_generation_clearing
|
||||
- test_cdc_generation_publishing
|
||||
- dtest/bypass_cache_test
|
||||
run_in_release:
|
||||
- test_gossiper
|
||||
run_in_dev:
|
||||
@@ -46,5 +42,6 @@ run_in_dev:
|
||||
- test_replace_alive_node
|
||||
- dtest/error_example_test
|
||||
- dtest/alternator_tests
|
||||
- dtest/bypass_cache_test
|
||||
run_in_debug:
|
||||
- random_failures/test_random_failures
|
||||
|
||||
@@ -14,6 +14,8 @@ markers =
|
||||
cpp: marker for c++ tests
|
||||
prepare_3_nodes_cluster: prepare 3 nodes cluster for test case based on suite.yaml (all tests from old topology folder)
|
||||
prepare_3_racks_cluster: prepare 3 nodes cluster in 1 dc and 3 racks for test case based on suite.yaml
|
||||
single_node: test that are mark like this, should be using only one node, and should boot much quicker (dtest only)
|
||||
|
||||
norecursedirs = manual perf lib
|
||||
# Ignore warnings about HTTPS requests without certificate verification
|
||||
# (see issue #15287). Pytest breaks urllib3.disable_warnings() in conftest.py,
|
||||
|
||||
Reference in New Issue
Block a user