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]

Returns the number of linux nodes which this test needs.

THIS METHOD IS DEPRECATED, and provided only for backwards compatibility. Please implement min_cluster_spec instead.

Returns:An integer.
min_cluster_spec()[source]

Returns a specification for the minimal cluster we need to run this test.

This method replaces the deprecated min_cluster_size. Unlike min_cluster_size, it can handle non-Linux operating systems.

In general, most Tests don’t need to override this method. The default implementation seen here works well in most cases. However, the default implementation only takes into account the services that exist at the time of the call. You may need to override this method if you add new services during the course of your test.

Returns:A ClusterSpec object.
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.
expected_num_nodes

How many nodes of any type we expect this test to consume when run.

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.