runner: fix some envs deleted too early

In some complex combination of test cases, which needs new_env and early
deployment phase, they may be put into the same environments, but
returned later. The extra environments will be deleted in the period,
so the test results cannot be run. With this change, the not deployed
environments won't be deleted until the whole runner completed.
This commit is contained in:
Chi Song 2021-08-09 18:23:37 -07:00 коммит произвёл Chi Song
Родитель 2288218a7f
Коммит b68f810127
2 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -194,7 +194,12 @@ class LisaRunner(BaseRunner):
available_environments = self._sort_environments(self.environments)
# check deleteable environments
for environment in available_environments:
if environment.is_in_use:
# if an environment is in using, or not deployed, they won't be
# deleted until end of runner.
if environment.is_in_use or environment.status in [
EnvironmentStatus.New,
EnvironmentStatus.Prepared,
]:
continue
can_run_results = self._get_runnable_test_results(

Просмотреть файл

@ -546,7 +546,7 @@ class RunnerTestCase(TestCase):
self.verify_env_results(
expected_prepared=["customized_0"],
expected_deployed_envs=[],
expected_deleted_envs=["customized_0"],
expected_deleted_envs=[],
runner=runner,
)
self.verify_test_results(
@ -631,4 +631,5 @@ class RunnerTestCase(TestCase):
temp_test_results = task()
if temp_test_results:
test_results.extend(temp_test_results)
return test_results