Skip to main content
Version: v1.6.0

Creating a test environment

You need a test environment for several reasons:

  • Creation of new parsers or scenarios
  • Testing new features or in general
  • Showcase a bug or a corner-case

This can be done directly with the tarball of the release :

VER=1.4.6 # Please check for latest version
tar xvzf crowdsec-release.tgz
cd crowdsec-v$VER

You receive a directory structure like this:

|- cmd
| |- crowdsec
| |- crowdsec-cli
|- config
| |- patterns
|- plugins
| |- notifications
|- tests
|- config
|- data
|- logs
|- plugins

The test environment is available in the folder tests and provides a functional CrowdSec environment :

cd tests
./crowdsec -c dev.yaml

cscli should be functional as well :

cd tests
./cscli -c dev.yaml hub list

In the test environment the configurations are in the folder config/.

Add hub repository to test environment

You only need to add this if you want to develop parsers and scenarios

# cd tests # if you are already in tests no need to cd
git clone
cd hub

Great! since we cloned the hub repository we can now run cscli commands within here for example:

../cscli -c ../dev.yaml hubtest run --all

That command will now run all tests within the hub repository. Please take note about the ../ infront of cscli and dev.yaml as these are in the folder above our current working directory.

A helpful tip to save you typing the whole command everytime is to set an shell alias example:

alias csdev="$(dirname $PWD)/cscli -c $(dirname $PWD)/dev.yaml"

Then you can run command as

csdev hubtest run --all

However, this is temporary alias set within the shell so please add to .bashrc or your shell equivalent.