To get help, run:
plaxrun -h
Usage of plaxrun:
-I value
YAML include directories
-dir string
Directory containing test files (default ".")
-g value
Groups to execute: Test Group Name
-json
Emit JSON test output; instead of JUnit XML
-labels string
Labels for tests to run
-log string
Log level (info, debug, none) (default "info")
-p value
Parameter Bindings:
-priority int
Test priority (default -1)
-redact
enable redactions when -log debug (default true)
-run string
Filename for test run specification (default "spec.yaml")
-s string
Suite name to execute; -t options represent the tests in the suite to execute
-t value
Tests to execute: Test Name
-v Verbosity (default true)
-version
Print version and then exit
Use -run
to specify the the path to the test run specification file
Use -dir
to specify the path to the root of the test files directory
To run a single test group, use -g once:
plaxrun -run cmd/plaxrun/demos/fullrun.yaml -dir demos -g basic
To run multiple test groups, specify -g multiple times:
plaxrun -run cmd/plaxrun/demos/fullrun.yaml -dir demos -g basic -g inclusion
To run a single test or set of tests, specify -t:
plaxrun -run cmd/plaxrun/demos/fullrun.yaml -dir demos -t basic
To run a set of tests in a test suite, specify -s
(plaxrun suite name references) and -t
(plax test name references):
plaxrun -run cmd/plaxrun/demos/fullrun.yaml -dir demos -s demos -t basic -t test-wait
Note: A combination of -g
an -t
is allowed unless -s
is used
Use -json
to output a JSON representation of the test results instead of the Junit XML format. This output includes test.State
as the key State
for each test case.
Use -labels
[string] to set the labels filter for tests to run
Use -priority
[int] to set the priority of tests to run
Use -p 'PARAM=VALUE'
to pass bindings on the command line. You can specify -b
multiple times:
plaxrun -run cmd/plaxrun/demos/waitrun.yaml -dir demos -g wait-prompt -p '?WAIT=600' -p '?MARGIN=200'
A plaxrun specification is a .yaml
file which contains the following major elements:
name
- The name of the test specification prefixed to all output test suite namesversion
- The version of the test specification appended to the nametests
- The set of defined tests referenced in test groupsgroups
- The set of defined test groups referenced from other groups or the command line-g
option(s)params
- The set of parameters to be bound via shell command execution if values are not already bound via-p
option(s)
Here is an example specification file
Let's start by breaking it down:
The general properties provided to uniquely identify test run executions
name: waitrun
version: 0.0.1
name: waitrun
of the specification which serves as the prefix of the test output suite name along with theversion
version: 0.0.1
of the specification which serves as the the prefix of the test output suite name following thename
The tests:
section defines a set of tests, either test suites or test files, to be references by test groups.
tests:
wait:
path: test-wait.yaml
version: github.com/Comcast/plax
params:
- 'WAIT'
- 'MARGIN'
wait:
is the test name used to reference the test from a test grouppath:
is the relative path to the test directory (Suite) or file (Test) based on.
or the-dir
optionversion: github.com/Comcast/plax
represents the name of the module that implements the plax plugin compatible with the plax execution engine test syntax. This is optional if the default versiongithub.com/Comcast/plax
is being targetedparams:
is the list of parameter name dependencies referencing the parameters defined in theparams
section. All listed parameters will be evaluated for parameter binding values- 'WAIT'
is a parameter required by thetest-wait.yaml
test- 'MARGIN'
is a parameter required by thetest-wait.yaml
test
The groups:
section defines a set of test groups which organize tests and nested test groups for execution.
Test groups can references defined tests as follows:
groups:
wait-prompt:
tests:
- name: wait
wait-prompt:
is the group name. It is used to reference the test group from other test groups and the-g
option; It shows how to define tests that likely require a prompt to enter tests parameter values not already boundparams:
is the set of parameter key/value binding for the test group'WAIT': 600
is a parameter bound with the value600
'MARGIN': 600
is a parameter bound with the value200
tests
is the list of test references where the testname
matches a test name defined in thetests
section; each test is executed in sequencename: wait
is a testname
reference to a test namedwait
Test groups can reference nested test groups that have been defined as follows:
wait-group:
groups:
- name: wait-prompt
- name: wait-no-prompt
- name: wait-iterate
wait-group
: is the group name. it is used to reference the test group from other test groups and the-g
option. It shows how to group test groups together inside a single test groupgroups:
is the list of group references where the groupname
matches a group name defined in thegroups
section; each group is executed in sequencename: wait-prompt
is a groupname
reference to a group namedwait-prompt
name: wait-no-prompt
is a groupname
reference to a group namedwait-no-prompt
name: wait-iterate
is a groupname
reference to a group namedwait-iterate
Test groups can have parameter bindings inherited by the referenced tests and groups as follows:
wait-no-prompt:
params:
'WAIT': 600
'MARGIN': 200
tests:
- name: wait
wait-no-prompt:
is the group name. It is used to reference the test group from other test groups and the-g
option; It shows how to define tests that do not required a prompt by binding all the necessary parameters with valuesparams:
is the set of parameter key/value binding for the test group'WAIT': 600
is a parameter bound with the value600
'MARGIN': 600
is a parameter bound with the value200
tests:
is the list of test references where the testname
matches a test name defined in thetests
section; each test is executed in sequencename: wait
is a testname
reference to a test namedwait
Test groups can iterate over a the referenced tests and groups as follows:
wait-iterate:
iterate:
params: |
[
{
"WAIT": 300,
"MARGIN": 100
},
{
"WAIT": 600,
"MARGIN": 200
},
{
"WAIT": 900,
"MARGIN": 300
}
]
tests:
- name: wait
wait-iterate
: is the group name. It is used to reference the test group from other test groups and the-g
option. It shows how to iterate through a set of tests or test groupsiterate:
is the instruction to iterate over the test(s) or group(s) reference by this groupparams:
is the set of parameter object (key/value) bindings for each iteration of the test group'WAIT': 600
is a parameter bound with the value600
'MARGIN': 600
is a parameter bound with the value200
tests:
is the list of test references where the testname
matches a test name defined in thetests
section; each test is executed in sequencename: wait
is a testname
reference to a test namedwait
Test groups can define a guard against test, group, or iteration execution.
groups:
wait-guard-test:
iterate:
dependsOn:
- WAIT_LIST
- ILLEGAL_WAIT
params: '{WAIT_LIST}'
tests:
- name: wait
guard:
src: |
return bs["WAIT"] != bs["ILLEGAL_WAIT"];
wait-guard-group:
groups:
- name: wait-prompt
guard:
dependsOn:
- DO_NOT_PROMPT
libraries:
- include/libs/boolean.js
src: |
return isFalse(bs["DO_NOT_PROMPT"]);
- name: wait-no-prompt
- name: wait-iterate
wait-guard-iterate:
iterate:
dependsOn:
- WAIT_LIST
- ILLEGAL_WAIT
params: '{WAIT_LIST}'
guard:
src: |
return bs["WAIT"] != bs["ILLEGAL_WAIT"];
tests:
- name: wait
guard:
is the instruction for a guarddependsOn:
evaluate the list of defined parameter referenceslibraries:
import the listed Javascript librariessrc:
execute the Javascript code to evaluate the guard; must return boolean [true|false]
The params:
parameter definition section defines the parameter names to be bound to a value or set of values returned by a shell command.
Each parameter is composed of the following parts:
envs:
is the section that defines the environment variables as mapped key/value pairsredact: [true|false]
is an optional flag to redact output of the parameter binding in the logscmd:
is the command to execute.bash
makes for a great command execution script environmentargs:
are the arguments to pass to the command
An example set of parameters follows:
params:
'WAIT':
include: include/commands/prompt.yaml
envs:
PROMPT: Enter wait
DEFAULT: 300
'MARGIN':
include: include/commands/value.yaml
envs:
DEFAULT: 100
'MARGIN':
include: include/commands/value.yaml
envs:
DEFAULT: universe
redact: true
'WAIT':
is the first parameter nameinclude: include/commands/prompt.yaml
is the macro inclusion of theprompt.yaml
) command meant for re-use by other parameter bindingsenvs:
is the section that defines the environment variables for theprompt.yaml
commandPROMPT:
is an optional environment variable for the prompt command; provides a default promptDEFAULT:
is an optional environment variable for the prompt command; no value by default
'MARGIN':
is the second parameter nameinclude: include/commands/value.yaml
is the macro inclusion of thevalue.yaml
command meant for re-use by other parameter bindingsenvs:
is the section that defines the environment variables for thevalue.yaml
commandDEFAULT: 100
is a required environment variable for thevalue.yaml
command if the environment variable is not already set
'WORLD':
is the third parameter nameinclude: include/commands/value.yaml
is the macro inclusion of thevalue.yaml
command meant for re-use by other parameter bindingsenvs:
is the section that defines the environment variables for thevalue.yaml
commandDEFAULT: 100
is a required environment variable for thevalue.yaml
command if the environment variable is not already set
redact: true
sets the flag to redact the output of the value of the parameter
The commands supported by plaxrun are greatly extensible. Each command, a simple include file for reusability across parameters, is typically composed as follows:
cmd: bash
args:
- -c
- |
if [ -n "${!KEY}" ]; then
echo $KEY=${!KEY}
else
: "${VALUE:?Variable is not set or empty}"
echo $KEY=$VALUE
fi
Within a command there is a preset environment variable call KEY
. $KEY
is a reference to the name of the default parameter to which a value should be bound. ${!KEY}
references the current value bound to $KEY
. The script should output to stdout
, in this case via echo
the key/value pair for the binding, e.g. echo $KEY=$VALUE
. The script can also echo out an other key/value pairs to bind more than one parameter value. e.g. echo MYPARAM="My Value"
The current built in commands are:
command.yaml
returns the existing environment variable value or executes the given command to fetch the valuecsv.yaml
returns an array of JSON objects with key and values mapped from the input CSVprompt.yaml
returns the existing environment variable value or prompt the user for a command with an optional default valuevalue.yaml
returns the existing environment variable value or returns a default value
Note: Each command has a different set of required or optional environment variables (envs
). See each respective command .yaml
file for additional information.
More commands can easily be added by plaxrun specification authors, e.g. fetch secure parameter values from Vault or invoke AWS CLI commands and bind the results to a parameter.
The reports:
definition section defines the report plugins to be executed to submit the result of the test execution. Currently Plaxrun supports the
following report plugin types:
- stdout - a report plugin that writes the test results to standard output in either XML or JSON format
Each report is composed of the following parts:
config:
is the section that defines the report plugin specific configuration settings. The config section supports parameter binding substitution.
An example report definition is as follows:
params:
STDOUT_REPORT_TYPE:
include: include/commands/value.yaml
envs:
VALUE: JSON
reports:
stdout:
config:
type: {STDOUT_REPORT_TYPE}
stdout:
is the default report plugin that reports to standard outputconfig:
is the plugin specific configuration settingstype:
is the stdout report plugin output format.XML
is the default. The example shows overriding to useJSON
using the{STDOUT_REPORT_TYPE}
parameter binding.
To run the test specifications described above:
- The following command runs just the
wait-no-prompt
test groupplaxrun -run cmd/plaxrun/demos/waitrun.yaml -dir demos -g wait-no-prompt -json | jq .
- The following command runs just the
wait-prompt
test groupplaxrun -run cmd/plaxrun/demos/waitrun.yaml -dir demos -g wait-prompt -json | jq .
- The following command runs both the
wait-no-prompt
andwait-prompt
test groupplaxrun -run cmd/plaxrun/demos/waitrun.yaml -dir demos -g wait-no-prompt -g wait-prompt -json | jq .
- The following command runs the
wait
test group which combines thewait-no-prompt
andwait-prompt
test groupsplaxrun -run cmd/plaxrun/demos/waitrun.yaml -dir demos -g wait -json | jq .
After test execution, plaxrun
will output results in JUnit XML:
<testsuite tests="1" failures="0" errors="0">
<testcase name="tests/discovery-1.yaml" status="executed" time="11"></testcase>
</testsuite>
plaxrun
will generate a suite name.
Use -json
to output a JSON representation of test result objects.
This output includes the following for each test case:
[
{
"Type": "suite",
"Time": "2020-12-02T21:33:09.0728586Z",
"Tests": 1,
"Passed": 1,
"Failed": 0,
"Errors": 0
},
{
"Name": "/.../plax/demos/test-wait.yaml",
"Status": "executed",
"Skipped": null,
"Error": null,
"Failure": null,
"Timestamp": "2020-12-02T21:33:09.077102Z",
"Suite": "waitrun-0.0.1:wait-no-prompt:wait",
"N": 0,
"Type": "case",
"State": {
"then": "2020-12-02T21:33:09.0781375Z"
}
}
]
The -log
command-line option accepts none
(default), info
, and
debug
. To provide some level of logging without printing some
possibly sensitive information, info
does not log payloads or bindings
values. In contrast, -debug
will by default log binding values and
payloads. However, with -log debug
, the flag -redact
enables some
log redactions:
-
Values with binding names that start with
X_
(ignoring non-alphabetic prefix characters like?
) will be redacted fromdebug
log output if-redact=true
(default is true). If the redactedX_
values are needed for debugging, use-redact=false
locally. -
In a test, Javascript (usually executed via a
run
step) can add redactions using the functionsredactRegexp
andredactString
. See documentation above for usage information.
See demos/redactions.yaml
for an example
of both techniques.