(c config)
| 288 | } |
| 289 | |
| 290 | func 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 | } |
no test coverage detected
searching dependent graphs…