class_docstr: Test Benchmark creation
docstr: Test creation in race condition
docstr_tok: ["Test","creation","in","race","condition"]
code: def test_create_race_condition(
      self, benchmark_config, benchmark_config_py, monkeypatch, caplog
  ):
      """Test creation in race condition"""
      with OrionState(benchmarks=benchmark_config) as cfg:
  
          def insert_race_condition(*args, **kwargs):
              if insert_race_condition.count == 0:
                  data = {}
              else:
                  data = benchmark_config
  
              insert_race_condition.count += 1
  
              return data
  
          insert_race_condition.count = 0
          monkeypatch.setattr(
              benchmark_client,
              "_fetch_benchmark",
              insert_race_condition,
          )
  
          with caplog.at_level(
              logging.INFO, logger="orion.benchmark.benchmark_client"
          ):
              bm = benchmark_client.get_or_create_benchmark(
                  cfg.storage, **benchmark_config_py
              )
              bm.close()
  
          assert (
              "Benchmark registration failed. This is likely due to a race condition. "
              "Now rolling back and re-attempting building it."
              in caplog.text
          )
          assert insert_race_condition.count == 2
  
          del benchmark_config["_id"]
  
          assert bm.configuration == benchmark_config
          assert count_benchmarks() == 1
  
imports: import copy
  import logging
  import pytest
  import orion.benchmark.benchmark_client
  import orion.core
  from orion.benchmark.assessment import AverageResult
  from orion.benchmark.benchmark_client import get_or_create_benchmark
  from orion.benchmark.task import CarromTable, RosenBrock
  from orion.client import ExperimentClient
  from orion.core.utils.exceptions import NoConfigurationError
  from orion.executor.joblib_backend import Joblib
  from orion.storage.base import setup_storage
  from orion.testing.state import OrionState
label_desc: Use image node_id 10 for calling the TestCreateBenchmark obj's underlying member method code with example usage: obj.test_create_race_condition(benchmark_config, benchmark_config_py, monkeypatch, caplog) and returns: data