class_docstr: run chaos
class_docstr_tok: ["run","chaos"]
code: def run_case(self, case_metric, **case_param):
      processing = case_param["processing"]
      after = case_param["after"]
      user_chaos = processing["chaos"]
      kind = user_chaos["kind"]
      spec = user_chaos["spec"]
      metadata_name = config.NAMESPACE + "-" + kind.lower()
      metadata = {"name": metadata_name}
      process_assertion = processing["assertion"]
      after_assertion = after["assertion"]
      # load yaml from default template to generate stand chaos dict
      chaos_mesh = kind_chaos_mapping[kind](
          config.DEFAULT_API_VERSION, kind, metadata, spec
      )
      experiment_config = chaos_mesh.gen_experiment_config()
      process_func = processing["interface_name"]
      process_params = (
          processing["params"] if "params" in processing else {}
      )
      after_func = after["interface_name"]
      after_params = after["params"] if "params" in after else {}
      logger.debug(chaos_mesh.kind)
      chaos_opt = ChaosOpt(chaos_mesh.kind)
      chaos_objects = chaos_opt.list_chaos_object()
      if len(chaos_objects["items"]) != 0:
          logger.debug(chaos_objects["items"])
          chaos_opt.delete_chaos_object(chaos_mesh.metadata["name"])
      # with open('./pod-newq.yaml', "w") as f:
      #     dump(experiment_config, f)
      #     f.close()
      # concurrent inject chaos and run func
      # logger.debug(experiment_config)
      t_milvus = threading.Thread(
          target=assert_func_mapping[process_assertion],
          args=(
              process_func,
              self.milvus,
          ),
          kwargs=process_params,
      )
      try:
          t_milvus.start()
          chaos_opt.create_chaos_object(experiment_config)
      # processing assert exception
      except Exception as e:
          logger.info("exception {}".format(str(e)))
      else:
          chaos_opt.delete_chaos_object(chaos_mesh.metadata["name"])
          # TODO retry connect milvus
          time.sleep(15)
          assert_func_mapping[after_assertion](
              after_func, self.milvus, **after_params
          )
      finally:
          chaos_opt.delete_all_chaos_object()
          logger.info(chaos_opt.list_chaos_object())
  
imports: import copy
  import logging
  import time
  from operator import methodcaller
  from yaml import full_load, dump
  import threading
  from milvus_benchmark import utils
  from milvus_benchmark.runners import utils
  from milvus_benchmark.chaos import utils
  from milvus_benchmark.runners.base import BaseRunner
  from chaos.chaos_opt import ChaosOpt
  from milvus_benchmark import config
  from milvus_benchmark.chaos.chaos_mesh import PodChaos, NetworkChaos
label_desc: Use image node_id 5 for calling the SimpleChaosRunner obj's underlying member method code with example usage: obj.run_case(case_metric) without return types