mirror of https://github.com/milvus-io/milvus.git
[test]Fix chaos test (#18694)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com> Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>pull/18692/head
parent
16dcd9718b
commit
61f320287b
|
@ -214,11 +214,10 @@ class InsertFlushChecker(Checker):
|
|||
class FlushChecker(Checker):
|
||||
"""check flush operations in a dependent thread"""
|
||||
|
||||
def __init__(self, collection_name=None, flush=False, shards_num=2):
|
||||
def __init__(self, collection_name=None, shards_num=2):
|
||||
if collection_name is None:
|
||||
collection_name = cf.gen_unique_str("FlushChecker_")
|
||||
super().__init__(collection_name=collection_name, shards_num=shards_num)
|
||||
self._flush = flush
|
||||
self.initial_entities = self.c_wrap.num_entities
|
||||
|
||||
@trace()
|
||||
|
|
|
@ -60,7 +60,7 @@ class TestChaosApply:
|
|||
log.info(connections.get_connection_addr('default'))
|
||||
release_name = self.release_name
|
||||
chaos_config = gen_experiment_config(
|
||||
f"{str(Path(__file__).absolute().parent)}/chaos_objects/{chaos_type}/chaos_{target_component}_{chaos_type}.yaml")
|
||||
f"{str(Path(__file__).absolute().parent)}/chaos_objects/{chaos_type.replace('-', '_')}/chaos_{target_component}_{chaos_type.replace('-', '_')}.yaml")
|
||||
chaos_config['metadata']['name'] = f"test-{target_component}-{chaos_type.replace('_','-')}-{int(time.time())}"
|
||||
chaos_config['metadata']['namespace'] = self.chaos_ns
|
||||
meta_name = chaos_config.get('metadata', None).get('name', None)
|
||||
|
|
|
@ -3,7 +3,8 @@ import pytest
|
|||
import json
|
||||
from time import sleep
|
||||
from pymilvus import connections
|
||||
from chaos.checker import (InsertFlushChecker,
|
||||
from chaos.checker import (InsertChecker,
|
||||
FlushChecker,
|
||||
SearchChecker,
|
||||
QueryChecker,
|
||||
IndexChecker,
|
||||
|
@ -12,6 +13,7 @@ from chaos.checker import (InsertFlushChecker,
|
|||
from common.cus_resource_opts import CustomResourceOperations as CusResource
|
||||
from utils.util_log import test_log as log
|
||||
from chaos import chaos_commons as cc
|
||||
from common import common_func as cf
|
||||
from common.common_type import CaseLabel
|
||||
from chaos import constants
|
||||
from delayed_assert import expect, assert_expectations
|
||||
|
@ -59,23 +61,28 @@ class TestBase:
|
|||
health_checkers = {}
|
||||
|
||||
|
||||
class TestOperatiions(TestBase):
|
||||
class TestOperations(TestBase):
|
||||
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def connection(self, host, port):
|
||||
connections.add_connection(default={"host": host, "port": port})
|
||||
connections.connect(alias='default')
|
||||
|
||||
def connection(self, host, port, user, password):
|
||||
if user and password:
|
||||
# log.info(f"connect to {host}:{port} with user {user} and password {password}")
|
||||
connections.connect('default', host=host, port=port, user=user, password=password, secure=True)
|
||||
else:
|
||||
connections.connect('default', host=host, port=port)
|
||||
if connections.has_connection("default") is False:
|
||||
raise Exception("no connections")
|
||||
log.info("connect to milvus successfully")
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.user = user
|
||||
self.password = password
|
||||
|
||||
def init_health_checkers(self, collection_name=None):
|
||||
c_name = collection_name
|
||||
checkers = {
|
||||
Op.insert: InsertFlushChecker(collection_name=c_name),
|
||||
Op.flush: InsertFlushChecker(collection_name=c_name, flush=True),
|
||||
Op.insert: InsertChecker(collection_name=c_name),
|
||||
Op.flush: FlushChecker(collection_name=c_name),
|
||||
Op.index: IndexChecker(collection_name=c_name),
|
||||
Op.search: SearchChecker(collection_name=c_name),
|
||||
Op.query: QueryChecker(collection_name=c_name),
|
||||
|
@ -90,17 +97,19 @@ class TestOperatiions(TestBase):
|
|||
yield request.param
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L3)
|
||||
def test_operations(self, collection_name):
|
||||
def test_operations(self):
|
||||
# start the monitor threads to check the milvus ops
|
||||
log.info("*********************Test Start**********************")
|
||||
log.info(connections.get_connection_addr('default'))
|
||||
c_name = collection_name
|
||||
c_name = cf.gen_unique_str("Checker_")
|
||||
self.init_health_checkers(collection_name=c_name)
|
||||
cc.start_monitor_threads(self.health_checkers)
|
||||
# wait 20s
|
||||
sleep(constants.WAIT_PER_OP * 2)
|
||||
# assert all expectations
|
||||
assert_statistic(self.health_checkers)
|
||||
assert_expectations()
|
||||
log.info("*********************Load Start**********************")
|
||||
# wait 200s
|
||||
|
||||
for i in range(10):
|
||||
sleep(20)
|
||||
for k,v in self.health_checkers.items():
|
||||
v.check_result()
|
||||
# log.info(v.check_result())
|
||||
log.info("*********************Chaos Test Completed**********************")
|
||||
|
|
|
@ -24,7 +24,7 @@ def pytest_addoption(parser):
|
|||
parser.addoption("--port", action="store", default=19530, help="service's port")
|
||||
parser.addoption("--user", action="store", default="", help="user name for connection")
|
||||
parser.addoption("--password", action="store", default="", help="password for connection")
|
||||
parser.addoption("--secure", action="store", default=False, help="secure for connection")
|
||||
parser.addoption("--secure", action="store", default=True, help="secure for connection")
|
||||
parser.addoption("--http_port", action="store", default=19121, help="http's port")
|
||||
parser.addoption("--handler", action="store", default="GRPC", help="handler of request")
|
||||
parser.addoption("--tag", action="store", default="all", help="only run tests matching the tag.")
|
||||
|
|
Loading…
Reference in New Issue