Commit Graph

391 Commits

Author SHA1 Message Date
Konstantin Osipov
a645bb3622 test.py: recursively search for pytests
cql-pytest contains subdirectories with tests
ported from Cassandra. It's desirable to preserve
the same layout and file names for these tests as in
the original source tree. To do that, add support for recursive
search of tests to PythonTestSuite. The log files for
the tests which are found recursively are created in subdirs
of the test tmpdir.

While implementing the feature, switch to using pathlib,
since a) it supports rglob (recursive glob) and b) it
was requested in one of the earlier reviews.

Closes #11018
2022-07-13 14:59:29 +03:00
Konstantin Osipov
d5d748ae86 test.py: extend xml output with logs
Add test and server logs, as well as the unidiff, to
XML output. This makes jenkins reports nicer.

While on it, debug & fix bugs in handling of flaky tests:

- the reset would reset a flaky test even after the last attempt
  fails, so it would be impossible to see what happened to it
- the args needed to be reset as well, since execution modifies
  them
- we would say that we're going to retry the flaky test when in
  fact it was the last attempt to run it and no more retries were
  planned
2022-06-28 18:22:01 +03:00
Konstantin Osipov
22d30abed8 test.py: log what cluster is used for a test 2022-06-28 18:22:01 +03:00
Konstantin Osipov
c4bee2860b test.py: use test uname, not id, in log output
Clarify "Test was cancelled" error message.
2022-06-28 18:22:01 +03:00
Konstantin Osipov
b502dd3c4e test.py: support --log-level option and pass it to logging module
scylla-python driver and scylla_server.py can be more verbose
at higher log levels, allow specifying the log level from the command
line.
2022-06-28 18:22:01 +03:00
Konstantin Osipov
867d5b4eda test.py: don't capture pytest output
Let print()s inside pytest tests go into pytest logs. This simplifies
debugging, especially if someone is not familiar with pytest.
2022-06-28 17:46:47 +03:00
Konstantin Osipov
fd3d08e560 test.py: add type annotations
Add type annotations where possible.
2022-06-28 17:46:47 +03:00
Konstantin Osipov
2470b1d888 test.py: convert log_filename to pathlib 2022-06-28 17:46:47 +03:00
Konstantin Osipov
20070e2d89 test.py: please linter
Rename the static method to not collied with a member variable
with the same name.
2022-06-28 17:46:46 +03:00
Konstantin Osipov
fc232099bb test.py: remove mypy warnings 2022-06-28 17:46:46 +03:00
Raphael S. Carvalho
f15a6ce41a tests: Introduce optional RNG seed for boost suite
Today, if you want to reproduce a rare condition using the same RNG seed
reported, you cannot use test.py which provides useful infrastructure
and will have to run the tests manually instead.
So let's extend test.py to allow optional forwarding of RNG seed to
boost tests only, as other suites don't support the seed option.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
Message-Id: <20220615223657.142110-1-raphaelsc@scylladb.com>
2022-06-20 07:19:08 +03:00
Konstantin Osipov
8036d19b84 test.py: add support for flaky tests
The idea is that a flaky test can be marked as flaky
rather than disabled to make sure it passes in CI.
This reduces chances of a regression being added
while the flakiness is being resolved and the number
of disabled tests doesn't grow.
2022-06-10 14:10:21 +03:00
Konstantin Osipov
4cf63efe6c test.py: make Test hierarchy resettable
Introduce reset() hierarchy, which is similar to __init__(),
i.e. allows to reset test execution state before retrying it.
Useful for retrying flaky tests.
2022-06-10 14:10:21 +03:00
Konstantin Osipov
ad01840117 test.py: workaround for a python bug
Workaround for a Python3 bug which prevents a correct
exception printout when asyncio is used with logging on.
2022-05-25 20:26:42 +03:00
Konstantin Osipov
dd633cdb21 test.py: respect --verbose even if output is a tty
If output is a not a tty, verbose is set automatically.

