5
5
"github.com/openziti/zrok/environment"
6
6
"github.com/sirupsen/logrus"
7
7
"github.com/spf13/cobra"
8
+ "math/rand"
8
9
"os"
9
10
"os/signal"
10
11
"syscall"
@@ -23,6 +24,8 @@ type testCanaryPeriodicCommand struct {
23
24
timeout time.Duration
24
25
minPayload uint64
25
26
maxPayload uint64
27
+ minPreDelay time.Duration
28
+ maxPreDelay time.Duration
26
29
minDwell time.Duration
27
30
maxDwell time.Duration
28
31
minPacing time.Duration
@@ -44,6 +47,8 @@ func newTestCanaryPeriodicCommand() *testCanaryPeriodicCommand {
44
47
cmd .Flags ().DurationVarP (& command .timeout , "timeout" , "T" , 30 * time .Second , "Timeout when sending HTTP requests" )
45
48
cmd .Flags ().Uint64Var (& command .minPayload , "min-payload" , 64 , "Minimum payload size in bytes" )
46
49
cmd .Flags ().Uint64Var (& command .maxPayload , "max-payload" , 10240 , "Maximum payload size in bytes" )
50
+ cmd .Flags ().DurationVar (& command .minPreDelay , "min-pre-delay" , 0 , "Minimum pre-delay before creating the next looper" )
51
+ cmd .Flags ().DurationVar (& command .maxPreDelay , "max-pre-delay" , 0 , "Maximum pre-delay before creating the next looper" )
47
52
cmd .Flags ().DurationVar (& command .minDwell , "min-dwell" , 1 * time .Second , "Minimum dwell time" )
48
53
cmd .Flags ().DurationVar (& command .maxDwell , "max-dwell" , 1 * time .Second , "Maximum dwell time" )
49
54
cmd .Flags ().DurationVar (& command .minPacing , "min-pacing" , 0 , "Minimum pacing time" )
@@ -64,6 +69,13 @@ func (cmd *testCanaryPeriodicCommand) run(_ *cobra.Command, _ []string) {
64
69
65
70
var loopers []* canary.PublicHttpLooper
66
71
for i := uint (0 ); i < cmd .loopers ; i ++ {
72
+ preDelay := cmd .maxPreDelay .Milliseconds ()
73
+ preDelayDelta := cmd .maxPreDelay .Milliseconds () - cmd .minPreDelay .Milliseconds ()
74
+ if preDelayDelta > 0 {
75
+ preDelay = int64 (rand .Intn (int (preDelayDelta ))) + cmd .minPreDelay .Milliseconds ()
76
+ time .Sleep (time .Duration (preDelay ) * time .Millisecond )
77
+ }
78
+
67
79
looperOpts := & canary.LooperOptions {
68
80
Iterations : cmd .iterations ,
69
81
StatusInterval : cmd .statusInterval ,
0 commit comments