MCPcopy
hub / github.com/containerd/containerd / criTest

Function criTest

cmd/containerd-stress/main.go:290–369  ·  view source on GitHub ↗
(c config)

Source from the content-addressed store, hash-verified

288}
289
290func criTest(c config) error {
291 var (
292 timeout = 1 * time.Minute
293 wg sync.WaitGroup
294 ctx = namespaces.WithNamespace(context.Background(), stressNs)
295 )
296
297 client, err := remote.NewRuntimeService(c.Address, timeout)
298 if err != nil {
299 return fmt.Errorf("failed to create runtime service: %w", err)
300 }
301 defer func() {
302 if err := client.Close(context.Background()); err != nil {
303 log.L.WithError(err).Warn("failed to close CRI runtime client")
304 }
305 }()
306
307 if err := criCleanup(ctx, client); err != nil {
308 return err
309 }
310
311 tctx, cancel := context.WithTimeout(ctx, c.Duration)
312 go func() {
313 s := make(chan os.Signal, 1)
314 signal.Notify(s, syscall.SIGTERM, syscall.SIGINT)
315 <-s
316 cancel()
317 }()
318
319 // get runtime version:
320 version, err := client.Version("")
321 if err != nil {
322 return fmt.Errorf("failed to get runtime version: %w", err)
323 }
324 var (
325 workers []worker
326 r = &run{}
327 )
328 log.L.Info("starting stress test run...")
329 // create the workers along with their spec
330 for i := 0; i < c.Concurrency; i++ {
331 wg.Add(1)
332 w := &criWorker{
333 id: i,
334 wg: &wg,
335 client: client,
336 commit: fmt.Sprintf("%s-%s", version.RuntimeName, version.RuntimeVersion),
337 runtimeHandler: c.Runtime,
338 snapshotter: c.Snapshotter,
339 }
340 workers = append(workers, w)
341 }
342
343 // start the timer and run the worker
344 r.start()
345 for _, w := range workers {
346 go w.run(ctx, tctx)
347 }

Callers 2

mainFunction · 0.85
serveFunction · 0.85

Calls 12

CloseMethod · 0.95
VersionMethod · 0.95
runMethod · 0.95
WithNamespaceFunction · 0.92
NewRuntimeServiceFunction · 0.92
criCleanupFunction · 0.85
endMethod · 0.80
gatherMethod · 0.80
InfoMethod · 0.65
AddMethod · 0.65
WaitMethod · 0.65
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…