File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed
Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,6 @@ func CommandServe(cfg *config.Config) *cli.Command {
8787 EnvVars : []string {envPrefix + strings .ToUpper (categoryChaos + "_" + category ) + "_MIN_INJECTED_LATENCY" },
8888 Name : categoryChaos + "-" + category + "-min-injected-latency" ,
8989 Usage : "min `latency` to enforce on every response processed by " + category + " proxy" ,
90- Value : 100 * time .Millisecond ,
9190 },
9291
9392 & cli.DurationFlag { // --chaos-xxx-max-injected-latency
@@ -382,7 +381,6 @@ func CommandServe(cfg *config.Config) *cli.Command {
382381 EnvVars : []string {envPrefix + strings .ToUpper (categoryChaos ) + "_FLASHBLOCKS_MIN_INJECTED_LATENCY" },
383382 Name : categoryChaos + "-flashblocks-min-injected-latency" ,
384383 Usage : "min `latency` to enforce on every response processed by flashblocks proxy" ,
385- Value : 100 * time .Millisecond ,
386384 },
387385
388386 & cli.DurationFlag { // --chaos-flashblocks-max-injected-latency
Original file line number Diff line number Diff line change @@ -583,12 +583,14 @@ func (p *HTTP) execProxyJob(job *proxyJob) {
583583 }
584584
585585 if p .cfg .proxy .Chaos .Enabled { // chaos-inject latency
586- loggedFields = append (loggedFields ,
587- zap .Bool ("chaos_injected_latency" , true ),
588- )
589- latency := time .Duration (rand .Int64N (int64 (p .cfg .proxy .Chaos .MaxInjectedLatency ) + 1 ))
590- latency = max (latency , p .cfg .proxy .Chaos .MinInjectedLatency )
591- time .Sleep (latency - time .Since (job .tsReqReceived ))
586+ if p .cfg .proxy .Chaos .MinInjectedLatency > 0 || p .cfg .proxy .Chaos .MaxInjectedLatency > 0 {
587+ loggedFields = append (loggedFields ,
588+ zap .Bool ("chaos_injected_latency" , true ),
589+ )
590+ latency := time .Duration (rand .Int64N (int64 (p .cfg .proxy .Chaos .MaxInjectedLatency ) + 1 ))
591+ latency = max (latency , p .cfg .proxy .Chaos .MinInjectedLatency )
592+ time .Sleep (latency - time .Since (job .tsReqReceived ))
593+ }
592594 }
593595
594596 { // add log fields
Original file line number Diff line number Diff line change @@ -193,12 +193,14 @@ func (p *websocketPump) pumpMessages(
193193 }
194194
195195 { // chaos-inject latency
196- loggedFields = append (loggedFields ,
197- zap .Bool ("chaos_injected_latency" , true ),
198- )
199- latency := time .Duration (rand .Int64N (int64 (p .cfg .proxy .Chaos .MaxInjectedLatency ) + 1 ))
200- latency = max (latency , p .cfg .proxy .Chaos .MinInjectedLatency )
201- time .Sleep (latency - time .Since (m .ts ))
196+ if p .cfg .proxy .Chaos .MinInjectedLatency > 0 || p .cfg .proxy .Chaos .MaxInjectedLatency > 0 {
197+ loggedFields = append (loggedFields ,
198+ zap .Bool ("chaos_injected_latency" , true ),
199+ )
200+ latency := time .Duration (rand .Int64N (int64 (p .cfg .proxy .Chaos .MaxInjectedLatency ) + 1 ))
201+ latency = max (latency , p .cfg .proxy .Chaos .MinInjectedLatency )
202+ time .Sleep (latency - time .Since (m .ts ))
203+ }
202204 }
203205 }
204206
You can’t perform that action at this time.
0 commit comments