Skip to content

Commit 1945e26

Browse files
committed
Add concurrent execs in stress tests
Signed-off-by: Michael Crosby <[email protected]>
1 parent ffa86b2 commit 1945e26

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

cmd/containerd-stress/exec_worker.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"strings"
2223
"syscall"
2324
"time"
@@ -38,8 +39,9 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
3839
w.wg.Done()
3940
logrus.Infof("worker %d finished", w.id)
4041
}()
41-
c, err := w.client.NewContainer(ctx, "exec-container",
42-
containerd.WithNewSnapshot("exec-container", w.image),
42+
id := fmt.Sprintf("exec-container-%d", w.id)
43+
c, err := w.client.NewContainer(ctx, id,
44+
containerd.WithNewSnapshot(id, w.image),
4345
containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("sleep", "30d")),
4446
)
4547
if err != nil {

cmd/containerd-stress/main.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,19 @@ func test(c config) error {
257257
}
258258
var exec *execWorker
259259
if c.Exec {
260-
wg.Add(1)
261-
exec = &execWorker{
262-
worker: worker{
263-
id: c.Concurrency,
264-
wg: &wg,
265-
image: image,
266-
client: client,
267-
commit: v.Revision,
268-
},
260+
for i := c.Concurrency; i < c.Concurrency+c.Concurrency; i++ {
261+
wg.Add(1)
262+
exec = &execWorker{
263+
worker: worker{
264+
id: i,
265+
wg: &wg,
266+
image: image,
267+
client: client,
268+
commit: v.Revision,
269+
},
270+
}
271+
go exec.exec(ctx, tctx)
269272
}
270-
go exec.exec(ctx, tctx)
271273
}
272274

273275
// start the timer and run the worker

0 commit comments

Comments
 (0)