couchbase Package

cluster Module

class cbtestlib.couchbase.cluster.Cluster

Bases: object

An API for interacting with Couchbase clusters

async_bucket_delete(server, bucket='default')

Asynchronously deletes a bucket

Parameters:
server - The server to delete the bucket on. (TestInputServer) bucket - The name of the bucket to be deleted. (String)
Returns:
BucketDeleteTask - A task future that is a handle to the scheduled task.
async_compact_view(server, design_doc_name, bucket='default')

Asynchronously run view compaction.

Compacts index file represented by views within the specified <design_doc_name>

Parameters:
server - The server to handle fragmentation config task. (TestInputServer) design_doc_name - design doc with views represented in index file. (String) bucket - The name of the bucket design_doc belongs to. (String)
Returns:
ViewCompactionTask - A task future that is a handle to the scheduled task.
async_create_default_bucket(server, size, replicas=1)

Asynchronously creates the default bucket

Parameters:
server - The server to create the bucket on. (TestInputServer) size - The size of the bucket to be created. (int) replicas - The number of replicas for this bucket. (int)
Returns:
BucketCreateTask - A task future that is a handle to the scheduled task.
async_create_sasl_bucket(server, name, password, size, replicas)

Asynchronously creates a sasl bucket

Parameters:
server - The server to create the bucket on. (TestInputServer) name - The name of the bucket to be created. (String) password - The password for this bucket. (String) replicas - The number of replicas for this bucket. (int) size - The size of the bucket to be created. (int)
Returns:
BucketCreateTask - A task future that is a handle to the scheduled task.
async_create_standard_bucket(server, name, port, size, replicas)

Asynchronously creates a standard bucket

Parameters:
server - The server to create the bucket on. (TestInputServer) name - The name of the bucket to be created. (String) port - The port to create this bucket on. (String) replicas - The number of replicas for this bucket. (int) size - The size of the bucket to be created. (int)
Returns:
BucketCreateTask - A task future that is a handle to the scheduled task.
async_create_view(server, design_doc_name, view, bucket='default')

Asynchronously creates a views in a design doc

Parameters:
server - The server to handle create view task. (TestInputServer) design_doc_name - Design doc to be created or updated with view(s) being created (String) view - The view being created (document.View) bucket - The name of the bucket containing items for this view. (String)
Returns:
ViewCreateTask - A task future that is a handle to the scheduled task.
async_delete_view(server, design_doc_name, view, bucket='default')

Asynchronously deletes a views in a design doc

Parameters:
server - The server to handle delete view task. (TestInputServer) design_doc_name - Design doc to be deleted or updated with view(s) being deleted (String) view - The view being deleted (document.View) bucket - The name of the bucket containing items for this view. (String)
Returns:
ViewDeleteTask - A task future that is a handle to the scheduled task.
async_failover(servers, to_failover)

Asyncronously fails over nodes

Parameters:
servers - All servers participating in the failover ([TestInputServers]) to_failover - All servers being failed over ([TestInputServers])
Returns:
FailoverTask - A task future that is a handle to the scheduled task
async_generate_expected_view_results(doc_generators, view, query)

Asynchronously generate expected view query results

Parameters:
doc_generators - Generators used for loading docs (DocumentGenerator[]) view - The view with map function (View) query - Query params to filter docs from the generator. (dict)
Returns:
GenerateExpectedViewResultsTask - A task future that is a handle to the scheduled task.
async_init_node(server)

Asynchronously initializes a node

The task scheduled will initialize a nodes username and password and will establish the nodes memory quota to be 2/3 of the available system memory.

Parameters:
server - The server to initialize. (TestInputServer)
Returns:
NodeInitTask - A task future that is a handle to the scheduled task.
async_load_gen_docs(server, bucket, generator, kv_store, op_type, exp=0, flag=0)
async_monitor_active_task(server, type, target_value, wait_progress=100, num_iteration=100, wait_task=True)

Asynchronously monitor active task.

When active task reached wait_progress this method will return.
Parameters:

