Optimize import of chaos (#8099)

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
pull/8106/head
ThreadDao 2021-09-16 18:49:49 +08:00 committed by GitHub
parent 7a7c7d9224
commit 53b63144ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View File

@ -2,11 +2,11 @@ import pytest
from time import sleep
from pymilvus import connections
from checker import CreateChecker, InsertFlushChecker, \
from chaos.checker import CreateChecker, InsertFlushChecker, \
SearchChecker, QueryChecker, IndexChecker, Op
from common.cus_resource_opts import CustomResourceOperations as CusResource
from utils.util_log import test_log as log
from chaos_commons import *
from chaos import chaos_commons as cc
from common.common_type import CaseLabel
from chaos import constants
from delayed_assert import expect, assert_expectations
@ -42,7 +42,7 @@ class TestChaosBase:
def parser_testcase_config(self, chaos_yaml):
tests_yaml = constants.TESTS_CONFIG_LOCATION + 'testcases.yaml'
tests_config = gen_experiment_config(tests_yaml)
tests_config = cc.gen_experiment_config(tests_yaml)
test_collections = tests_config.get('Collections', None)
for t in test_collections:
test_chaos = t.get('testcase', {}).get('chaos', {})
@ -102,15 +102,15 @@ class TestChaos(TestChaosBase):
log.info(f"Thread {k} is_alive(): {t.is_alive()}")
@pytest.mark.tags(CaseLabel.L3)
@pytest.mark.parametrize('chaos_yaml', get_chaos_yamls())
@pytest.mark.parametrize('chaos_yaml', cc.get_chaos_yamls())
def test_chaos(self, chaos_yaml):
# start the monitor threads to check the milvus ops
log.info("*********************Chaos Test Start**********************")
log.info(connections.get_connection_addr('default'))
self.checker_threads = start_monitor_threads(self.health_checkers)
self.checker_threads = cc.start_monitor_threads(self.health_checkers)
# parse chaos object
chaos_config = gen_experiment_config(chaos_yaml)
chaos_config = cc.gen_experiment_config(chaos_yaml)
self._chaos_config = chaos_config # cache the chaos config for tear down
log.info(chaos_config)
@ -135,7 +135,7 @@ class TestChaos(TestChaosBase):
log.info("chaos injected")
sleep(constants.WAIT_PER_OP * 2.1)
# reset counting
reset_counting(self.health_checkers)
cc.reset_counting(self.health_checkers)
# wait 40s
sleep(constants.WAIT_PER_OP*4)
@ -164,10 +164,10 @@ class TestChaos(TestChaosBase):
# reconnect if needed
sleep(constants.WAIT_PER_OP*2)
reconnect(connections, self.host, self.port)
cc.reconnect(connections, self.host, self.port)
# reset counting again
reset_counting(self.health_checkers)
cc.reset_counting(self.health_checkers)
# wait 50s (varies by feature)
sleep(constants.WAIT_PER_OP*5)

View File

@ -7,9 +7,10 @@ from base.collection_wrapper import ApiCollectionWrapper
from common.cus_resource_opts import CustomResourceOperations as CusResource
from common import common_func as cf
from common import common_type as ct
from chaos_commons import *
from chaos.chaos_commons import gen_experiment_config, get_chaos_yamls, reconnect
from common.common_type import CaseLabel
from chaos import constants
from utils.util_log import test_log as log
def reboot_pod(chaos_yaml):