Files
scylladb/test/cqlpy/test_guardrail_compact_storage.py
Nadav Har'El e75c75f8cd test/cqlpy: fix two tests that couldn't fail because of typo
As noticed by copilot, two tests in test_guardrail_compact_storage.py
could never fail, because they used `pytest.fail` instead of the
correct `pytest.fail()` to fail. Unfortunately, Python has a footgun
where if it sees a bare function name without parenthesis, instead of
complaining it evaluates the function object and then ignores it,
and absolutely nothing happens.

So let's add the missing `()`. The test still passes, but now it at
least has a chance of failing if we have a regression.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>

Closes scylladb/scylladb#27658
2025-12-24 06:49:54 +02:00

34 lines
1.5 KiB
Python

import pytest
from cassandra.protocol import InvalidRequest
from .util import config_value_context, new_test_table
# Tests for the enable_create_table_with_compact_storage guardrail.
# Because this feature does not exist in Cassandra , *all* tests in this file are
# Scylla-only. Let's mark them all scylla_only with an autouse fixture:
@pytest.fixture(scope="function", autouse=True)
def all_tests_are_scylla_only(scylla_only):
pass
def test_create_table_with_compact_storage_default_config(cql, test_keyspace):
# enable_create_table_with_compact_storage is now disabled in db/config
try:
with new_test_table(cql, test_keyspace, schema="p int PRIMARY KEY, v int", extra="WITH COMPACT STORAGE") as test_table:
pytest.fail()
except InvalidRequest:
pass
@pytest.mark.parametrize("enable_compact_storage", [False, True])
def test_create_table_with_compact_storage_config(cql, test_keyspace, enable_compact_storage):
with config_value_context(cql, 'enable_create_table_with_compact_storage', str(enable_compact_storage).lower()):
try:
with new_test_table(cql, test_keyspace, schema="p int PRIMARY KEY, v int", extra="WITH COMPACT STORAGE") as test_table:
if not enable_compact_storage:
pytest.fail()
except InvalidRequest:
# expected to throw InvalidRequest only when
# enable_create_table_with_compact_storage=false
if enable_compact_storage:
pytest.fail()