Skip to content

Commit 31fa8be

Browse files
committed
address PR comments
1 parent 4f165be commit 31fa8be

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

scaletest/trafficgen/run.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package trafficgen
22

33
import (
4-
"bytes"
54
"context"
65
"encoding/json"
76
"io"
@@ -50,8 +49,8 @@ func (r *Runner) Run(ctx context.Context, _ string, logs io.Writer) error {
5049
var (
5150
agentID = r.cfg.AgentID
5251
reconnect = uuid.New()
53-
height uint16 = 65535
54-
width uint16 = 65535
52+
height uint16 = 25
53+
width uint16 = 80
5554
tickInterval = r.cfg.TicksPerSecond
5655
bytesPerTick = r.cfg.BytesPerSecond / r.cfg.TicksPerSecond
5756
)
@@ -74,7 +73,8 @@ func (r *Runner) Run(ctx context.Context, _ string, logs io.Writer) error {
7473
return xerrors.Errorf("connect to workspace: %w", err)
7574
}
7675

77-
defer func() {
76+
go func() {
77+
<-deadlineCtx.Done()
7878
logger.Debug(ctx, "close agent connection", slog.F("agent_id", agentID))
7979
_ = conn.Close()
8080
}()
@@ -87,8 +87,8 @@ func (r *Runner) Run(ctx context.Context, _ string, logs io.Writer) error {
8787
defer tick.Stop()
8888

8989
// Now we begin writing random data to the pty.
90-
rch := make(chan error)
91-
wch := make(chan error)
90+
rch := make(chan error, 1)
91+
wch := make(chan error, 1)
9292

9393
go func() {
9494
<-deadlineCtx.Done()
@@ -141,14 +141,12 @@ func drainContext(ctx context.Context, src io.Reader, bufSize int64) error {
141141
errCh := make(chan error, 1)
142142
done := make(chan struct{})
143143
go func() {
144-
tmp := make([]byte, bufSize)
145-
buf := bytes.NewBuffer(tmp)
146144
for {
147145
select {
148146
case <-done:
149147
return
150148
default:
151-
_, err := io.CopyN(buf, src, 1)
149+
_, err := io.CopyN(io.Discard, src, 1)
152150
if ctx.Err() != nil {
153151
return // context canceled while we were copying.
154152
}

0 commit comments

Comments
 (0)