class_docstr: Test cases of alias interface operations
class_docstr_tok: ["Test","cases","of","alias","interface","operations"]
docstr: target: test collection altering alias
  method: 
          1. create collection_1 with 10 partitions and its alias alias_a
          2. create collection_2 with 5 partitions and its alias alias_b
          3. collection_1 alter alias to alias_b
  expected: 
          in step 1, collection_1 is equal to alias_a
          in step 2, collection_2 is equal to alias_b
          in step 3, collection_1 is equal to alias_a and alias_b, and collection_2 is not equal to alias_b
docstr_tok: ["target",":","test","collection","altering","alias","method",":","1.","create","collection_1","with","10","partitions","and","its","alias","alias_a","2.","create","collection_2","with","5","partitions","and","its","alias","alias_b","3.","collection_1","alter","alias","to","alias_b","expected",":","in","step","1",",","collection_1","is","equal","to","alias_a","in","step","2",",","collection_2","is","equal","to","alias_b","in","step","3",",","collection_1","is","equal","to","alias_a","and","alias_b",",","and","collection_2","is","not","equal","to","alias_b"]
code: def test_alias_alter_operation_default(self):
      """
      target: test collection altering alias
      method:
              1. create collection_1 with 10 partitions and its alias alias_a
              2. create collection_2 with 5 partitions and its alias alias_b
              3. collection_1 alter alias to alias_b
      expected:
              in step 1, collection_1 is equal to alias_a
              in step 2, collection_2 is equal to alias_b
              in step 3, collection_1 is equal to alias_a and alias_b, and collection_2 is not equal to alias_b
      """
      self._connect()
  
      # create collection_1 with 10 partitions and its alias alias_a
      c_1_name = cf.gen_unique_str("collection")
      collection_1 = self.init_collection_wrap(
          name=c_1_name,
          schema=default_schema,
          check_task=CheckTasks.check_collection_property,
          check_items={exp_name: c_1_name, exp_schema: default_schema},
      )
      for _ in range(10):
          partition_name = cf.gen_unique_str("partition")
          # create partition with different names and check the partition exists
          self.init_partition_wrap(collection_1, partition_name)
          assert collection_1.has_partition(partition_name)[0]
  
      alias_a_name = cf.gen_unique_str(prefix)
      self.utility_wrap.create_alias(collection_1.name, alias_a_name)
      collection_alias_a, _ = self.collection_wrap.init_collection(
          name=alias_a_name,
          check_task=CheckTasks.check_collection_property,
          check_items={
              exp_name: alias_a_name,
              exp_schema: default_schema,
          },
      )
      # assert collection is equal to alias according to partitions
      assert [p.name for p in collection_1.partitions] == [
          p.name for p in collection_alias_a.partitions
      ]
  
      # create collection_2 with 5 partitions and its alias alias_b
      c_2_name = cf.gen_unique_str("collection")
      collection_2 = self.init_collection_wrap(
          name=c_2_name,
          schema=default_schema,
          check_task=CheckTasks.check_collection_property,
          check_items={exp_name: c_2_name, exp_schema: default_schema},
      )
  
      for _ in range(5):
          partition_name = cf.gen_unique_str("partition")
          # create partition with different names and check the partition exists
          self.init_partition_wrap(collection_2, partition_name)
          assert collection_2.has_partition(partition_name)[0]
  
      alias_b_name = cf.gen_unique_str(prefix)
      self.utility_wrap.create_alias(collection_2.name, alias_b_name)
      collection_alias_b, _ = self.collection_wrap.init_collection(
          name=alias_b_name,
          check_task=CheckTasks.check_collection_property,
          check_items={
              exp_name: alias_b_name,
              exp_schema: default_schema,
          },
      )
      # assert collection is equal to alias according to partitions
      assert [p.name for p in collection_2.partitions] == [
          p.name for p in collection_alias_b.partitions
      ]
  
      # collection_1 alter alias to alias_b
      self.utility_wrap.alter_alias(collection_1.name, alias_b_name)
  
      # collection_1 has two alias name, alias_a and alias_b, but collection_2 has no alias any more
      assert [p.name for p in collection_1.partitions] == [
          p.name for p in collection_alias_b.partitions
      ]
      assert [p.name for p in collection_1.partitions] == [
          p.name for p in collection_alias_a.partitions
      ]
      assert [p.name for p in collection_2.partitions] != [
          p.name for p in collection_alias_b.partitions
      ]
  
imports: import pytest
  import random
  from base.client_base import TestcaseBase
  from utils.util_log import test_log
  from common import common_func
  from common import common_type
  from common.common_type import CaseLabel, CheckTasks
label_desc: Use image node_id 2 for calling the TestAliasOperation obj's underlying member method code with example usage: obj.test_alias_alter_operation_default() without return types