If the output is a tty, one has to request --verbose.

However, a part of test.py verbosity was ignoring --verbose
and looking only at the terminal type.
2022-05-25 20:26:42 +03:00
Konstantin Osipov
9512e076af test: remove tools/cql_repl
Remove tools/cql_repl from the source, build targets and
use in test.py. Superseded by ApprovalTest and
test/pylib/cql_repl/cql_repl.py.
2022-05-25 20:26:42 +03:00
Konstantin Osipov
405517bc1b test.py: implement CQL approval tests over pytest
Before this patch, approval tests (test/cql/*) were using a C++
application called cql_repl, which is a seastar app running
Scylla, reading commands from the standard input and producing
results in Json format in the standard output. The rationale for
this was to avoid running a standalone Scylla which could leak
more resources such as open sockets.

Now that other suites already start and stop Scylla servers, it
makes more sense to run CQL commands in approval tests against an
existing running server. It saves us from building a one more
binary and allows to better format the output. Specifically, we
would like to see Scylla output in tabular format in approval
tests, which is difficult to do when C++ formatting libraries
are used.
2022-05-25 20:26:42 +03:00
Konstantin Osipov
bc719209ee test.py: introduce PythonTest and PythonTestSuite
PythonTest and PythonTestSuite allow to use test.py-managed
scylla servers (or clusters) to run pytest tests.
2022-05-25 20:26:42 +03:00
Konstantin Osipov
1a74828834 test.py: use artifact registry
Track running tests in the suite.
Cleanup after each suite (after all tests
in the suite end).
Cleanup all artifacts before exit.  Don't drop server logs if
there is at least one failed test.
2022-05-25 20:26:42 +03:00
Konstantin Osipov
dee6da53b3 test.py: highlight the failure cause
Use color palette to highlight the exception which aborted
the harness.
2022-02-04 17:15:52 +03:00
Konstantin Osipov
56aaabfa31 test.py: clean up setting of scylla executable
Now that suites are per mode, set scylla executable
path once per suite, not once per test.
Ditto for scylla env.
2022-02-04 17:15:52 +03:00
Konstantin Osipov
e9ec69494e test.py: speed up search for tests cases, use async
Search for test cases in parallel.
This speeds up the search for test cases from 30 to 4-5
seconds in absence of test case cache and from 4 to 3
seconds if case cache is present.
2022-02-04 17:15:52 +03:00
Konstantin Osipov
45270f5ad2 test.py: make case cache global
test.py runs each unit test's test case in a separate process.
The list of test cases is built at start, by running --list-cases
for each unit test. The output is cached, so that if one uses --repeat
option, we don't list the cases again and again.

The cache, however, was only useful for --repeat, because it was only
caching the last tests' output, not all tests output, so if I, for example,
run tests like:

./test.py foo bar foo

.. the cache was unused. Make the cache global which simplifies its
logic and makes it work in more cases.
2022-02-04 16:47:35 +03:00
Konstantin Osipov
445f90dc3b test.py: make --cpus option work on Ubuntu
The used API is only available in python3, so use it explicitly.
2022-02-04 16:16:17 +03:00
Konstantin Osipov
60fde39880 test.py: create an own TestSuite instance for each path/mode combo
To run tests in a given mode we will need to start off scylla
clusters, which we would want to pool and reuse between many tests.
TestSuite class was designed to share resources of common tests.
One can't pool together scylla servers compiled with different
tests, so create an own TestSuite instance for each mode.
2022-02-04 16:16:17 +03:00
Konstantin Osipov
efd7b9f4a3 test.py: do not fail entire run if list-content fails due to ASAN
If list-content of one test fails with ASAN error, do not abort.
2022-02-04 16:16:17 +03:00
Konstantin Osipov
c63e0ee271 test.py: print subtest name on cancel 2022-02-04 16:16:17 +03:00
Konstantin Osipov
8cc7c1a5bb test.py: fix flake8 complaints
It's good practice to use linters and style formatters for
all scripted languages. Python community is more strict
about formatting guidelines than others, and using
formatters (like flake8 or black) is almost universally
accepted.

test.py was adhering to flake8 standards at some point,
but later this was spoiled by random commits.
2022-02-04 16:16:17 +03:00
Avi Kivity
fcb8d040e8 treewide: use Software Package Data Exchange (SPDX) license identifiers
Instead of lengthy blurbs, switch to single-line, machine-readable
standardized (https://spdx.dev) license identifiers. The Linux kernel
switched long ago, so there is strong precedent.

Three cases are handled: AGPL-only, Apache-only, and dual licensed.
For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0),
reasoning that our changes are extensive enough to apply our license.

The changes we applied mechanically with a script, except to
licenses/README.md.

Closes #9937
2022-01-18 12:15:18 +01:00
Avi Kivity
ef3edcf848 test: refine test suite names exposed via xunit format
The test suite names seen by Jenkins are suboptimal: there is
no distinction between modes, and the ".cc" suffix of file names
is interpreted as a class name, which is converted to a tree node
that must be clicked to expand. Massage the names to remove
unnecessary information and add the mode.

Closes #9696
2021-12-02 09:58:58 +02:00
Avi Kivity
b23af15432 tests: consolidate boost xunit result files
The recent parallelization of boost unit tests caused an increase
in xml result files. This is challenging to Jenkins, since it
appears to use rpc-over-ssh to read the result files, and as a result
it takes more than an hour to read all result files when the Jenkins
main node is not on the same continent as the agent.

To fix this, merge the result files in test.py and leave one result
file per mode. Later we can leave one result file overall (integrating
the mode into the testsuite name), but that can wait.

Tested on a local Jenkins instance (just reading the result files,
not the entire build).

Closes #9668
2021-11-28 22:12:52 +02:00
Pavel Emelyanov
dcefe98fbb test.py: Add --cpus option
The option accepts taskset-style cpulist and limits the launched tests
respectively. When specified, the default number of jobs is adjusted
accordingly, if --jobs is given it overrides this "default" as expected.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-11-23 11:08:41 +03:00
Pavel Emelyanov
0246841c5e test.py: Lazily calculate args.jobs
Next patch will need to know if the --jobs option was specified or the
caller is OK with the default. One way to achieve it is to keep 0 as the
default and set the default value afterwards.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-11-23 11:05:56 +03:00
Pavel Emelyanov
d1679b66f2 test.py: Run parallel cases by default
There were few missing bits before making this the default.

- default max number of AIOs, now tests are run with the greatly
  reduced value

- 1.5 hours single case from database_test, now it's split and
  scales with --parallel-cases

- suite add_test methods called in a loop for --repeat options,
  patch #1 from this set fixes it

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-11-04 10:47:13 +03:00
Pavel Emelyanov
0d0ccd50b5 test.py: Cache collected test-cases
The add_test method of a siute can be called several times in a
row e.g. in case of --repeat option or because there are more
than one custom_args entries in the suite.yaml file. In any case
it's pointless to re-collect the test cases by launching the
test binary again, it's much faster (and 100% safe) to keep the
list of cases from the previous call and re-use it if the test
name matches.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-11-04 10:47:13 +03:00
Pavel Emelyanov
4f4b863e6a test.py: Always disable boost colored output
Tests' output is always redirected to a log file. Enabling colored
output makes it very hard to read.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Message-Id: <20210730083731.17813-1-xemul@scylladb.com>
2021-07-30 12:22:31 +03:00
Avi Kivity
2cfc517874 main, test: adjust number of networking iocbs
Seastar's default limit of 10,000 iocbs per shard is too low for
some workload (it places an upper bound on the number of idle
connections, above which a crash occurs). Use the new Seastar
feature to raise the default to 50000.

Also multiply the global reservation by 5, and round it upwards
so the number is less weird. This prevents io_setup() from failing.

For tests, the reservation is reduced since they don't create large
numbers of connections. This reduces surprise test failures when they
are run on machines that haven't been adjusted.

Fixes #9051

Closes #9052
2021-07-18 14:38:44 +03:00
Pavel Emelyanov
cbb4837b77 test.py: Parallelize test-cases run (for boost tests)
The parallelizm is acheived by listing the content of each (boost)
test and by adding a test for each case found appending the
'--run_test={case_name}' option.

Also few tests (logallog and memtable) have cases that depend on
each other (the former explicitly stated this in the head comment),
so these are marked as "no_parallel_cases" in the suite.yaml file.

In dev mode tests need 2m:5s to run by default. With parallelizm
(and updated long-running tests list) -- 1m 35s.

In debug mode there are 6 slow _cases_ that overrun 30 minutes.
They finish last and deserve some special (incremental) care. All
the other tests run ~1h by default vs ~25m in parallel.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-07-16 17:25:07 +03:00
Pavel Emelyanov
3cac5173b7 test.py: Prepare BoostTest for running individual cases
This means adding the casename argument to its describing class
and handling it:

1. appending to the shortname
2. adding the --run_test= argument to boost args

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-07-16 17:25:07 +03:00
Pavel Emelyanov
0baee5d423 test.py: Prepare TestSuite::create_test() for parallelizm
The method in question is in charge of creating a single
entry in the list of tests to be run. The BoostTestSuite's
method is about to create several entries and this patch
prepares it for this:

- makes it distinguish individual arguments
- lets it select the test.id value itself

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-07-16 17:25:07 +03:00
Pavel Emelyanov
a547677502 test.py: Treat shortname as composite
When running tests in parallel-cases mode the test.uname must
include the case name to make different log and xml files for
different runs and to show which exact case is run when shown
by the tabular-output. At the same time the test shortname
identifies the binary with the whole test.

This patch makes class Test treat the shortname argument as
a dot-separated string where the 0th component is the binary
with the test and the rest is how test identifies itself.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-07-16 17:25:07 +03:00
Pavel Emelyanov
f188dd3396 test.py: Reformat tabluar output
This change solves several issues that would arise with the
case-by-case run.

First, the currently printed name is "$binary_name.$id". For
case-by-case run the binary name would coinside for many cases
and it will be inconvenient to identify the test case. So
the tests uname is printed instead.

Second, the tests uname doesn't contain suite name (unlike the
test binary name which does), so this patch also adds the
explicit suite name back as a separate column (like MODE)

Third, the testname + casename string length will be far above
the allocated 50 characters, so the test name is moved at the
tail of the line.

Fourth, the total number of cases is 2100+, the field of 7
characters is not enough to print it, so it's extended.

Finally the test.py output would look like this for parallel run:
================================================================================
[N/TOTAL]   SUITE    MODE   RESULT   TEST
------------------------------------------------------------------------------
[1/2108]     raft     dev   [ PASS ] etcd_test.test_progress_leader.40 0.06s
[2/2108]     raft     dev   [ PASS ] etcd_test.test_vote_from_any_state.45 0.03s
[3/2108]     raft     dev   [ PASS ] etcd_test.test_progress_flow_control.43 0.04s
[4/2108]     raft     dev   [ PASS ] etcd_test.test_progress_resume_by_append_resp.41 0.05s
[5/2108]     raft     dev   [ PASS ] etcd_test.test_leader_election_overwrite_newer_logs.44 0.04s
[6/2108]     raft     dev   [ PASS ] etcd_test.test_progress_paused.42 0.05s
[7/2108]     raft     dev   [ PASS ] etcd_test.test_log_replication_2.47 0.06s
...

or like this for regular:
================================================================================
[N/TOTAL]   SUITE    MODE   RESULT   TEST
------------------------------------------------------------------------------
[1/184]      raft     dev   [ PASS ] fsm_test.41 0.06s
[2/184]      raft     dev   [ PASS ] etcd_test.40 0.06s
[3/184]      cql      dev   [ PASS ] cassandra_cql_test.2 1.87s
[4/184]      unit     dev   [ PASS ] btree_stress_test.30 1.82s
...

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2021-07-16 17:24:36 +03:00
Avi Kivity
ed6c01a9fa test: increase timeout to account for flat_mutation_reader_v2 tests
Since fce124bd90 ("Merge "Introduce flat_mutation_reader_v2" from
Tomasz") tests involving mutation_reader are a lot slower due to
the new API testing. On slower machines it's enough to time out.

Work underway to improve the situation, and it will also revert back
to the original timing once the flat_mutation_reader_v2 work is done,
but meanwhile, increase the timeout.

Closes #9046
2021-07-15 12:33:43 +03:00
Avi Kivity
a55b434a2b treewide: extent copyright statements to present day 2021-06-06 19:18:49 +03:00
Botond Dénes
b0056f88dc test.py: revamp coverage support
Instead of attempting to universally set the proper environment
necessary for tests to generate profiling data such that coverage.py can
process it, allow each Test subclass to set up the environment as needed
by the specific Test variant.
With this we now have support for all current test types, including cql,
cql-pytest and alternator tests.
2021-06-06 09:21:23 +03:00
Michael Livshin
3bff94cd29 test.py: refine test mode control
* Add ability to skip tests in individual modes using "skip_in_<mode>".

* Add ability to allow tests in specific modes using "run_in_<mode>".

* Rename "skip_in_debug_mode" to "skip_in_debug_modes", because there
  is an actual mode named "debug" and this is confusing.

Signed-off-by: Michael Livshin <michael.livshin@scylladb.com>
2021-05-11 18:39:10 +03:00
Botond Dénes
435d699393 test.py: add basic coverage generation support
Add support for the newly added coverage mode. When --mode=coverage,
also invoke the coverage generation report script to produce a coverage
report after having run the tests.
There are still some rough edges, alternator and cql tests don't work.
2021-05-07 15:54:49 +03:00
Avi Kivity
c2866f46b5 test: relax quota for tests on machines with small page size
8a8589038c ("test: increase quota for tests to 6GB") increased
the quota for tests from 2GB to 6GB. I later found that the increased
requirement is related to the page size: Address Sanitizer allocates
at least a page per object, and so if the page size is larger the
memory requirement is also larger.

Make use of this by only increasing the quota if the page size
is greater than 4096 (I've only seen 4096 and 65536 in the wild).
This allows greater parallelism when the page size is small.

Closes #8371
2021-03-30 12:13:42 +02:00
Avi Kivity
8785dd62cb tests: use kernel page cache
Tests are short-lived and use a small amount of data. They
are also often run repeatly, and the data is deleted immediately
after the test. This is a good scenario for using the kernel page
cache, as it can cache read-only data from test to test, and avoid
spilling write data to disk if it is deleted quickly.

Acknowledge this by using the new --kernel-page-cache option for
tests.

This is expected to help on large machines, where the disk can be
overloaded. Smaller machines with NVMe disks probably will not see
a difference.

Closes #8347
2021-03-30 12:04:55 +02:00
Konstantin Osipov
269c049a16 test.py: enable back CQL based tests
The patch which introduces build-dependent testing
has a regression: it quietly filters out all tests
which are not part of ninja output. Since ninja
doesn't build any CQL tests (including CQL-pytest),
all such tests were quietly disabled.

Fix the regression by only doing the filtering
in unit and boost test suites.

test: dev (unit), dev + --build-raft
Message-Id: <20201119224008.185250-1-kostja@scylladb.com>
2020-11-20 11:45:15 +02:00