server - The server to handle fragmentation config task. (TestInputServer) type - task type(‘indexer’ , ‘bucket_compaction’, ‘view_compaction’ ) (String) target_value - target value (for example “_design/ddoc” for indexing, bucket “default”

for bucket_compaction or “_design/dev_view” for view_compaction) (String)

wait_progress - expected progress (int) num_iteration - failed test if progress is not changed during num iterations(int) wait_task - expect to find task in the first attempt(bool)

Returns:
MonitorActiveTask - A task future that is a handle to the scheduled task.
async_monitor_view_fragmentation(server, design_doc_name, fragmentation_value, bucket='default')

Asynchronously monitor view fragmentation.

When <fragmentation_value> is reached on the index file for <design_doc_name> this method will return.
Parameters:
server - The server to handle fragmentation config task. (TestInputServer) design_doc_name - design doc with views represented in index file. (String) fragmentation_value - target amount of fragmentation within index file to detect. (String) bucket - The name of the bucket design_doc belongs to. (String)
Returns:
MonitorViewFragmentationTask - A task future that is a handle to the scheduled task.
async_query_view(server, design_doc_name, view_name, query, expected_rows=None, bucket='default', retry_time=2)

Asynchronously query a views in a design doc

Parameters:
server - The server to handle query view task. (TestInputServer) design_doc_name - Design doc with view(s) being queried(String) view_name - The view being queried (String) expected_rows - The number of rows expected to be returned from the query (int) bucket - The name of the bucket containing items for this view. (String) retry_time - The time in seconds to wait before retrying failed queries (int)
Returns:
ViewQueryTask - A task future that is a handle to the scheduled task.
async_rebalance(servers, to_add, to_remove)

Asyncronously rebalances a cluster

Parameters:
servers - All servers participating in the rebalance ([TestInputServers]) to_add - All servers being added to the cluster ([TestInputServers]) to_remove - All servers being removed from the cluster ([TestInputServers])
Returns:
RebalanceTask - A task future that is a handle to the scheduled task
async_verify_data(server, bucket, kv_store, max_verify=None)
async_verify_revid(src_server, dest_server, bucket, kv_store, ops_perf)
async_view_query_verification(server, design_doc_name, view_name, query, expected_rows, num_verified_docs=20, bucket='default', query_timeout=20)

Asynchronously query a views in a design doc and does full verification of results

Parameters:
server - The server to handle query verification task. (TestInputServer) design_doc_name - Design doc with view(s) being queried(String) view_name - The view being queried (String) query - Query params being used with the query. (dict) expected_rows - The number of rows expected to be returned from the query (int) num_verified_docs - The number of docs to verify that require memcached gets (int) bucket - The name of the bucket containing items for this view. (String) query_timeout - The time to allow a query with stale=false to run. (int) retry_time - The time in seconds to wait before retrying failed queries (int)
Returns:
ViewQueryVerificationTask - A task future that is a handle to the scheduled task.
async_wait_for_stats(servers, bucket, param, stat, comparison, value)

Asynchronously wait for stats

Waits for stats to match the criteria passed by the stats variable. See couchbase.stats_tool.StatsCommon.build_stat_check(...) for a description of the stats structure and how it can be built.

Parameters:
servers - The servers to get stats from. Specifying multiple servers will
cause the result from each server to be added together before comparing. ([TestInputServer])

bucket - The name of the bucket (String) param - The stats parameter to use. (String) stat - The stat that we want to get the value from. (String) comparison - How to compare the stat result to the value specified. value - The value to compare to.

Returns:
RebalanceTask - A task future that is a handle to the scheduled task
async_workload(server, bucket, kv_store, num_ops, create, read, update, delete, exp)
bucket_delete(server, bucket='default', timeout=None)

Synchronously deletes a bucket

Parameters:
server - The server to delete the bucket on. (TestInputServer) bucket - The name of the bucket to be deleted. (String)
Returns:
boolean - Whether or not the bucket was deleted.
compact_view(server, design_doc_name, bucket='default', timeout=None)

Synchronously run view compaction.

Compacts index file represented by views within the specified <design_doc_name>

