Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lobsterkatie committed Aug 6, 2024
1 parent 99560ab commit 469a940
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import orjson
from urllib3.response import HTTPResponse

from sentry import options
from sentry.api.endpoints.group_similar_issues_embeddings import (
GroupSimilarIssuesEmbeddingsEndpoint,
)
from sentry.api.serializers.base import serialize
from sentry.conf.server import SEER_SIMILAR_ISSUES_URL
from sentry.models.group import Group
from sentry.seer.similarity.similar_issues import SIMILARITY_REQUEST_METRIC_SAMPLE_RATE
from sentry.seer.similarity.types import SeerSimilarIssueData, SimilarIssuesEmbeddingsResponse
from sentry.testutils.cases import APITestCase
from sentry.testutils.helpers.eventprocessing import save_new_event
Expand Down Expand Up @@ -244,7 +244,7 @@ def test_simple(self, mock_logger, mock_seer_request, mock_metrics_incr):
)
mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={
"response_status": 200,
"outcome": "matching_group_found",
Expand Down Expand Up @@ -356,7 +356,7 @@ def test_incomplete_return_data(self, mock_seer_request, mock_logger, mock_metri
)
mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={
"response_status": 200,
"outcome": "error",
Expand Down Expand Up @@ -409,7 +409,7 @@ def test_nonexistent_group(

mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={
"response_status": 200,
"outcome": "error",
Expand Down
14 changes: 7 additions & 7 deletions tests/sentry/seer/similarity/test_similar_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from urllib3.exceptions import MaxRetryError, TimeoutError
from urllib3.response import HTTPResponse

from sentry import options
from sentry.conf.server import SEER_SIMILAR_ISSUES_URL
from sentry.seer.similarity.similar_issues import (
SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
get_similarity_data_from_seer,
seer_grouping_connection_pool,
)
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_groups_found(self, mock_seer_request: MagicMock, mock_metrics_incr: Mag
]
mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={
"response_status": 200,
"outcome": expected_outcome,
Expand All @@ -92,7 +92,7 @@ def test_no_groups_found(self, mock_seer_request: MagicMock, mock_metrics_incr:
assert get_similarity_data_from_seer(self.request_params) == []
mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"response_status": 200, "outcome": "no_similar_groups"},
)

Expand Down Expand Up @@ -142,7 +142,7 @@ def test_bad_response_data(
assert get_similarity_data_from_seer(self.request_params) == []
mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"response_status": 200, "outcome": "error", "error": expected_error},
)
assert mock_record_circuit_breaker_error.call_count == 0
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_redirect(
)
mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"response_status": 308, "outcome": "error", "error": "Redirect"},
)
assert mock_record_circuit_breaker_error.call_count == 0
Expand Down Expand Up @@ -207,7 +207,7 @@ def test_request_error(
)
mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"outcome": "error", "error": expected_error_tag},
)
assert mock_record_circuit_breaker_error.call_count == 1
Expand Down Expand Up @@ -240,7 +240,7 @@ def test_error_status(
)
mock_metrics_incr.assert_any_call(
"seer.similar_issues_request",
sample_rate=SIMILARITY_REQUEST_METRIC_SAMPLE_RATE,
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"response_status": status, "outcome": "error", "error": "RequestError"},
)
assert mock_record_circuit_breaker_error.call_count == (
Expand Down
4 changes: 4 additions & 0 deletions tests/sentry/tasks/test_backfill_seer_grouping_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@
from sentry.testutils.helpers.options import override_options
from sentry.testutils.helpers.task_runner import TaskRunner
from sentry.testutils.pytest.fixtures import django_db_all
from sentry.testutils.skips import requires_snuba
from sentry.utils import json
from sentry.utils.safe import get_path
from sentry.utils.snuba import RateLimitExceeded, bulk_snuba_queries

pytestmark = [requires_snuba]


EXCEPTION = {
"values": [
{
Expand Down

0 comments on commit 469a940

Please sign in to comment.