docstr: target: test compact after create index
  method: 1.insert binary data into two segments
          2.create binary index
          3.compact
          4.search
  expected: Verify segment info and index info
docstr_tok: ["target",":","test","compact","after","create","index","method",":","1.insert","binary","data","into","two","segments","2.create","binary","index","3.compact","4.search","expected",":","Verify","segment","info","and","index","info"]
code: def test_compact_after_binary_index(self):
      """
      target: test compact after create index
      method: 1.insert binary data into two segments
              2.create binary index
              3.compact
              4.search
      expected: Verify segment info and index info
      """
      # create collection with 1 shard and insert 2 segments
      collection_w = self.init_collection_wrap(
          name=cf.gen_unique_str(prefix),
          shards_num=1,
          schema=cf.gen_default_binary_collection_schema(),
      )
      for i in range(2):
          df, _ = cf.gen_default_binary_dataframe_data()
          collection_w.insert(data=df)
          assert collection_w.num_entities == (i + 1) * ct.default_nb
  
      # create index
      collection_w.create_index(
          ct.default_binary_vec_field_name, ct.default_binary_index
      )
      log.debug(collection_w.index())
  
      # load and search
      collection_w.load()
      search_params = {
          "metric_type": "JACCARD",
          "params": {"nprobe": 32},
      }
      search_res_one, _ = collection_w.search(
          df[ct.default_binary_vec_field_name][
              : ct.default_nq
          ].to_list(),
          ct.default_binary_vec_field_name,
          search_params,
          ct.default_limit,
      )
  
      # compact
      collection_w.compact()
      collection_w.wait_for_compaction_completed()
      c_plans = collection_w.get_compaction_plans(
          check_task=CheckTasks.check_merge_compact
      )[0]
  
      # waiting for handoff completed and search
      cost = 180
      start = time()
      while True:
          sleep(1)
          segment_info = self.utility_wrap.get_query_segment_info(
              collection_w.name
          )[0]
          if (
              len(segment_info) != 0
              and segment_info[0].segmentID == c_plans.plans[0].target
          ):
              log.debug(segment_info)
              break
          if time() - start > cost:
              raise MilvusException(
                  1,
                  f"Handoff after compact and index cost more than {cost}s",
              )
  
      # verify search result
      search_res_two, _ = collection_w.search(
          df[ct.default_binary_vec_field_name][
              : ct.default_nq
          ].to_list(),
          ct.default_binary_vec_field_name,
          search_params,
          ct.default_limit,
      )
      assert len(search_res_one) == ct.default_nq
      for hits in search_res_one:
          assert len(hits) == ct.default_limit
  
imports: import threading
  from time import time, sleep
  import pytest
  from pymilvus.grpc_gen.common_pb2 import SegmentState
  from pymilvus.exceptions import MilvusException
  from base.client_base import TestcaseBase
  from common import common_func
  from common import common_type
  from common.common_type import CaseLabel, CheckTasks
  from utils.util_log import test_log
label_desc: Use image node_id 5 for calling the TestCompactionOperation obj's underlying member method code with example usage: obj.test_compact_after_binary_index() without return types