1717from feast .feature_service import FeatureService
1818from feast .feature_view import FeatureView
1919from feast .field import Field
20+ from feast .infra .utils .postgres .postgres_config import ConnectionType
2021from feast .online_response import TIMESTAMP_POSTFIX
2122from feast .types import Float32 , Int32 , String
2223from feast .wait import wait_retry_backoff
3233from tests .utils .data_source_test_creator import prep_file_source
3334
3435
36+ @pytest .mark .integration
37+ @pytest .mark .universal_online_stores (only = ["postgres" ])
38+ def test_connection_pool_online_stores (
39+ environment , universal_data_sources , fake_ingest_data
40+ ):
41+ if os .getenv ("FEAST_IS_LOCAL_TEST" , "False" ) == "True" :
42+ return
43+ fs = environment .feature_store
44+ fs .config .online_store .conn_type = ConnectionType .pool
45+ fs .config .online_store .min_conn = 1
46+ fs .config .online_store .max_conn = 10
47+
48+ entities , datasets , data_sources = universal_data_sources
49+ driver_hourly_stats = create_driver_hourly_stats_feature_view (data_sources .driver )
50+ driver_entity = driver ()
51+
52+ # Register Feature View and Entity
53+ fs .apply ([driver_hourly_stats , driver_entity ])
54+
55+ # directly ingest data into the Online Store
56+ fs .write_to_online_store ("driver_stats" , fake_ingest_data )
57+
58+ # assert the right data is in the Online Store
59+ df = fs .get_online_features (
60+ features = [
61+ "driver_stats:avg_daily_trips" ,
62+ "driver_stats:acc_rate" ,
63+ "driver_stats:conv_rate" ,
64+ ],
65+ entity_rows = [{"driver_id" : 1 }],
66+ ).to_df ()
67+ assertpy .assert_that (df ["avg_daily_trips" ].iloc [0 ]).is_equal_to (4 )
68+ assertpy .assert_that (df ["acc_rate" ].iloc [0 ]).is_close_to (0.6 , 1e-6 )
69+ assertpy .assert_that (df ["conv_rate" ].iloc [0 ]).is_close_to (0.5 , 1e-6 )
70+
71+
3572@pytest .mark .integration
3673@pytest .mark .universal_online_stores (only = ["redis" ])
37- def test_entity_ttl_online_store (environment , universal_data_sources ):
74+ def test_entity_ttl_online_store (environment , universal_data_sources , fake_ingest_data ):
3875 if os .getenv ("FEAST_IS_LOCAL_TEST" , "False" ) == "True" :
3976 return
4077 fs = environment .feature_store
@@ -47,19 +84,8 @@ def test_entity_ttl_online_store(environment, universal_data_sources):
4784 # Register Feature View and Entity
4885 fs .apply ([driver_hourly_stats , driver_entity ])
4986
50- # fake data to ingest into Online Store
51- data = {
52- "driver_id" : [1 ],
53- "conv_rate" : [0.5 ],
54- "acc_rate" : [0.6 ],
55- "avg_daily_trips" : [4 ],
56- "event_timestamp" : [pd .Timestamp (datetime .datetime .utcnow ()).round ("ms" )],
57- "created" : [pd .Timestamp (datetime .datetime .utcnow ()).round ("ms" )],
58- }
59- df_ingest = pd .DataFrame (data )
60-
6187 # directly ingest data into the Online Store
62- fs .write_to_online_store ("driver_stats" , df_ingest )
88+ fs .write_to_online_store ("driver_stats" , fake_ingest_data )
6389
6490 # assert the right data is in the Online Store
6591 df = fs .get_online_features (
0 commit comments