Files
scylladb/test/cql-pytest
Nadav Har'El a0ffbf3291 test/cql-pytest: fix test that started failing after error message change
Recently a change to Scylla's expression implementation changed the standard
error message copied from Cassandra:

    Cannot execute this query as it might involve data filtering and thus
    may have unpredictable performance. If you want to execute this query
    despite the performance unpredictability, use ALLOW FILTERING

In the special case where the filter is on the partition key, we changed
the message to:

    Only EQ and IN relation are supported on the partition key (unless you
    use the token() function or allow filtering)

We had a cql-pytest test translated from Cassandra's unit test that checked
the old message, and started to fail. Unfortunately nobody noticed because
a bug in test.py caused it to stop running these translated unit tests.

So in this patch, we trivially fix the test to pass again. Instead of
insisting on the old message, we check jsut for the string "allow
filtering", in lowercase or uppercase. After this patch, the tests
passes as expected on both Scylla and Cassandra.

Refs #10918 (this test failing is one of the failures reported there)
Refs #10962 (test.py stopped running this test)

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

Closes #10964
2022-07-05 15:24:20 +03:00
..
2022-03-23 16:51:50 +02:00
2022-04-04 17:25:13 +03:00
2022-03-04 14:18:42 +01:00
2022-04-04 17:25:13 +03:00

Single-node functional tests for Scylla's CQL features.

These tests use the Python CQL library and the pytest frameworks. By using an actual CQL library for the tests, they can be run against any implementation of CQL - both Scylla and Cassandra. Most tests - except in rare cases - should pass on both, to ensure that Scylla is compatible with Cassandra in most features.

To run all tests against an already-running local installation of Scylla or Cassandra on localhost, just run pytest. The "--host" and "--port" can be used to give a different location for the running Scylla or Cassanra. The "--ssl" option can be used to use an encrypted (TLSv1.2) connection.

More conveniently, we have two scripts - "run" and "run-cassandra" - which do all the work necessary to start Scylla or Cassandra (respectively), and run the tests on them. The Scylla or Cassandra process is run in a temporary directory which is automatically deleted when the test ends.

"run" automatically picks the most recently compiled version of Scylla in build/*/scylla - but this choice of Scylla executable can be overridden with the SCYLLA environment variable. "run-cassandra" defaults to running the command cassandra from the user's path, but this can be overriden by setting the CASSANDRA environment variable to the path of the cassandra script, e.g., export CASSANDRA=$HOME/apache-cassandra-3.11.10/bin/cassandra. A few of the tests also require the nodetool when running on Cassandra - this tool is again expected to be in the user's path, or be overridden with the NODETOOL environment variable. Nodetool is not needed to test Scylla.

Additional options can be passed to "pytest" or to "run" / "run-cassandra" to control which tests to run:

  • To run all tests in a single file, do pytest test_table.py.
  • To run a single specific test, do pytest test_table.py::test_create_table_unsupported_names.
  • To run the same test or tests 100 times, add the --count=100 option. This is faster than running run 100 times, because Scylla is only run once, and also counts for you how many of the runs failed. For pytest to support the --count option, you need to install a pytest extension: pip install pytest-repeat

Additional useful pytest options, especially useful for debugging tests:

  • -v: show the names of each individual test running instead of just dots.
  • -s: show the full output of running tests (by default, pytest captures the test's output and only displays it if a test fails)