Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traffic generator V2 #1055

Merged
merged 14 commits into from
Jan 14, 2025
Prev Previous commit
Next Next commit
fix lint
  • Loading branch information
dmanc committed Jan 10, 2025
commit a8cdba3e21ac9bb5b2c3fa1917bbb20078b73b95
4 changes: 3 additions & 1 deletion tools/traffic/cmd2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func trafficGeneratorMain(ctx *cli.Context) error {
return err
case sig := <-sigChan:
fmt.Printf("\nReceived signal %v, shutting down...\n", sig)
generator.Stop()
if err := generator.Stop(); err != nil {
fmt.Printf("Failed to stop generator: %v\n", err)
}
return nil
}
}
4 changes: 3 additions & 1 deletion tools/traffic/generator_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ func (generator *Generator) handleConfigUpdate(runtimeConfig *trafficconfig.Runt
// Start instantiates goroutines that generate read/write traffic.
func (generator *Generator) Start() error {
// Start metrics server
generator.generatorMetrics.Start()
if err := generator.generatorMetrics.Start(); err != nil {
return fmt.Errorf("failed to start metrics server: %w", err)
}

// Start runtime config watcher if configured
if generator.configManager != nil {
Expand Down
3 changes: 0 additions & 3 deletions tools/traffic/workers/blob_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ type BlobWriter struct {

// Ticker for controlling write intervals
ticker *time.Ticker

// cancel is used to cancel the context
cancel *context.CancelFunc
}

// NewBlobWriter creates a new BlobWriter instance.
Expand Down
7 changes: 6 additions & 1 deletion tools/traffic/workers/blob_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ func TestBlobWriter(t *testing.T) {
).Return(&status, keyToReturn, errorToReturn)

// Simulate the advancement of time (i.e. allow the writer to write the next blob).
writer.writeNextBlob()
err = writer.writeNextBlob()
if errorToReturn != nil {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}

disperserClient.mock.AssertNumberOfCalls(t, "DisperseBlob", 1)

Expand Down
Loading