Skip to content

Commit 5bee2bb

Browse files
plumbing for the 'zrok test canary' commands (#771)
1 parent 3cf98fc commit 5bee2bb

File tree

3 files changed

+59
-24
lines changed

3 files changed

+59
-24
lines changed

cmd/zrok/main.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ func init() {
2424
adminCmd.AddCommand(adminDeleteCmd)
2525
adminCmd.AddCommand(adminListCmd)
2626
adminCmd.AddCommand(adminUpdateCmd)
27-
testCmd.AddCommand(loopCmd)
27+
testCmd.AddCommand(testCanaryCmd)
28+
testCmd.AddCommand(testLoopCmd)
2829
rootCmd.AddCommand(adminCmd)
2930
rootCmd.AddCommand(configCmd)
3031
rootCmd.AddCommand(modifyCmd)
@@ -82,12 +83,6 @@ var configCmd = &cobra.Command{
8283
Short: "Configure your zrok environment",
8384
}
8485

85-
var loopCmd = &cobra.Command{
86-
Use: "loopback",
87-
Aliases: []string{"loop"},
88-
Short: "Loopback testing utilities",
89-
}
90-
9186
var modifyCmd = &cobra.Command{
9287
Use: "modify",
9388
Aliases: []string{"mod"},
@@ -101,7 +96,18 @@ var shareCmd = &cobra.Command{
10196

10297
var testCmd = &cobra.Command{
10398
Use: "test",
104-
Short: "Utilities for testing zrok deployments",
99+
Short: "Utilities for testing deployments",
100+
}
101+
102+
var testCanaryCmd = &cobra.Command{
103+
Use: "canary",
104+
Short: "Utilities for performance management",
105+
}
106+
107+
var testLoopCmd = &cobra.Command{
108+
Use: "loopback",
109+
Aliases: []string{"loop"},
110+
Short: "Loopback testing utilities",
105111
}
106112

107113
func main() {

cmd/zrok/testCanaryPeriodic.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"github.com/sirupsen/logrus"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
func init() {
9+
testCanaryCmd.AddCommand(newTestCanaryPeriodicCommand().cmd)
10+
}
11+
12+
type testCanaryPeriodicCommand struct {
13+
cmd *cobra.Command
14+
}
15+
16+
func newTestCanaryPeriodicCommand() *testCanaryPeriodicCommand {
17+
cmd := &cobra.Command{
18+
Use: "periodic",
19+
Short: "Run a periodic canary inspection",
20+
Args: cobra.NoArgs,
21+
}
22+
command := &testCanaryPeriodicCommand{cmd: cmd}
23+
cmd.Run = command.run
24+
return command
25+
}
26+
27+
func (c *testCanaryPeriodicCommand) run(_ *cobra.Command, _ []string) {
28+
logrus.Info("periodic")
29+
}

cmd/zrok/testLoopPublic.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
)
2929

3030
func init() {
31-
loopCmd.AddCommand(newTestLoopPublicCommand().cmd)
31+
testLoopCmd.AddCommand(newTestLoopPublicCommand().cmd)
3232
}
3333

3434
type testLoopPublicCommand struct {
@@ -50,22 +50,22 @@ func newTestLoopPublicCommand() *testLoopPublicCommand {
5050
cmd := &cobra.Command{
5151
Use: "public",
5252
Short: "Start a loop agent testing public proxy shares",
53-
Args: cobra.ExactArgs(0),
53+
Args: cobra.NoArgs,
5454
}
55-
r := &testLoopPublicCommand{cmd: cmd}
56-
cmd.Run = r.run
57-
cmd.Flags().IntVarP(&r.loopers, "loopers", "l", 1, "Number of current loopers to start")
58-
cmd.Flags().IntVarP(&r.iterations, "iterations", "i", 1, "Number of iterations per looper")
59-
cmd.Flags().IntVarP(&r.statusEvery, "status-every", "E", 100, "Show status every # iterations")
60-
cmd.Flags().IntVarP(&r.timeoutSeconds, "timeout-seconds", "T", 30, "Time out after # seconds when sending http requests")
61-
cmd.Flags().IntVar(&r.minPayload, "min-payload", 64, "Minimum payload size in bytes")
62-
cmd.Flags().IntVar(&r.maxPayload, "max-payload", 10240, "Maximum payload size in bytes")
63-
cmd.Flags().IntVar(&r.minDwellMs, "min-dwell-ms", 1000, "Minimum dwell time in milliseconds")
64-
cmd.Flags().IntVar(&r.maxDwellMs, "max-dwell-ms", 1000, "Maximum dwell time in milliseconds")
65-
cmd.Flags().IntVar(&r.minPacingMs, "min-pacing-ms", 0, "Minimum pacing in milliseconds")
66-
cmd.Flags().IntVar(&r.maxPacingMs, "max-pacing-ms", 0, "Maximum pacing in milliseconds")
67-
cmd.Flags().StringArrayVar(&r.frontendSelection, "frontends", []string{"public"}, "Selected frontends to use for the share")
68-
return r
55+
command := &testLoopPublicCommand{cmd: cmd}
56+
cmd.Run = command.run
57+
cmd.Flags().IntVarP(&command.loopers, "loopers", "l", 1, "Number of current loopers to start")
58+
cmd.Flags().IntVarP(&command.iterations, "iterations", "i", 1, "Number of iterations per looper")
59+
cmd.Flags().IntVarP(&command.statusEvery, "status-every", "E", 100, "Show status every # iterations")
60+
cmd.Flags().IntVarP(&command.timeoutSeconds, "timeout-seconds", "T", 30, "Time out after # seconds when sending http requests")
61+
cmd.Flags().IntVar(&command.minPayload, "min-payload", 64, "Minimum payload size in bytes")
62+
cmd.Flags().IntVar(&command.maxPayload, "max-payload", 10240, "Maximum payload size in bytes")
63+
cmd.Flags().IntVar(&command.minDwellMs, "min-dwell-ms", 1000, "Minimum dwell time in milliseconds")
64+
cmd.Flags().IntVar(&command.maxDwellMs, "max-dwell-ms", 1000, "Maximum dwell time in milliseconds")
65+
cmd.Flags().IntVar(&command.minPacingMs, "min-pacing-ms", 0, "Minimum pacing in milliseconds")
66+
cmd.Flags().IntVar(&command.maxPacingMs, "max-pacing-ms", 0, "Maximum pacing in milliseconds")
67+
cmd.Flags().StringArrayVar(&command.frontendSelection, "frontends", []string{"public"}, "Selected frontends to use for the share")
68+
return command
6969
}
7070

7171
func (cmd *testLoopPublicCommand) run(_ *cobra.Command, _ []string) {

0 commit comments

Comments
 (0)