Caution
This page documents the latest, unreleased version of Buildbot. For documentation for released versions, see http://docs.buildbot.net/current/.
2.5.25.1. Worker command expectations
TestBuildStepMixin
is used to test steps and accepts command expectations to its expect_commands
method.
These command expectations are instances of classes listed in this page.
In all cases the arguments used to construct the expectation is what is expected to receive from the step under test. The methods called on the command are used to build a list of effects that the step will observe.
- class buildbot.test.steps.Expect
This class is the base class of all command expectation classes. It must not be instantiated by the user. It provides methods that are common to all command expectations.
- exit(code)
- Parameters:
code (int) – Exit code
Specifies command exit code sent to the step. In most cases
0
signify success, other values signify failure.
- stdout(output)
- Parameters:
output – stdout output to send to the step. Must be an instance of
bytes
orstr
.
Specifies
stdout
stream in thestdio
log that is sent by the command to the step.
- stderr(output)
- Parameters:
output – stderr output to send to the step. Must be an instance of
bytes
orstr
.
Specifies
stderr
stream in thestdio
log that is sent by the command to the step.
- log(name, **streams)
- Parameters:
name (str) – The name of the log.
streams (kwargs) – The log streams of the log streams. The most common are
stdout
andstderr
. The values must be instances ofbytes
orstr
.
Specifies logs sent by the command to the step.
For
stdio
log andstdout
stream use thestdout()
function.For
stdio
log andstderr
stream use thestderr()
function.
- error(error)
- Parameters:
error – An instance of an exception to throw when running the command.
Throws an exception when running the command. This is often used to simulate broken connection by throwing in an instance of
twisted.internet.error.ConnectionLost
.
ExpectShell
- class buildbot.test.steps.ExpectShell(Expect)
This class represents a
shell
command sent to the worker.Usually the stdout log produced by the command is specified by the
.stdout
method, the stderr log is specified by the.stderr
method and the exit code is specified by the.exit
method.ExpectShell(workdir='myworkdir', command=["my-test-command", "arg1", "arg2"]) .stdout(b'my sample output') .exit(0)
- __init__(workdir, command, env=None, want_stdout=1, want_stderr=1, initial_stdin=None, timeout=20 * 60, max_time=None, sigterm_time=None, logfiles=None, use_pty=None, log_environ=True, interrupt_signal=None)
Initializes the expectation.
ExpectStat
- class buildbot.test.steps.ExpectStat(Expect)
This class represents a
stat
command sent to the worker.Tests usually indicate the existence of the file by calling the
.exit
method.- __init__(file, workdir=None, log_environ=None)
Initializes the expectation.
- stat(mode, inode=99, dev=99, nlink=1, uid=0, gid=0, size=99, atime=0, mtime=0, ctime=0)
Specifies
os.stat
result that is sent back to the step.In most cases it’s more convenient to use
stat_file
orstat_dir
.
- stat_file(mode=0, size=99, atime=0, mtime=0, ctime=0)
- Parameters:
mode (int) – Additional mode bits to set
Specifies
os.stat
result of a regular file.
- stat_dir(mode=0, size=99, atime=0, mtime=0, ctime=0)
- Parameters:
mode (int) – Additional mode bits to set
Specifies
os.stat
result of a directory.
ExpectUploadFile
- class buildbot.test.steps.ExpectUploadFile(Expect)
This class represents a
uploadFile
command sent to the worker.- __init__(blocksize=None, maxsize=None, workersrc=None, workdir=None, writer=None, keepstamp=None, slavesrc=None, interrupted=False)
Initializes the expectation.
- upload_string(string, error=None)
- Parameters:
string (str) – The data of the file to sent to the step.
error (object) – An optional instance of an exception to raise to simulate failure to transfer data.
Specifies the data to send to the step.
ExpectDownloadFile
- class buildbot.test.steps.ExpectDownloadFile(Expect)
This class represents a
downloadFile
command sent to the worker. Tests usually check what the step attempts to send to the worker by calling.download_string
and checking what data the supplied callable receives.- __init__(blocksize=None, maxsize=None, workerdest=None, workdir=None, reader=None, mode=None, interrupted=False, slavesrc=None, slavedest=None)
Initializes the expectation.
- download_string(dest_callable, size=1000)
- Parameters:
dest_callable (callable) – A callable to call with the data that is being sent from the step.
size (int) – The size of the data to read
Specifies the callable to store the data that the step wants the worker to download.
ExpectMkdir
ExpectRmdir
ExpectCpdir
ExpectRmfile
ExpectGlob
- class buildbot.test.steps.ExpectGlob(Expect)
This class represents a
mkdir
command sent to the worker.- __init__(path=None, log_environ=None)
Initializes the expectation.
- files(files=None)
- Parameters:
files (list) – An optional list of returned files.
Specifies the list of files returned to the step.