Skip to content

Commit

Permalink
plumbing for the 'zrok test canary' commands (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Oct 30, 2024
1 parent 3cf98fc commit 5bee2bb
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 24 deletions.
22 changes: 14 additions & 8 deletions cmd/zrok/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func init() {
adminCmd.AddCommand(adminDeleteCmd)
adminCmd.AddCommand(adminListCmd)
adminCmd.AddCommand(adminUpdateCmd)
testCmd.AddCommand(loopCmd)
testCmd.AddCommand(testCanaryCmd)
testCmd.AddCommand(testLoopCmd)
rootCmd.AddCommand(adminCmd)
rootCmd.AddCommand(configCmd)
rootCmd.AddCommand(modifyCmd)
Expand Down Expand Up @@ -82,12 +83,6 @@ var configCmd = &cobra.Command{
Short: "Configure your zrok environment",
}

var loopCmd = &cobra.Command{
Use: "loopback",
Aliases: []string{"loop"},
Short: "Loopback testing utilities",
}

var modifyCmd = &cobra.Command{
Use: "modify",
Aliases: []string{"mod"},
Expand All @@ -101,7 +96,18 @@ var shareCmd = &cobra.Command{

var testCmd = &cobra.Command{
Use: "test",
Short: "Utilities for testing zrok deployments",
Short: "Utilities for testing deployments",
}

var testCanaryCmd = &cobra.Command{
Use: "canary",
Short: "Utilities for performance management",
}

var testLoopCmd = &cobra.Command{
Use: "loopback",
Aliases: []string{"loop"},
Short: "Loopback testing utilities",
}

func main() {
Expand Down
29 changes: 29 additions & 0 deletions cmd/zrok/testCanaryPeriodic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

func init() {
testCanaryCmd.AddCommand(newTestCanaryPeriodicCommand().cmd)
}

type testCanaryPeriodicCommand struct {
cmd *cobra.Command
}

func newTestCanaryPeriodicCommand() *testCanaryPeriodicCommand {
cmd := &cobra.Command{
Use: "periodic",
Short: "Run a periodic canary inspection",
Args: cobra.NoArgs,
}
command := &testCanaryPeriodicCommand{cmd: cmd}
cmd.Run = command.run
return command
}

func (c *testCanaryPeriodicCommand) run(_ *cobra.Command, _ []string) {
logrus.Info("periodic")
}
32 changes: 16 additions & 16 deletions cmd/zrok/testLoopPublic.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

func init() {
loopCmd.AddCommand(newTestLoopPublicCommand().cmd)
testLoopCmd.AddCommand(newTestLoopPublicCommand().cmd)
}

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

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

0 comments on commit 5bee2bb

Please sign in to comment.