blob: f690d7247d1948766660005704892575740a111f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
"""Utilities for generating with multiversion tests."""
from typing import List
import inject
from buildscripts.task_generation.resmoke_proxy import ResmokeProxyService
REPL_MIXED_VERSION_CONFIGS = ["new-old-new", "new-new-old", "old-new-new"]
SHARDED_MIXED_VERSION_CONFIGS = ["new-old-old-new"]
class MultiversionUtilService:
"""Utilities to working with multiversion tests."""
@inject.autoparams()
def __init__(self, resmoke_proxy: ResmokeProxyService) -> None:
"""
Initialize the service.
:param resmoke_proxy: Resmoke proxy service.
"""
self.resmoke_proxy = resmoke_proxy
def is_suite_sharded(self, suite_name: str) -> bool:
"""Return true if a suite uses ShardedClusterFixture."""
source_config = self.resmoke_proxy.read_suite_config(suite_name)
return source_config["executor"]["fixture"]["class"] == "ShardedClusterFixture"
def get_version_configs_for_suite(self, suite_name: str) -> List[str]:
"""
Get the version configs that apply for the given suite.
:param suite_name: Suite to get version configs for.
:return: List of version configs.
"""
is_sharded = self.is_suite_sharded(suite_name)
return self.get_version_configs(is_sharded)
@staticmethod
def get_version_configs(is_sharded: bool) -> List[str]:
"""Get the version configurations to use."""
if is_sharded:
return SHARDED_MIXED_VERSION_CONFIGS
return REPL_MIXED_VERSION_CONFIGS
|