From da05daa07975b4157a6713d8794bd62384fbeff3 Mon Sep 17 00:00:00 2001 From: Rachel Chen Date: Wed, 11 Dec 2024 14:46:14 -0800 Subject: [PATCH] added protobuf comparison --- .../test_endpoint_trace_item_table.py | 72 ++++--------------- 1 file changed, 15 insertions(+), 57 deletions(-) diff --git a/tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py b/tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py index a6744f65a0..7136bee0a1 100644 --- a/tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py +++ b/tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py @@ -1063,66 +1063,24 @@ def test_floats_calculations(self) -> None: # assert result.column_values[1].attribute_name == "min(sampling_rate)" # assert result.column_values[1].results[0].val_float == 0.1 - def test_single_float_retrieval(self) -> None: - spans_storage = get_storage(StorageKey("eap_spans")) - start = BASE_TIME - messages = [ - { - "is_segment": False, - "retention_days": 90, - "tags": {}, - "sentry_tags": {"status": "success"}, - "measurements": {"client_sample_rate": {"value": 0.123456}}, - "event_id": "df1626f2c20249368d32cbc7bedc58b6", - "organization_id": 1, - "project_id": 1, - "trace_id": "724cb5bc3e9843e39dba73c7ec2909ab", - "span_id": "3a3ff57148b14923", - "parent_span_id": "87f08db2b78848c7", - "segment_id": "b6684d253c934ea3", - "group_raw": "30cff40b57554d8a", - "profile_id": "1f2e11173706458f9010599631234fc4", - "start_timestamp_ms": int(start.timestamp()) * 1000 - - int(random.gauss(1000, 200)), - "start_timestamp_precise": start.timestamp(), - "end_timestamp_precise": start.timestamp() + 1, - "received": 1721319572.877828, - "duration_ms": 152, - "exclusive_time_ms": 0.228, - "description": "foo", - "ingest_in_eap": True, - }, - ] - write_raw_unprocessed_events(spans_storage, messages) # type: ignore - - ts = Timestamp(seconds=int(BASE_TIME.timestamp())) - hour_ago = Timestamp(seconds=int((BASE_TIME - timedelta(hours=1)).timestamp())) - err_req = { - "meta": { - "organizationId": 1, - "referrer": "api.organization-events", - "projectIds": [1], - "startTimestamp": hour_ago.ToJsonString(), - "endTimestamp": ts.ToJsonString(), - }, - "columns": [ - { - "key": {"type": "TYPE_FLOAT", "name": "sentry.sampling_factor"}, - }, + def test_single_float_comparison(self) -> None: + protobuf_with_float = TraceItemColumnValues( + attribute_name="blah", + results=[ + AttributeValue(val_float=0.123456), ], - } + ) - err_msg = ParseDict(err_req, TraceItemTableRequest()) - result = EndpointTraceItemTable().execute(err_msg) + # this passes + assert protobuf_with_float == TraceItemColumnValues( + attribute_name="blah", + results=[ + AttributeValue(val_float=0.123456), + ], + ) - assert result.column_values == [ - TraceItemColumnValues( - attribute_name="sentry.sampling_factor", - results=[ - AttributeValue(val_float=0.123456), - ], - ), - ] + # this should NOT pass + assert protobuf_with_float.results[0].val_float != 0.123455 class TestUtils: