Merge pull request #2720 from crosbymichael/stress-root

Fix stress test for image config opt requirements
This commit is contained in:
Michael Crosby 2018-10-15 21:17:12 -04:00 committed by GitHub
commit fdc4e1f426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 35 deletions

View File

@ -18,7 +18,6 @@ package main
import ( import (
"context" "context"
"path/filepath"
"strings" "strings"
"syscall" "syscall"
"time" "time"
@ -39,14 +38,9 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
w.wg.Done() w.wg.Done()
logrus.Infof("worker %d finished", w.id) logrus.Infof("worker %d finished", w.id)
}() }()
// create and start the exec container
w.spec.Linux.CgroupsPath = filepath.Join("/", "stress", "exec-container")
w.spec.Process.Args = []string{
"sleep", "30d",
}
c, err := w.client.NewContainer(ctx, "exec-container", c, err := w.client.NewContainer(ctx, "exec-container",
containerd.WithNewSnapshot("exec-container", w.image), containerd.WithNewSnapshot("exec-container", w.image),
containerd.WithSpec(w.spec, oci.WithUsername("games")), containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("sleep", "30d")),
) )
if err != nil { if err != nil {
logrus.WithError(err).Error("create exec container") logrus.WithError(err).Error("create exec container")
@ -66,8 +60,13 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
logrus.WithError(err).Error("wait exec container's task") logrus.WithError(err).Error("wait exec container's task")
return return
} }
spec, err := c.Spec(ctx)
if err != nil {
logrus.WithError(err).Error("failed to get spec")
return
}
pspec := w.spec.Process pspec := spec.Process
pspec.Args = []string{"true"} pspec.Args = []string{"true"}
for { for {

View File

@ -29,9 +29,7 @@ import (
"time" "time"
"github.com/containerd/containerd" "github.com/containerd/containerd"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
metrics "github.com/docker/go-metrics" metrics "github.com/docker/go-metrics"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli" "github.com/urfave/cli"
@ -227,7 +225,6 @@ func test(c config) error {
if err != nil { if err != nil {
return err return err
} }
logrus.Info("generating spec from image")
tctx, cancel := context.WithTimeout(ctx, c.Duration) tctx, cancel := context.WithTimeout(ctx, c.Duration)
go func() { go func() {
s := make(chan os.Signal, 1) s := make(chan os.Signal, 1)
@ -241,7 +238,6 @@ func test(c config) error {
r = &run{} r = &run{}
) )
logrus.Info("starting stress test run...") logrus.Info("starting stress test run...")
args := oci.WithProcessArgs("true")
v, err := client.Version(ctx) v, err := client.Version(ctx)
if err != nil { if err != nil {
return err return err
@ -249,18 +245,9 @@ func test(c config) error {
// create the workers along with their spec // create the workers along with their spec
for i := 0; i < c.Concurrency; i++ { for i := 0; i < c.Concurrency; i++ {
wg.Add(1) wg.Add(1)
spec, err := oci.GenerateSpec(ctx, client,
&containers.Container{},
oci.WithImageConfig(image),
args,
)
if err != nil {
return err
}
w := &worker{ w := &worker{
id: i, id: i,
wg: &wg, wg: &wg,
spec: spec,
image: image, image: image,
client: client, client: client,
commit: v.Revision, commit: v.Revision,
@ -270,19 +257,10 @@ func test(c config) error {
var exec *execWorker var exec *execWorker
if c.Exec { if c.Exec {
wg.Add(1) wg.Add(1)
spec, err := oci.GenerateSpec(ctx, client,
&containers.Container{},
oci.WithImageConfig(image),
args,
)
if err != nil {
return err
}
exec = &execWorker{ exec = &execWorker{
worker: worker{ worker: worker{
id: c.Concurrency, id: c.Concurrency,
wg: &wg, wg: &wg,
spec: spec,
image: image, image: image,
client: client, client: client,
commit: v.Revision, commit: v.Revision,

View File

@ -19,7 +19,6 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"path/filepath"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -27,7 +26,6 @@ import (
"github.com/containerd/containerd" "github.com/containerd/containerd"
"github.com/containerd/containerd/cio" "github.com/containerd/containerd/cio"
"github.com/containerd/containerd/oci" "github.com/containerd/containerd/oci"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -39,7 +37,6 @@ type worker struct {
client *containerd.Client client *containerd.Client
image containerd.Image image containerd.Image
spec *specs.Spec
commit string commit string
} }
@ -76,10 +73,9 @@ func (w *worker) run(ctx, tctx context.Context) {
func (w *worker) runContainer(ctx context.Context, id string) (err error) { func (w *worker) runContainer(ctx context.Context, id string) (err error) {
// fix up cgroups path for a default config // fix up cgroups path for a default config
w.spec.Linux.CgroupsPath = filepath.Join("/", "stress", id)
c, err := w.client.NewContainer(ctx, id, c, err := w.client.NewContainer(ctx, id,
containerd.WithNewSnapshot(id, w.image), containerd.WithNewSnapshot(id, w.image),
containerd.WithSpec(w.spec, oci.WithUsername("games")), containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("true")),
) )
if err != nil { if err != nil {
return err return err