Skip to content

Scope Methods

tahmmee edited this page Apr 18, 2016 · 1 revision

Overview

Scope methods are used to help tests access scope resources without knowing specifics such as IP address, Ports, Bucket name, etc.. These are defined lib/template.go and work in conjunction with golang text/template to create dynamic tests that can adopt to various scopes.

Server Selectors

.Nodes:

Generates a list of all nodes defined in the scope. This example shows piping the output into the 'net' method to filter just the ip address of the 1st node in the list.

# first node ip
command: "-U  {{.Nodes | net 0}}"

.Cluster:

Generates a list of all nodes defined within the first cluster from the scope.

# first node in cluster 1
command: "-U  {{.Cluster 1 | net 0}}"

.Orchestrator

Shortcut to get IP address of first node in the first cluster

# first node in cluster 0
command: "-U  {{.Orchestrator}}"

.Service

Generates a list of all nodes with the specified service (requires v4.0+). Any service recognized by couchbase can be used such as 'kv' 'n1ql', 'view', 'fts'.

# run cbq against first query node 
image: sequoiatools/cbq
command: "-e=http://{{.Nodes | .Service `n1ql` | net 0}}:8093 ..."

.QueryNode

Shortcut to get first query node from the cluster

# run cbq against first query node 
image: sequoiatools/cbq
command: "-e=http://{{.QueryNode}}:8093 ..."

.NthQueryNode

Shortcut to get Nth query node from the cluster, where N=0 is the first query node.

# run cbq against second query node 
image: sequoiatools/cbq
command: "-e=http://{{.NthQueryNode 1}}:8093 ..."

.DataNode Shortcut to get first data node from the cluster

# view queries on data node 
command: "query --host {{.DataNode}} --ddoc scale ..."

.NthDataNode

Shortcut to get Nth data node from the cluster, where N=0 is the first data node.

# run view queries against forth data node 
command: "query --host {{.NthDataNode 4}} --ddoc scale..."

| net

Downstream method to resolve IP address from a cluster group.

| noport

Strip the port from the ip host (if exists)

command: "{{.Orchestrator | noport}}"

Bucket Selectors

.Bucket

Returns the first bucket defined on the first cluster

# 10k ops to first bucket
command: "kv --ops 10000 --create 100 --bucket {{.Bucket}}"

.NthBucket

Returns the Nth bucket defined on the first cluster.

# 10k ops to the third bucket
command: "kv --ops 10000 --create 100 --bucket {{.NthBucket 2}}"

| bucket

Downstream method for selecting a bucket from cluster group. Useful when you want a bucket from a different cluster.

# load into 2nd bucket on 2nd cluster
command: "kv --ops 10000 --create 100 --bucket {{.Nodes | .Cluster 1 | bucket 0}}"

Attribute Selectors

Attribute selectors can be used to reference scope variables such as rest_port, rest_password.

.Attr

Generic attribute selector used to reference scope keys. Supported attributes are

  • rest_username
  • rest_password
  • rest_port
  • view_port
  • ram
  • name
# select rest username from cluster 1 
command: "... --xdcr-username {{.Nodes | .Cluster 1 | .Attr `rest_username`}}"

.RestUsername

Shortcut to get rest username for the orchestrator

# select rest username from cluster 1  
command:  "rebalance  -u  {{.RestUsername}} ..."

.RestPassword

Shortcut to get rest password for the orchestrator

# select rest username from cluster 1  
command:  "rebalance -p  {{.RestPassword}} ..."

Utility Methods

The following methods offer dynamic control and scalability to the test

.Scale

Numeric factor to scale by as defined in config.yml. This method will multiple it's argument by the specified scale. For use to increase/decrease stress from loaders.

# multiply by scale factor
image: sequoiatools/pillowfight
command: "-U  {{.Orchestrator}} -I {{.Scale 1000}} -B {{.Scale 100}} -t 4 -c 10"

.DoOnce

Require that a task should only run once. For use with longevity testing when test is continually repeated.

# only setup xdcr once
image: sequoiatools/couchbase-cli
requires:  "{{eq true .DoOnce }}"
command:  "xdcr-setup -c {{.Orchestrator}} --create --xdcr-cluster-name remote 

.Version

Require that a task is only run at specified version. This directive returns value of currently tested version for comparison.

# tpcc requires couchbase > 4.0
image: sequoiatools/tpcc
requires:  "{{.Version | le 4.0 | eq .DoOnce}}"
command:  "./run.sh {{.QueryNode}}:8093 util/cbcrindex.sql"
Clone this wiki locally