Parameters:
server - The server to handle fragmentation config task. (TestInputServer) design_doc_name - design doc with views represented in index file. (String) bucket - The name of the bucket design_doc belongs to. (String)
Returns:
boolean - True file size reduced after compaction, False if successful but no work done
create_default_bucket(server, size, replicas=1, timeout=None)

Synchronously creates the default bucket

Parameters:
server - The server to create the bucket on. (TestInputServer) size - The size of the bucket to be created. (int) replicas - The number of replicas for this bucket. (int)
Returns:
boolean - Whether or not the bucket was created.
create_sasl_bucket(server, name, password, size, replicas, timeout=None)

Synchronously creates a sasl bucket

Parameters:
server - The server to create the bucket on. (TestInputServer) name - The name of the bucket to be created. (String) password - The password for this bucket. (String) replicas - The number of replicas for this bucket. (int) size - The size of the bucket to be created. (int)
Returns:
boolean - Whether or not the bucket was created.
create_standard_bucket(server, name, port, size, replicas, timeout=None)

Synchronously creates a standard bucket

Parameters:
server - The server to create the bucket on. (TestInputServer) name - The name of the bucket to be created. (String) port - The port to create this bucket on. (String) replicas - The number of replicas for this bucket. (int) size - The size of the bucket to be created. (int)
Returns:
boolean - Whether or not the bucket was created.
create_view(server, design_doc_name, view, bucket='default', timeout=None)

Synchronously creates a views in a design doc

Parameters:
server - The server to handle create view task. (TestInputServer) design_doc_name - Design doc to be created or updated with view(s) being created (String) view - The view being created (document.View) bucket - The name of the bucket containing items for this view. (String)
Returns:
string - revision number of design doc.
delete_view(server, design_doc_name, view, bucket='default', timeout=None)

Synchronously deletes a views in a design doc

Parameters:
server - The server to handle delete view task. (TestInputServer) design_doc_name - Design doc to be deleted or updated with view(s) being deleted (String) view - The view being deleted (document.View) bucket - The name of the bucket containing items for this view. (String)
Returns:
boolean - Whether or not delete view was successful.
failover(servers, to_failover, timeout=None)

Syncronously fails over nodes

Parameters:
servers - All servers participating in the failover ([TestInputServers]) to_failover - All servers being failed over ([TestInputServers])
Returns:
boolean - Whether or not the failover was successful
generate_expected_view_query_results(doc_generators, view, query, timeout=None)

Synchronously generate expected view query results

Parameters:
doc_generators - Generators used for loading docs (DocumentGenerator[]) view - The view with map function (View) query - Query params to filter docs from the generator. (dict)
Returns:
list - A list of rows expected to be returned for given query
init_node(server)

Synchronously initializes a node

The task scheduled will initialize a nodes username and password and will establish the nodes memory quota to be 2/3 of the available system memory.

Parameters:
server - The server to initialize. (TestInputServer)
Returns:
boolean - Whether or not the node was properly initialized.
load_gen_docs(server, bucket, generator, kv_store, op_type, exp=0, timeout=None, flag=0)
modify_fragmentation_config(server, config, bucket='default', timeout=None)

Synchronously modify fragmentation configuration spec

Parameters:
server - The server to handle fragmentation config task. (TestInputServer) config - New compaction configuration (dict - see task) bucket - The name of the bucket fragementation config applies to. (String)
Returns:
boolean - True if config values accepted.
monitor_view_fragmentation(server, design_doc_name, fragmentation_value, bucket='default', timeout=None)

Synchronously monitor view fragmentation.

When <fragmentation_value> is reached on the index file for <design_doc_name> this method will return.
Parameters:
server - The server to handle fragmentation config task. (TestInputServer) design_doc_name - design doc with views represented in index file. (String) fragmentation_value - target amount of fragmentation within index file to detect. (String) bucket - The name of the bucket design_doc belongs to. (String)
Returns:
boolean - True if <fragmentation_value> reached
query_view(server, design_doc_name, view_name, query, expected_rows=None, bucket='default', retry_time=2, timeout=None)

Synchronously query a views in a design doc

