README.md

toxiproxyr.test

Linux Build Status Windows Build status

This repo exists to show how to use toxiproxy and toxiproxyr for continuous integration.

Configuring a project to use toxiproxyr

The key bits needed are:

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.

^\.toxiproxy$
before_script:
  - Rscript -e 'toxiproxyr:::toxiproxy_start_ci(".toxiproxy")'

The path .toxiproxy here can be anything but must match what you use in .Rbuildignore

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

  1. Begin any test block that uses toxiproxy with skip_if_not_installed("toxiproxyr") because toxiproxyr is only a Suggests package
  2. Follow this with toxiproxyr::skip_if_no_toxiproxy_server() which will skip tests if toxiproxy server is running (such as on CRAN)
  3. If you create a proxy 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 fails

After that, things continue much as normal.

What the steps above do

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:

You can set these via your continuous integration's environment variables settting if you need them to be set differently



richfitz/toxiproxyr.test documentation built on May 27, 2019, 8:43 a.m.