This repo exists to show how to use toxiproxy and toxiproxyr for continuous integration.
The key bits needed are:
toxiproxyr
to your DESCRIPTION
Suggests:
testthat,
toxiproxyr
Remotes: richfitz/toxiproxyr
The Remotes
entry will be needed until toxiproxyr
is on CRAN. toxiproxyr
is added to Suggests:
only because it is needed only in tests.
.Rbuildignore
to ignore some files that are needed on the continuous integration server^\.toxiproxy$
.travis.yml
to start toxiproxy before running your testsbefore_script:
- Rscript -e 'toxiproxyr:::toxiproxy_start_ci(".toxiproxy")'
The path .toxiproxy
here can be anything but must match what you use in .Rbuildignore
appveyor.yml
build_script:
- travis-tool.sh install_deps
- Rscript -e 'toxiproxyr:::toxiproxy_start_ci(".toxiproxy")'
The first line of this is in the standard appveyor template.
A full example is given in tests/testthat/test-package.R. There are several things to note here
toxiproxy
with skip_if_not_installed("toxiproxyr")
because toxiproxyr
is only a Suggests
packagetoxiproxyr::skip_if_no_toxiproxy_server()
which will skip tests if toxiproxy server is running (such as on CRAN)tox
in a test block, consider adding on.exit(tox$destroy())
to ensure that it is removed at the end of the test block, even if it failsAfter that, things continue much as normal.
The .toxiproxy
directory will hold a copy of the toxiproxy
server binary; that is downloaded by the toxiproxyr:::toxiproxy_start_ci
function. It then starts a copy of the server and saves the log into the .toxiproxy
directory.
The toxiproxyr:::toxiproxy_start_ci
function looks two environment variables to control its behaviour:
TOXIPROXY_PORT
: port to run toxiproxy on (default: 8474)TOXIPROXY_VERSION
: version of toxiproxy run run (default: 2.0.0)You can set these via your continuous integration's environment variables settting if you need them to be set differently
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.