diff --git a/src/sentry/release_health/metrics.py b/src/sentry/release_health/metrics.py index 526e7f9dae774d..3d94e47262a7f4 100644 --- a/src/sentry/release_health/metrics.py +++ b/src/sentry/release_health/metrics.py @@ -449,7 +449,9 @@ def get_release_sessions_time_bounds( Condition(Column("org_id"), Op.EQ, org_id), Condition(Column("project_id"), Op.EQ, project_id), Condition(Column(tag_key(org_id, "release")), Op.EQ, tag_value(org_id, release)), - Condition(Column("timestamp"), Op.GTE, datetime.min), + Condition( + Column("timestamp"), Op.GTE, datetime(2008, 5, 8) + ), # Date of sentry's first commit Condition(Column("timestamp"), Op.LT, datetime.now(pytz.utc)), ] diff --git a/src/sentry/testutils/skips.py b/src/sentry/testutils/skips.py index bef6f16504df31..9a50d377a0718e 100644 --- a/src/sentry/testutils/skips.py +++ b/src/sentry/testutils/skips.py @@ -40,6 +40,15 @@ def snuba_metrics_available(): ) +def is_arm64(): + return os.uname().machine == "arm64" + + +requires_not_arm64 = pytest.mark.skipif( + is_arm64(), reason="this test fails in our arm64 testing env" +) + + def xfail_if_not_postgres(reason): def decorator(function): return pytest.mark.xfail(os.environ.get("TEST_SUITE") != "postgres", reason=reason)( diff --git a/src/sentry/utils/snuba.py b/src/sentry/utils/snuba.py index 2efa1f71e8db71..8d8dccfdde4cbd 100644 --- a/src/sentry/utils/snuba.py +++ b/src/sentry/utils/snuba.py @@ -607,7 +607,9 @@ def __init__( ): # TODO: instead of having events be the default, make dataset required. self.dataset = dataset or Dataset.Events - self.start = start or datetime.utcfromtimestamp(0) # will be clamped to project retention + self.start = start or datetime( + 2008, 5, 8 + ) # Date of sentry's first commit. Will be clamped to project retention # Snuba has end exclusive but our UI wants it generally to be inclusive. # This shows up in unittests: https://github.com/getsentry/sentry/pull/15939 # We generally however require that the API user is aware of the exclusive diff --git a/tests/snuba/api/endpoints/test_organization_events_stats.py b/tests/snuba/api/endpoints/test_organization_events_stats.py index 1b9d07fdb41ce9..e0c8d3fb18907d 100644 --- a/tests/snuba/api/endpoints/test_organization_events_stats.py +++ b/tests/snuba/api/endpoints/test_organization_events_stats.py @@ -1579,7 +1579,7 @@ def test_top_events_with_user(self): "end": iso_format(self.day_ago + timedelta(hours=2)), "interval": "1h", "yAxis": "count()", - "orderby": ["-count()"], + "orderby": ["-count()", "user"], "field": ["user", "count()"], "topEvents": 5, }, @@ -1590,7 +1590,7 @@ def test_top_events_with_user(self): assert response.status_code == 200, response.content assert len(data) == 5 - assert data["email:bar@example.com"]["order"] == 0 + assert data["email:bar@example.com"]["order"] == 1 assert [attrs for time, attrs in data["email:bar@example.com"]["data"]] == [ [{"count": 7}], [{"count": 0}], @@ -1609,7 +1609,7 @@ def test_top_events_with_user_and_email(self): "end": iso_format(self.day_ago + timedelta(hours=2)), "interval": "1h", "yAxis": "count()", - "orderby": ["-count()"], + "orderby": ["-count()", "user"], "field": ["user", "user.email", "count()"], "topEvents": 5, }, @@ -1620,7 +1620,7 @@ def test_top_events_with_user_and_email(self): assert response.status_code == 200, response.content assert len(data) == 5 - assert data["email:bar@example.com,bar@example.com"]["order"] == 0 + assert data["email:bar@example.com,bar@example.com"]["order"] == 1 assert [attrs for time, attrs in data["email:bar@example.com,bar@example.com"]["data"]] == [ [{"count": 7}], [{"count": 0}], diff --git a/tests/snuba/api/endpoints/test_organization_events_v2.py b/tests/snuba/api/endpoints/test_organization_events_v2.py index fb5b51433f4eb1..bf8caea1c1a951 100644 --- a/tests/snuba/api/endpoints/test_organization_events_v2.py +++ b/tests/snuba/api/endpoints/test_organization_events_v2.py @@ -22,6 +22,7 @@ from sentry.testutils import APITestCase, SnubaTestCase from sentry.testutils.helpers import parse_link_header from sentry.testutils.helpers.datetime import before_now, iso_format +from sentry.testutils.skips import requires_not_arm64 from sentry.utils import json from sentry.utils.samples import load_data from sentry.utils.snuba import QueryExecutionError, QueryIllegalTypeOfArgument, RateLimitExceeded @@ -1355,6 +1356,7 @@ def test_count_miserable_new_alias_field(self): ], "query": "event.type:transaction", "project": [project.id], + "sort": "count_miserable_user", } response = self.do_request( @@ -1365,8 +1367,8 @@ def test_count_miserable_new_alias_field(self): assert len(response.data["data"]) == 3 data = response.data["data"] assert data[0]["count_miserable_user"] == 0 - assert data[1]["count_miserable_user"] == 2 - assert data[2]["count_miserable_user"] == 1 + assert data[1]["count_miserable_user"] == 1 + assert data[2]["count_miserable_user"] == 2 query["query"] = "event.type:transaction count_miserable(user):>0" @@ -1377,8 +1379,8 @@ def test_count_miserable_new_alias_field(self): assert response.status_code == 200, response.content assert len(response.data["data"]) == 2 data = response.data["data"] - assert abs(data[0]["count_miserable_user"]) == 2 - assert abs(data[1]["count_miserable_user"]) == 1 + assert abs(data[0]["count_miserable_user"]) == 1 + assert abs(data[1]["count_miserable_user"]) == 2 def test_user_misery_alias_field(self): project = self.create_project() @@ -1445,6 +1447,7 @@ def test_apdex_new_alias_field(self): ], "query": "event.type:transaction", "project": [project.id], + "sort": "-apdex", } response = self.do_request( @@ -3011,6 +3014,7 @@ def test_all_aggregates_in_columns(self): assert data[0]["corr_transaction_duration_transaction_duration"] == 0.0 assert data[0]["sum_transaction_duration"] == 10000 + @requires_not_arm64 def test_null_user_misery_returns_zero(self): project = self.create_project() data = load_data( @@ -3035,6 +3039,7 @@ def test_null_user_misery_returns_zero(self): data = response.data["data"] assert data[0]["user_misery_300"] == 0 + @requires_not_arm64 def test_null_user_misery_new_returns_zero(self): project = self.create_project() data = load_data( @@ -3311,14 +3316,14 @@ def test_deleted_issue_in_results(self): event2.group.delete() features = {"organizations:discover-basic": True, "organizations:global-views": True} - query = {"field": ["issue", "count()"], "sort": "count()"} + query = {"field": ["issue", "count()"], "sort": "issue.id"} response = self.do_request(query, features=features) assert response.status_code == 200, response.content data = response.data["data"] assert len(data) == 2 - assert data[0]["issue"] == "unknown" - assert data[1]["issue"] == event1.group.qualified_short_id + assert data[0]["issue"] == event1.group.qualified_short_id + assert data[1]["issue"] == "unknown" def test_last_seen_negative_duration(self): project = self.create_project()