test_workload.py 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # import datetime
  2. # import pytest
  3. #
  4. # from base.client_base import TestcaseBase
  5. # from common import common_func as cf
  6. # from common import common_type as ct
  7. # from common.common_type import CaseLabel
  8. # from utils.util_log import test_log as log
  9. # from pymilvus import utility
  10. #
  11. #
  12. # rounds = 100
  13. # per_nb = 100000
  14. # default_field_name = ct.default_float_vec_field_name
  15. # default_index_params = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}}
  16. #
  17. #
  18. # class TestLoad(TestcaseBase):
  19. # """ Test case of end to end"""
  20. # @pytest.mark.tags(CaseLabel.L3)
  21. # def test_load_default(self):
  22. # name = 'load_test_collection_1'
  23. # name2 = 'load_test_collection_2'
  24. # # create
  25. # # collection_w = self.init_collection_wrap(name=name)
  26. # # collection_w2 = self.init_collection_wrap(name=name2)
  27. # # assert collection_w.name == name
  28. #
  29. # for i in range(50):
  30. # name = f"load_collection2_{i}"
  31. # self.init_collection_wrap(name=name)
  32. # log.debug(f"total collections: {len(utility.list_collections())}")
  33. #
  34. # # # insert
  35. # # data = cf.gen_default_list_data(per_nb)
  36. # # log.debug(f"data len: {len(data[0])}")
  37. # # for i in range(rounds):
  38. # # t0 = datetime.datetime.now()
  39. # # ins_res, res = collection_w.insert(data, timeout=180)
  40. # # tt = datetime.datetime.now() - t0
  41. # # log.debug(f"round{i} insert: {len(ins_res.primary_keys)} entities in {tt}s")
  42. # # assert res # and per_nb == len(ins_res.primary_keys)
  43. # #
  44. # # t0 = datetime.datetime.now()
  45. # # ins_res2, res = collection_w2.insert(data, timeout=180)
  46. # # tt = datetime.datetime.now() - t0
  47. # # log.debug(f"round{i} insert2: {len(ins_res2.primary_keys)} entities in {tt}s")
  48. # # assert res
  49. # #
  50. # # # flush
  51. # # t0 = datetime.datetime.now()
  52. # # log.debug(f"current collection num_entities: {collection_w.num_entities}")
  53. # # tt = datetime.datetime.now() - t0
  54. # # log.debug(f"round{i} flush in {tt}")
  55. # #
  56. # # t0 = datetime.datetime.now()
  57. # # log.debug(f"current collection2 num_entities: {collection_w2.num_entities}")
  58. # # tt = datetime.datetime.now() - t0
  59. # # log.debug(f"round{i} flush2 in {tt}")
  60. #
  61. # # index, res = collection_w.create_index(default_field_name, default_all_indexes_params, timeout=60)
  62. # # assert res
  63. #
  64. # # # search
  65. # # collection_w.load()
  66. # # search_vectors = cf.gen_vectors(1, ct.default_dim)
  67. # # t0 = datetime.datetime.now()
  68. # # res_1, _ = collection_w.search(data=search_vectors,
  69. # # anns_field=ct.default_float_vec_field_name,
  70. # # param={"nprobe": 16}, limit=1)
  71. # # tt = datetime.datetime.now() - t0
  72. # # log.debug(f"assert search: {tt}")
  73. # # assert len(res_1) == 1
  74. # # # collection_w.release()
  75. # #
  76. # # # index
  77. # # collection_w.insert(cf.gen_default_dataframe_data(nb=5000))
  78. # # assert collection_w.num_entities == len(data[0]) + 5000
  79. # # _index_params = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}}
  80. # # t0 = datetime.datetime.now()
  81. # # index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name,
  82. # # index_params=_index_params,
  83. # # name=cf.gen_unique_str())
  84. # # tt = datetime.datetime.now() - t0
  85. # # log.debug(f"assert index: {tt}")
  86. # # assert len(collection_w.indexes) == 1
  87. # #
  88. # # # query
  89. # # term_expr = f'{ct.default_int64_field_name} in [3001,4001,4999,2999]'
  90. # # t0 = datetime.datetime.now()
  91. # # res, _ = collection_w.query(term_expr)
  92. # # tt = datetime.datetime.now() - t0
  93. # # log.debug(f"assert query: {tt}")
  94. # # assert len(res) == 4