@@ -32,24 +32,26 @@ def _get_request_meta(
3232 end : datetime | None = None ,
3333 hour_interval : int | None = None ,
3434 downsampled_storage_config : DownsampledStorageConfig | None = None ,
35+ trace_item_type : TraceItemType .ValueType | None = None ,
3536) -> RequestMeta :
3637 hour_interval = hour_interval or 24
3738 start = start or BASE_TIME - timedelta (hours = hour_interval )
3839 end = end or BASE_TIME
40+ trace_item_type = trace_item_type or TraceItemType .TRACE_ITEM_TYPE_SPAN
3941 return RequestMeta (
4042 project_ids = [_PROJECT_ID ],
4143 organization_id = _ORG_ID ,
4244 cogs_category = "something" ,
4345 referrer = "something" ,
4446 start_timestamp = Timestamp (seconds = int (start .timestamp ())),
4547 end_timestamp = Timestamp (seconds = int (end .timestamp ())),
46- trace_item_type = TraceItemType . TRACE_ITEM_TYPE_SPAN ,
48+ trace_item_type = trace_item_type ,
4749 downsampled_storage_config = downsampled_storage_config ,
4850 )
4951
5052
5153@pytest .fixture
52- def store_outcomes_fixture (clickhouse_db : Any ) -> None :
54+ def store_outcomes_fixture (eap : Any ) -> None :
5355 # Generate 24 hours of outcomes data with 1M outcomes per hour
5456 outcome_data = []
5557 for hour in range (24 ):
@@ -59,8 +61,8 @@ def store_outcomes_fixture(clickhouse_db: Any) -> None:
5961 store_outcomes_data (outcome_data )
6062
6163
62- @pytest .mark .clickhouse_db
6364@pytest .mark .redis_db
65+ @pytest .mark .eap
6466def test_outcomes_based_routing_queries_daily_table () -> None :
6567 strategy = OutcomesBasedRoutingStrategy ()
6668
@@ -82,7 +84,42 @@ def test_outcomes_based_routing_queries_daily_table() -> None:
8284 assert routing_decision .can_run
8385
8486
85- @pytest .mark .clickhouse_db
87+ @pytest .mark .eap
88+ @pytest .mark .redis_db
89+ def test_item_type_full_retention () -> None :
90+ """
91+ Certain item types will not use the long term retention downsampling,
92+ find them in ITEM_TYPE_FULL_RETENTION routing_strategies/common.py
93+ """
94+ state .set_config (
95+ "enable_long_term_retention_downsampling" ,
96+ 1 ,
97+ )
98+ strategy = OutcomesBasedRoutingStrategy ()
99+
100+ # request that queries last 50 days of data
101+ end_time = datetime .now (UTC ).replace (hour = 0 , minute = 0 , second = 0 , microsecond = 0 )
102+ start_time = end_time - timedelta (hours = 1200 ) # 50 days
103+ request = TraceItemTableRequest (
104+ meta = _get_request_meta (
105+ start = start_time ,
106+ end = end_time ,
107+ trace_item_type = TraceItemType .TRACE_ITEM_TYPE_UPTIME_RESULT ,
108+ )
109+ )
110+ request .meta .downsampled_storage_config .mode = DownsampledStorageConfig .MODE_NORMAL
111+ context = RoutingContext (
112+ in_msg = request ,
113+ timer = Timer ("test" ),
114+ query_id = uuid .uuid4 ().hex ,
115+ )
116+ routing_decision = strategy .get_routing_decision (context )
117+ assert routing_decision .tier == Tier .TIER_1
118+ assert routing_decision .clickhouse_settings == {"max_threads" : 10 }
119+ assert routing_decision .can_run
120+
121+
122+ @pytest .mark .eap
86123@pytest .mark .redis_db
87124def test_outcomes_based_routing_sampled_data_past_thirty_days () -> None :
88125 state .set_config (
@@ -156,7 +193,7 @@ def test_outcomes_based_routing_sampled_data_past_thirty_days() -> None:
156193 assert routing_decision .can_run
157194
158195
159- @pytest .mark .clickhouse_db
196+ @pytest .mark .eap
160197@pytest .mark .redis_db
161198def test_outcomes_based_routing_normal_mode (store_outcomes_fixture : Any ) -> None :
162199 strategy = OutcomesBasedRoutingStrategy ()
@@ -176,7 +213,7 @@ def test_outcomes_based_routing_normal_mode(store_outcomes_fixture: Any) -> None
176213 assert routing_decision .can_run
177214
178215
179- @pytest .mark .clickhouse_db
216+ @pytest .mark .eap
180217@pytest .mark .redis_db
181218def test_outcomes_based_routing_downsample (store_outcomes_fixture : Any ) -> None :
182219 state .set_config ("OutcomesBasedRoutingStrategy.max_items_before_downsampling" , 5_000_000 )
@@ -220,7 +257,7 @@ def test_outcomes_based_routing_downsample(store_outcomes_fixture: Any) -> None:
220257 assert routing_decision .can_run
221258
222259
223- @pytest .mark .clickhouse_db
260+ @pytest .mark .eap
224261@pytest .mark .redis_db
225262def test_outcomes_based_routing_highest_accuracy_mode (store_outcomes_fixture : Any ) -> None :
226263 strategy = OutcomesBasedRoutingStrategy ()
@@ -240,7 +277,7 @@ def test_outcomes_based_routing_highest_accuracy_mode(store_outcomes_fixture: An
240277 assert routing_decision .can_run
241278
242279
243- @pytest .mark .clickhouse_db
280+ @pytest .mark .eap
244281@pytest .mark .redis_db
245282def test_outcomes_based_routing_defaults_to_tier1_for_unspecified_item_type (
246283 store_outcomes_fixture : Any ,
0 commit comments