-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuite.go
47 lines (39 loc) · 982 Bytes
/
suite.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cmd
import (
"github.com/JamesBalazs/lode/internal/lode"
"github.com/spf13/cobra"
)
var dryRun bool
// suiteCmd represents the suite command
var suiteCmd = &cobra.Command{
Use: "suite",
Short: "Run a test suite from a YAML file",
Long: `Run a series of predefined load tests from a YAML file, for CI/automation use.
e.g. lode suite examples/suite.yaml
Example YAML format:
tests:
- url: https://www.google.co.uk
method: GET
concurrency: 4
freq: 10
maxrequests: 20
- url: https://abc.xyz/
method: GET
concurrency: 2
delay: 0.5s
maxrequests: 4
headers:
- SomeHeader=someValue
- OtherHeader=otherValue`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
suite := lode.SuiteFromFile(args[0])
if !dryRun {
suite.Run()
}
},
}
func init() {
rootCmd.AddCommand(suiteCmd)
suiteCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Validate YAML file without running the test suite")
}