Command: test
The sentinel test
command runs policies against the Sentinel test framework.
To learn more about testing, see the testing policies page.
Usage
Usage: sentinel test [options] [PATH] ...
This command runs the defined test cases against a set of policies.
The test cases are expected to live at the path test/<policy>/*.[hcl|json]
relative
to the policy being tested. <policy>
should be the name of the policy
excluding the file extension. The files should be in the configuration
file structure. The test
key is used for
assertions. Test cases ignore the root level configuration file and must have
all required configuration provided in each test case.
The PATH arguments specified may be a list of zero or more files or directories.
When no arguments are given, it defaults to the current directory. When a
directory is given, all policies ending with the extension .sentinel
are
tested.
The command-line flags are all optional. The list of available flags are:
-color
- Enable or disable colorized output. Enabled by default if running interactively.-json
- Suppress normal output and output test results as a JSON document. See the testing JSON output section for more details.-run=regexp
- Run only tests matching the regular expression pattern. A/
splits policy name and test case name.-verbose
- Show tracing and log output for tests that succeed in addition to tests that fail. By default, traces and logs are only shown for tests that fail.-maxConcurrency
- Allows users to specify the number of tests to be run concurrently. Defaults to the number of logical CPUs if not provided. To run tests sequentially, use-maxConcurrency=1
-timeout
- Allows users to specify a timeout after which the test command will stop running. Defaults to 5 minutes if not provided. The timeout needs to be specified as a Duration type, eg100ms, 5s etc