code: def stress_test(storage, space_type, workers, size):
      """Spawn workers and run stress test with verifications
  
      Parameters
      ----------
      storage: str
          See `get_experiment`.
      space_type: str
          See `get_experiment`.
      workers: int
          Number of workers to run in parallel.
      size: int
          See `get_experiment`.
  
      Returns
      -------
      `list` of `orion.core.worker.trial.Trial`
          List of all trials at the end of the stress test
  
      """
      if storage == "pickleddb":
          if os.path.exists(DB_FILE):
              os.remove(DB_FILE)
      elif storage == "mongodb":
          client = MongoClient(
              username="user", password="pass", authSource="stress"
          )
          database = client.stress
          database.experiments.drop()
          database.lying_trials.drop()
          database.trials.drop()
          database.workers.drop()
          database.resources.drop()
          client.close()
  
      print("Worker  |  Point")
  
      with Pool(workers) as p:
          results = p.starmap(
              worker,
              zip(
                  range(workers),
                  [storage] * workers,
                  [space_type] * workers,
                  [size] * workers,
              ),
          )
  
      assert (
          None not in results
      ), "A worker crashed unexpectedly. See logs for the error messages."
      assert all(
          n > 0 for n in results
      ), "A worker could not execute any trial."
  
      if space_type in ["discrete", "real-seeded"]:
          assert sum(results) == size, results
      else:
          assert sum(results) >= size, results
  
      experiment = get_experiment(storage, space_type, size)
  
      trials = experiment.fetch_trials()
  
      if storage == "pickleddb":
          os.remove(DB_FILE)
      elif storage == "mongodb":
          client = MongoClient(
              username="user", password="pass", authSource="stress"
          )
          database = client.stress
          database.experiments.drop()
          database.lying_trials.drop()
          database.trials.drop()
          database.workers.drop()
          database.resources.drop()
          client.close()
  
      return trials
  
file_path: orion/tests/stress/client/stress_experiment.py
imports: import os
  import random
  import time
  import traceback
  from multiprocessing import Pool
  import matplotlib.pyplot
  from pymongo import MongoClient
  from orion.client import create_experiment
  from orion.core.io.database import DatabaseTimeout
  from orion.core.utils.exceptions import ReservationTimeout
label_desc: Use image node_id 4 for calling a global function with example usage: stress_test(storage, space_type, workers, size) and returns: trials