404 changes: 404 additions & 0 deletions test/pylib/scylla_server.py

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions test/pylib/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (C) 2022-present ScyllaDB
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
import time

unique_name_prefix = 'test_'


def unique_name():
current_ms = int(round(time.time() * 1000))
# If unique_name() is called twice in the same millisecond...
if unique_name.last_ms >= current_ms:
current_ms = unique_name.last_ms + 1
unique_name.last_ms = current_ms
return unique_name_prefix + str(current_ms)


unique_name.last_ms = 0
3 changes: 2 additions & 1 deletion test/rest_api/suite.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
type: Run
type: Python
pool_size: 1
239 changes: 0 additions & 239 deletions test/tools/cql_repl.cc

This file was deleted.

15 changes: 15 additions & 0 deletions test/topology/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (C) 2022-present ScyllaDB
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This file configures pytest for all tests in this directory, and also
# defines common test fixtures for all of them to use

import pathlib
import sys

# Add test.pylib to the search path
sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))


6 changes: 6 additions & 0 deletions test/topology/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Pytest configuration file. If we don't have one in this directory,
# pytest will look for one in our ancestor directories, and may find
# something irrelevant. So we should have one here, even if empty.
[pytest]
# Use shared fixtures from the parent dir
addopts = --confcutdir ..
7 changes: 7 additions & 0 deletions test/topology/suite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: Python
pool_size: 4
topology:
class: Simple
replication_factor: 3
disable:
- test_null
26 changes: 26 additions & 0 deletions test/topology/test_null.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (C) 2022-present ScyllaDB
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
from cassandra.protocol import InvalidRequest # type: ignore
from pylib.util import unique_name
import pytest


@pytest.fixture(scope="module")
def table1(cql, test_keyspace):
table = test_keyspace + "." + unique_name()
cql.execute(f"CREATE TABLE {table} (p text, c text, v text, primary key (p, c))")
yield table
cql.execute("DROP TABLE " + table)


def test_delete_empty_string_key(cql, table1):
s = "foobar"
# An empty-string clustering *is* allowed:
cql.execute(f"DELETE FROM {table1} WHERE p='{s}' AND c=''")
# But an empty-string partition key is *not* allowed, with a specific
# error that a "Key may not be empty":
with pytest.raises(InvalidRequest, match='Key may not be empty'):
cql.execute(f"DELETE FROM {table1} WHERE p='' AND c='{s}'")