Parameters:
server - The server to handle query view task. (TestInputServer) design_doc_name - Design doc with view(s) being queried(String) view_name - The view being queried (String) expected_rows - The number of rows expected to be returned from the query (int) bucket - The name of the bucket containing items for this view. (String) retry_time - The time in seconds to wait before retrying failed queries (int)
Returns:
ViewQueryTask - A task future that is a handle to the scheduled task.
rebalance(servers, to_add, to_remove, timeout=None)

Syncronously rebalances a cluster

Parameters:
servers - All servers participating in the rebalance ([TestInputServers]) to_add - All servers being added to the cluster ([TestInputServers]) to_remove - All servers being removed from the cluster ([TestInputServers])
Returns:
boolean - Whether or not the rebalance was successful
shutdown(force=False)
verify_data(server, bucket, kv_store, timeout=None)
view_query_verification(server, design_doc_name, view_name, query, expected_rows, num_verified_docs=20, bucket='default', query_timeout=20, timeout=None)

Synchronously query a views in a design doc and does full verification of results

Parameters:
server - The server to handle query verification task. (TestInputServer) design_doc_name - Design doc with view(s) being queried(String) view_name - The view being queried (String) query - Query params being used with the query. (dict) expected_rows - The number of rows expected to be returned from the query (int) num_verified_docs - The number of docs to verify that require memcached gets (int) bucket - The name of the bucket containing items for this view. (String) query_timeout - The time to allow a query with stale=false to run. (int) retry_time - The time in seconds to wait before retrying failed queries (int)
Returns:
dict - An object with keys: passed = True or False
errors = reasons why verification failed
wait_for_stats(servers, bucket, param, stat, comparison, value, timeout=None)

Synchronously wait for stats

Waits for stats to match the criteria passed by the stats variable. See couchbase.stats_tool.StatsCommon.build_stat_check(...) for a description of the stats structure and how it can be built.

Parameters:
servers - The servers to get stats from. Specifying multiple servers will
cause the result from each server to be added together before comparing. ([TestInputServer])

bucket - The name of the bucket (String) param - The stats parameter to use. (String) stat - The stat that we want to get the value from. (String) comparison - How to compare the stat result to the value specified. value - The value to compare to.

Returns:
boolean - Whether or not the correct stats state was seen
workload(server, bucket, kv_store, num_ops, create, read, update, delete, exp, timeout=None)

document Module

class cbtestlib.couchbase.document.DesignDocument(name, views, rev=None)
add_view(view)
as_json()
delete_view(view)
class cbtestlib.couchbase.document.View(name, map_func, red_func=None, dev_view=True)
as_json()
cbtestlib.couchbase.document.clean_string(str_)

documentgenerator Module

class cbtestlib.couchbase.documentgenerator.BlobGenerator(name, seed, value_size, start=0, end=10000)

Bases: cbtestlib.couchbase.documentgenerator.KVGenerator

next()
class cbtestlib.couchbase.documentgenerator.DocumentGenerator(name, template, *args, **kwargs)

Bases: cbtestlib.couchbase.documentgenerator.KVGenerator

An idempotent document generator.

next()
class cbtestlib.couchbase.documentgenerator.KVGenerator(name, start, end)

Bases: object

has_next()
next()
reset()

stats_tools Module

class cbtestlib.couchbase.stats_tools.StatsCommon
static get_stats(servers, bucket, stat_param, stat)

Gets stats for a specific key from a list of servers

Parameters:
servers - A list of servers to get a stat from. ([TestInputServer]) bucket - The name of the bucket to get a stat from. (String) stat_param - The parameter for the stats call, eg. ‘checkpoint’. (String) stat - The name of the stat to get. (String)
Returns:
Dictionary - The key is the test input server and the value is the result of the for the stat passed in as a parameter.

view_helper Module

class cbtestlib.couchbase.view_helper.ViewHelper
static queryViewUntilNotEmpty(rest, design_doc_name, view_name, bucket, query, spatial=False, interval=10, tries=40)
static queryViewWaitForKeys(rest, design_doc_name, view_name, bucket, query, expected_keys, spatial=False, interval=10, timeout=600)

Table Of Contents

Previous topic

cbkarma Package

Next topic

couchdb Package

This Page