Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Root = &cobra.Command{
Use: "redalert",
Short: "Validate system state.",
}
Root CLI command. This should have no functionality.
var Run = &cobra.Command{ Use: "run", Short: "Run tests against this system.", Run: func(cmd *cobra.Command, args []string) { var err error var testsFile testfile.TestFile if fileFlag == "" { testsFile, err = loadTestFile(findTestFile()) } else { testsFile, err = loadTestFile(fileFlag) } if err != nil { fmt.Println("ERROR:", err) os.Exit(1) } results := map[string]error{} for _, suite := range suites { tests := testsFile.TestsToRun(suite) loadedChecks, err := testfile.LoadChecks(tests) if err != nil { fmt.Println("ERROR: Unable to load checks:", err) continue } checksToRun := make(chan testfile.CheckToRun, len(loadedChecks)) checkResults := make(chan checkResult, len(loadedChecks)) for i := 0; i < runtime.NumCPU(); i++ { go runCheck(checksToRun, checkResults) } for _, c := range loadedChecks { checksToRun <- c } for i := 0; i < len(loadedChecks); i++ { result := <-checkResults results[result.Name] = result.Result } close(checksToRun) close(checkResults) } exitCode := 0 for name, result := range results { if result == nil { fmt.Printf("%s: SUCCESS\n", name) continue } fmt.Printf("%s: FAILURE\n%s\n", name, result) exitCode = 1 } os.Exit(exitCode) }, }
Run will simply run the tests. It takes zero to one arguments. If no arguments are given it looks for a tests.(yml|yaml) or redalert.(yml|yaml) in the local directory, in `$HOME/.redalert/` (`%APPDATA%\redalert` instead of `$HOME/.redalert` on windows.) and finally in `/etc/redalert/` (`C:\redalert` on windows).
It takes the following flags:
- `--quiet` only report test failures.
- `--jobs $VALUE` specify the number of parallel tests to run. Default to # of cores.
- `--test $TEST_NAME` specify a test by name to run, can be provided multiple times.
- `--suite $SUITE_NAME` which test suite to run, an [alias](#aliases) can be provided as the suite name. Can be provided multiple times. There is a default "all" alias which matches all tests and is used if `--suite` is not provided.
- `--file $FILE_PATH` in lieu of searching in directories you can specify a file using this flag. If provided the aliases.(yml|yaml) file will not be looked for but aliases in the file will still be loaded.
- `--output $FORMAT` specify the output format. Valid values: text, json, csv. Default: text
Run will attempt to load an additional file `aliases.(yml|yaml)` which specifies the available [aliases](#aliases). If not found aliases will be looked for as a key in the `tests.(yml|yaml)` according to the [aliases](#aliases) section.
Run will run tests in parallel.
Functions ¶
This section is empty.
Types ¶
This section is empty.