Command Line
Canarytrace is distributed as a docker image and is run from command line. Behavior and functions are set using options. Some options are mandatory and some are optional. Canarytrace is based on WDIO v7 and therefore some options are described on WDIO CLI Options page.
What you’ll learn#
- How to run Canarytrace from the command line
- Options for Canarytrace settings
- All options are environment variables and they are used when running in both the docker and the kubernetes
How to run Canarytrace#
Examples below shows how to run Canarytrace in minimal configuration. Minimal configuration means, that Canarytrace will be run with default configuration.
Docker compose#
The easiest way to run Canarytrace is to use a docker compose
In this example are only options BASE_URL which contain target URL and LICENSE.
You can run a command using docker-compose up
Kubernetes#
Use Kubernetes CronJob for production use and for non-stop monitoring.
This example isn't complete, but contains more options as environment variable ELASTIC_CLUSTER, PT_AUDIT, PT_AUDIT_THROTTLING or LABELS. Some of them are mandatory and some are optional.
Mode smoke#
How to read this documentation#
- You can run Canarytrace in modes
smokeoruser-journey. Smoke mode is a default mode and is maintenance free and therefore you can use less mandatory options.- If you have Canarytrace Pro edition, you can run audits such as performance audit. Features for Canarytrace Pro have this badge Professional
Mandatory options#
Mode
smokeis a default.
BASE_URLadd more URLs, e.g.BASE_URL=https://canarytrace.com/;https://webperf.canarytrace.com/LICENSEadd your license key.
Elasticsearch#
If you want use live logging to Elasticsearch and visualize data in a Kibana, you must use this options.
ELASTIC_CLUSTERURI of elasticsearch cluster. E.g.ELASTIC_CLUSTER="http://localhost:9200"This option activate live reporting all data to elasticsearch. If left blank, documents will be printed to stdout.ELASTIC_HTTP_AUTHBasic authentication in format username:password . E.g.ELASTIC_HTTP_AUTH=elastic:1fKP17UklmiI14rekO6iCx9rMIN_PTIMEPrint requests to elasticsearch if is exceeded transactions time. Default min processing time is 300ms.ELASTIC_OBSERVABILITYUseallowfor print settings of elasticsearch and all requests and responses to stdout.INDEX_PREFIX- Default isc.USE_ELASTIC_DOC_TYPE_BY_INDEX_NAMEDefault is false and will be used type _doc. If you true will be used name of index just type.ELASTIC_REQUEST_COMPRESSIONUseallowfor use compression.ELASTIC_TIMEOUTDefault is 5000ms.
Performance audit#
ProfessionalConfiguration is on separate page. Performance audit configuration
Optional#
PAUSE_BETWEEN_SMOKEDefault is 0ms. Pause between every tested URL.
Mode user-journey#
- If you use this mode you need test script / monitor script writen in Webdriver.IO. Try how to write test script / monitor script
- In this mode you must use more mandatory options, because Canarytrace need to download test cases from your git repositry.
- If you have Canarytrace Pro edition, you can run audits such as performance audit. Features for Canarytrace Pro have this badge Professional
BASE_URL- is a start address 'https://the-internet.herokuapp.com/' for your test script. You test script can start with/
Mandatory options#
MODE- switch mode of Canarytrace on user journeyMODE="user-journey"SPEC- is file with your test case / monitor script, e.g.SPEC="test/specs/example.e2e.js"GIT_REPOSITORY- e.g.git@github.com:canarytrace/wdio75-demo.gitGIT_REPOSITORY_PORT- e.g.22GIT_REPOSITORY_HOST- e.g.github.comGIT_REVISION-fd29508revision of your test case. Canarytrace perform git checkout before run test.
Optional#
USERusername for TC, which use login to app. E.g.USER=CYBERTRUCKPASSpassword for TC, which use login to app. E.g.PASS=Cybertruck@250Mil
How to use in your test case
Other#
These options are not mandatory and are available for both mode.
LABELSis optional metainformation, which is stored in the elastic to each record in each index, e.g.'relesease=7, environment=dev'SPECis path and name of testcase / monitor script. E.g.SPEC=tesla/smoke.jsENGINE- default iswdiofor Webdriver.IO v7.5 and no need change itENV_PRINT- Print all environment variables. Print all environment variables before execution of monitor script. All environment variables will be saved to Elasticsearch indexc.env-*
It's useful for debugging but use with caution. This command print value all environment variables including sensitive if exist.
AVAILABILITY_CHECK- useallowif you want run check availability of web app before run Canarytrace.
It's useful for check availability environment and tested application.
WAIT_FOR_TIMEOUT- Timeout limit for all webdriver.io waitFor* commands. Default is 30.000msLOG_LEVEL- default iswarn. Level of logging verbosityATTACHMENTSUseallowfor store screenshot to disk, when testStep is failed.Format HHmmss-YYYY-MM-DD-uuidAction.png
You must bind volume
-v $(pwd)/attachments/:/opt/canary/attachmentsfor "move screenshot from docker container to local directory"/attachments.You can use
AWS_S3_BUCKEToption for upload screenshot to AWS S3 This option is described below.
CAPTURE_EVERY_SCREEN=allowcreate a screenshot on every test step.TESTS_PATHdefault is/opt/canary/teststhere is no reason to change this option.
Services#
ProfessionalREQUEST_LOGdefaultnostore collection all requests and responses directly from browser into elasticsearch indexc.request-log-*- For activate this features use
REQUEST_LOG=allow
- For activate this features use
CONSOLE_INTERCEPTdefaultnostore console of browser into elasticsearch indexc.console-*- For activate this features use
CONSOLE_INTERCEPT=allow
- For activate this features use
COVERAGE_AUDITdefaultnostore percentage used and unused code of web application into elasticsearch indexc.coverage-audit-*- For activate this features use
COVERAGE_AUDIT=allow
- For activate this features use
MEMORY_INTERCEPTdefaultnostore used javascript memory during loading and using the web application into elasticsearch indexc.memory-*- For activate this features use
MEMORY_INTERCEPT=allow
- For activate this features use
HERO_ELEMENTSdefaultnostore Hero Elements into elasticsearch indexc.performance-entries-*- For activate this features use
HERO_ELEMENTS=allow
- For activate this features use
Volumes#
-v $(pwd)/assets/:/opt/canary/assetsbinding local directory with directory in docker container for statical files, e.g. Lighthouse HTML report or JSON records of activity in Chrome's processes.-v $(pwd)/tests/:/opt/canary/testsbinding local directory with tests to directory in docker container.-v $(pwd)/config:/opt/canary/config/wdiofor extended default configuration.
- Do you find mistake or have any questions? Please create issue, thanks 👍
- Have more questions? Contact us.