Test

class ducktape.tests.test.Test(test_context, *args, **kwargs)[source]

Bases: ducktape.template.TemplateRenderer

Base class for tests.

__init__(test_context, *args, **kwargs)[source]
compress_service_logs(node, service, node_logs)[source]

Compress logs on a node corresponding to the given service.

Parameters:
  • node – The node on which to compress the given logs
  • service – The service to which the node belongs
  • node_logs – Paths to logs (or log directories) which will be compressed
Returns:

a list of paths to compressed logs.

copy_service_logs(test_status)[source]

Copy logs from service nodes to the results directory.

If the test passed, only the default set will be collected. If the the test failed, all logs will be collected.

min_cluster_size()[source]

THIS METHOD IS DEPRECATED AND WILL BE REMOVED IN THE SUBSEQUENT RELEASES. Nothing in the ducktape framework calls it, it is only provided so that subclasses don’t break. If you’re overriding this method in your subclass, please remove it.

min_cluster_spec()[source]

THIS METHOD IS DEPRECATED AND WILL BE REMOVED IN THE SUBSEQUENT RELEASES. Nothing in the ducktape framework calls it, it is only provided so that subclasses don’t break. If you’re overriding this method in your subclass, please remove it.

setup()[source]

Override this for custom setup logic.

teardown()[source]

Override this for custom teardown logic.

class ducktape.tests.test.TestContext(**kwargs)[source]

Bases: object

Wrapper class for state variables needed to properly run a single ‘test unit’.

__init__(**kwargs)[source]
Parameters:
  • session_context
  • cluster – the cluster object which will be used by this test
  • module – name of the module containing the test class/method
  • cls – class object containing the test method
  • function – the test method
  • file – file containing this module
  • injected_args – a dict containing keyword args which will be passed to the test method
  • cluster_use_metadata – dict containing information about how this test will use cluster resources
close()[source]

Release resources, etc.

copy(**kwargs)[source]

Construct a new TestContext object from another TestContext object Note that this is not a true copy, since a fresh ServiceRegistry instance will be created.

description

Description of the test, needed in particular for reporting. If the function has a docstring, return that, otherwise return the class docstring or “”.

expected_cluster_spec

The cluster spec we expect this test to consume when run.

Returns:A ClusterSpec object or None if the test cannot be run (e.g. session context settings disallow tests with no cluster metadata attached).
expected_num_nodes

How many nodes of any type we expect this test to consume when run. Note that this will be 0 for both unschedulable tests and the tests that legitimately need 0 nodes.

Returns:an integer number of nodes.
local_scratch_dir

This local scratch directory is created/destroyed on the test driver before/after each test is run.

test_name

The fully-qualified name of the test. This is similar to test_id, but does not include the session ID. It includes the module, class, and method name.