示例#1
0
 def get(self, request):
     return Response(
         serialize([
             config().as_dict()
             for config in sorted(CONFIGURATIONS.values(),
                                  key=lambda x: x.id)
         ]))
示例#2
0
def load_configs():
    configs = CONFIGURATIONS.keys()

    rv = []
    for filename in os.listdir(_fixture_path):
        if filename.endswith(".json"):
            for config in configs:
                rv.append((config, filename[:-5]))

    rv.sort()

    return rv
示例#3
0
    def get(self, request: Request, project) -> Response:

        configs = [
            config.as_dict()
            for config in sorted(CONFIGURATIONS.values(), key=lambda x: x.id)
        ]
        latest = next(config["id"] for config in configs if config["latest"])

        # As long as newstyle:2019-10-29 is the global "latest", allow orgs to upgrade
        # to mobile:2021-02-12 if the appropriate feature flag is on:
        if latest == DEFAULT_GROUPING_CONFIG and features.has(
                "organizations:grouping-tree-ui",
                project.organization,
                actor=request.user):
            for config in configs:
                config["latest"] = config["id"] == BETA_GROUPING_CONFIG

        return Response(serialize(configs))
        if isinstance(value, GroupingComponent):
            if value.tree_label:
                lines.append('{}tree_label: "{}"'.format("  " * indent, value.tree_label))
            lines.append("{}{}:".format("  " * indent, key))
            _dump_component(value, indent + 1)
        elif key == "config":
            # We do not want to dump the config
            continue
        else:
            lines.append("{}{}: {}".format("  " * indent, key, json.dumps(value)))

    return lines


@with_grouping_input("grouping_input")
@pytest.mark.parametrize("config_name", CONFIGURATIONS.keys(), ids=lambda x: x.replace("-", "_"))
def test_event_hash_variant(config_name, grouping_input, insta_snapshot, log):
    grouping_config = get_default_grouping_config_dict(config_name)
    evt = grouping_input.create_event(grouping_config)

    # Make sure we don't need to touch the DB here because this would
    # break stuff later on.
    evt.project = None

    rv = []
    for (key, value) in sorted(evt.get_grouping_variants().items()):
        if rv:
            rv.append("-" * 74)
        rv.append("%s:" % key)
        dump_variant(value, rv, 1)
    output = "\n".join(rv)
示例#5
0
import pytest

from sentry.grouping.api import get_default_grouping_config_dict
from sentry.grouping.strategies.configurations import CONFIGURATIONS
from tests.sentry.grouping import grouping_input as grouping_inputs

CONFIGS = {
    key: get_default_grouping_config_dict(key)
    for key in sorted(CONFIGURATIONS.keys())
}


def benchmark_available():
    try:
        import pytest_benchmark  # NOQA
    except ModuleNotFoundError:
        return False
    else:
        return True


@pytest.mark.skipif(not benchmark_available(),
                    reason="requires pytest-benchmark")
@pytest.mark.parametrize("config_name",
                         sorted(CONFIGURATIONS.keys()),
                         ids=lambda x: x.replace("-", "_"))
def test_benchmark_grouping(config_name, benchmark):
    config = CONFIGS[config_name]
    input_iter = iter(grouping_inputs)

    def setup():
示例#6
0
 def get(self, request):
     return Response(serialize([
         config.as_dict() for config in sorted(CONFIGURATIONS.values(),
                                               key=lambda x: x.id)
     ]))
示例#7
0
    for (key, value) in sorted(variant.__dict__.items()):
        if isinstance(value, GroupingComponent):
            lines.append("%s%s:" % ("  " * indent, key))
            _dump_component(value, indent + 1)
        elif key == "config":
            # We do not want to dump the config
            continue
        else:
            lines.append("%s%s: %s" % ("  " * indent, key, json.dumps(value)))

    return lines


@with_grouping_input("grouping_input")
@pytest.mark.parametrize("config_name",
                         CONFIGURATIONS.keys(),
                         ids=lambda x: x.replace("-", "_"))
def test_event_hash_variant(config_name, grouping_input, insta_snapshot, log):
    grouping_config = get_default_grouping_config_dict(config_name)
    evt = grouping_input.create_event(grouping_config)

    # Make sure we don't need to touch the DB here because this would
    # break stuff later on.
    evt.project = None

    rv = []
    for (key, value) in sorted(evt.get_grouping_variants().items()):
        if rv:
            rv.append("-" * 74)
        rv.append("%s:" % key)
        dump_variant(value, rv, 1)
示例#8
0
def _get_configurations():
    # Sort configurations by ascending date
    strategies = sorted(CONFIGURATIONS.keys(), key=lambda x: x.split(":")[-1])
    return list(zip(strategies, strategies[1:]))