fixtures.merkyl module

class fixtures.merkyl.MerkylInspector(request)[source]

Bases: object

add_log(log_name)[source]

Adds a log file to the merkyl process.

This function adds a log file path to the merkyl process on the appliance. This is relevant only for the duration of the test. At the end of the test, the file is removed from the merkyl tracker.

Note that this is a blocking call, ie, we ensure that the file is being logged by merkyl, before we continue. This is important and prevents the file_add operation being queued and processes which generate log information activating before the log is being monitored. This is achieved using the grab_result switch, but in fact, nothing will be received.

It is worth noting that the file path must be “discoverable” by merkyl. This may mean editing the allowed_files prior to deploying merkyl.

Parameters:log_name – Full path to the log file wishing to be monitored.
get_log(log_name)[source]

A simple getter for log files.

Returns the cached content of a particular log

Parameters:log_name – Full path to the log file wishing to be received.
search_log(needle, log_name)[source]

A simple search, test if needle is in cached log_contents.

Does a simple search of needle in contents. Note that this does not trawl the previous contents of the file, but only looks at the log information which has been gathered since merkyl was tracking the file.

fixtures.merkyl.merkyl_inspector(request)[source]

Provides a MerkylInspector instance.

This fixture is used to gain access to a relevant MerkylInspector instance.

Example usage is below:

def test_test(merkyl_inspector):
    merkyl_inspector.add_log('/path/to/log/file')
    # Do something
    if merkyl_inspector.search_log('needle', '/path/to/log/file'):
        print(merkyl_inspector.get_log('/path/to/log/file'))