docstr: target: test compact cross shards
  method: 1.create with shard_num=2
          2.insert once and flush (two segments, belonging to two shards)
          3.compact and completed
  expected: Verify compact plan sources only one segment
docstr_tok: ["target",":","test","compact","cross","shards","method",":","1.create","with","shard_num=2","2.insert","once","and","flush","(","two","segments",",","belonging","to","two","shards",")","3.compact","and","completed","expected",":","Verify","compact","plan","sources","only","one","segment"]
code: def test_compact_cross_shards(self):
      """
      target: test compact cross shards
      method: 1.create with shard_num=2
              2.insert once and flush (two segments, belonging to two shards)
              3.compact and completed
      expected: Verify compact plan sources only one segment
      """
      # insert into two segments with two shard
      collection_w = self.init_collection_wrap(
          name=cf.gen_unique_str(prefix), shards_num=2
      )
      df = cf.gen_default_dataframe_data(tmp_nb)
      collection_w.insert(df)
      assert collection_w.num_entities == tmp_nb
      collection_w.create_index(
          ct.default_float_vec_field_name, ct.default_index
      )
      log.debug(collection_w.index())
  
      # compact
      collection_w.compact()
      collection_w.wait_for_compaction_completed()
      c_plans = collection_w.get_compaction_plans()[0]
  
      # Actually no merged
      assert len(c_plans.plans) == 2
      for plan in c_plans.plans:
          assert len(plan.sources) == 1
  
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 20 for calling the TestCompactionOperation obj's underlying member method code with example usage: obj.test_compact_cross_shards() without return types