Files
scylladb/test/cql-pytest/run
Nadav Har'El 189ff5414f test/cql-pytest: implement test_tools.py without run-script cooperation
In commit afab1a97c6, we added
test_tools.py - tests for the various tools embedded in the Scylla
executable. These tests need to know where the Scylla executable is,
and also where its sstables are stored. For this, the commit added two
test parameters - "--scylla-path" and "--workdir" - with which the
"run" script communicated this knowledge to the test.

However, that implementation meant that these tests only work if the
test was run via the test/cql-pytest/run script - they won't work if
the user ran Scylla/pytest manually, or through some other script not
passing these options.

This patch drops the "--scylla-path" and "--workdir" parameters, and
instead the test figures out this information on its own:

1. To find the Scylla executable, we begin by looking (using the
   local_process_id(cql) function from the previous patch) for a
   local process which listens to our CQL connection, and then find
   the executable's path using /proc.

2. To find the Scylla data directory (which is what we really need, not
   workdir which is just a shortcut to set all directories!), we
   retrieve this configuration from the system.config table through CQL.

I tested that test_tools.py now works not only through test/cql-pytest/run
but also if I run Scylla manually and then run "pytest test_tools.py"
without any extra parameters.

Fixes #10209

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
Message-Id: <20220314151125.2737815-2-nyh@scylladb.com>
2022-03-14 20:25:22 +02:00

45 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
import sys
import run # run.py in this directory
print('Scylla is: ' + run.scylla + '.')
ssl = '--ssl' in sys.argv
if ssl:
cmd = run.run_scylla_ssl_cql_cmd
check_cql = run.check_ssl_cql
else:
cmd = run.run_scylla_cmd
check_cql = run.check_cql
# If the "--raft" option is given, switch to the experimental Raft-based
# implementation of schema operations. Some tests are expected to fail
# when not in raft mode, so they use the fails_without_raft fixture
# that will cause them to xfail when raft isn't used.
if '--raft' in sys.argv:
sys.argv.remove('--raft')
def run_with_raft(pid, dir):
(c, e) = run_with_raft.orig_cmd(pid, dir)
return (c + ['--experimental-features=raft'], e)
run_with_raft.orig_cmd = cmd
cmd = run_with_raft
pid = run.run_with_temporary_dir(cmd)
ip = run.pid_to_ip(pid)
run.wait_for_services(pid, [
lambda: run.check_rest_api(ip),
lambda: check_cql(ip)
])
success = run.run_pytest(sys.path[0], ['--host=' + ip] + sys.argv[1:])
run.summary = 'Scylla tests pass' if success else 'Scylla tests failure'
exit(0 if success else 1)
# Note that the run.cleanup_all() function runs now, just like on any exit
# for any reason in this script. It will delete the temporary files and
# announce the failure or success of the test (printing run.summary).