11import tempfile
2+ import uuid
23from contextlib import contextmanager
3- from pathlib import Path
4+ from pathlib import Path , PosixPath
45from textwrap import dedent
56
6- import assertpy
77import pytest
8-
9- from feast .feature_store import FeatureStore
8+ import yaml
9+ from assertpy import assertpy
10+
11+ from feast import FeatureStore , RepoConfig
12+ from tests .integration .feature_repos .repo_configuration import FULL_REPO_CONFIGS
13+ from tests .integration .feature_repos .universal .data_source_creator import (
14+ DataSourceCreator ,
15+ )
1016from tests .utils .cli_utils import CliRunner , get_example_repo
1117from tests .utils .online_read_write_test import basic_rw_test
1218
1319
1420@pytest .mark .integration
15- def test_workflow () -> None :
16- """
17- Test running apply on a sample repo, and make sure the infra gets created.
18- """
21+ @ pytest . mark . parametrize ( "test_repo_config" , FULL_REPO_CONFIGS )
22+ def test_universal_cli ( test_repo_config ) -> None :
23+ project = f"test_universal_cli_ { str ( uuid . uuid4 ()). replace ( '-' , '' )[: 8 ] } "
24+
1925 runner = CliRunner ()
20- with tempfile .TemporaryDirectory () as repo_dir_name , tempfile .TemporaryDirectory () as data_dir_name :
2126
22- # Construct an example repo in a temporary dir
27+ with tempfile .TemporaryDirectory () as repo_dir_name :
28+ feature_store_yaml = make_feature_store_yaml (
29+ project , test_repo_config , repo_dir_name
30+ )
2331 repo_path = Path (repo_dir_name )
24- data_path = Path (data_dir_name )
2532
2633 repo_config = repo_path / "feature_store.yaml"
2734
28- repo_config .write_text (
29- dedent (
30- f"""
31- project: foo
32- registry: { data_path / "registry.db" }
33- provider: local
34- online_store:
35- path: { data_path / "online_store.db" }
36- offline_store:
37- type: bigquery
38- """
39- )
40- )
35+ repo_config .write_text (dedent (feature_store_yaml ))
4136
4237 repo_example = repo_path / "example.py"
4338 repo_example .write_text (get_example_repo ("example_feature_repo_1.py" ))
44-
4539 result = runner .run (["apply" ], cwd = repo_path )
4640 assertpy .assert_that (result .returncode ).is_equal_to (0 )
4741
@@ -65,6 +59,9 @@ def test_workflow() -> None:
6559 )
6660 assertpy .assert_that (result .returncode ).is_equal_to (0 )
6761
62+ fs = FeatureStore (repo_path = str (repo_path ))
63+ assertpy .assert_that (fs .list_feature_views ()).is_length (3 )
64+
6865 # entity & feature view describe commands should fail when objects don't exist
6966 result = runner .run (["entities" , "describe" , "foo" ], cwd = repo_path )
7067 assertpy .assert_that (result .returncode ).is_equal_to (1 )
@@ -76,7 +73,6 @@ def test_workflow() -> None:
7673 # Doing another apply should be a no op, and should not cause errors
7774 result = runner .run (["apply" ], cwd = repo_path )
7875 assertpy .assert_that (result .returncode ).is_equal_to (0 )
79-
8076 basic_rw_test (
8177 FeatureStore (repo_path = str (repo_path ), config = None ),
8278 view_name = "driver_locations" ,
@@ -86,44 +82,29 @@ def test_workflow() -> None:
8682 assertpy .assert_that (result .returncode ).is_equal_to (0 )
8783
8884
89- @pytest .mark .integration
90- def test_non_local_feature_repo () -> None :
91- """
92- Test running apply on a sample repo, and make sure the infra gets created.
93- """
94- runner = CliRunner ()
95- with tempfile .TemporaryDirectory () as repo_dir_name :
96-
97- # Construct an example repo in a temporary dir
98- repo_path = Path (repo_dir_name )
99-
100- repo_config = repo_path / "feature_store.yaml"
101-
102- repo_config .write_text (
103- dedent (
104- """
105- project: foo
106- registry: data/registry.db
107- provider: local
108- online_store:
109- path: data/online_store.db
110- offline_store:
111- type: bigquery
112- """
113- )
114- )
115-
116- repo_example = repo_path / "example.py"
117- repo_example .write_text (get_example_repo ("example_feature_repo_1.py" ))
118-
119- result = runner .run (["apply" ], cwd = repo_path )
120- assertpy .assert_that (result .returncode ).is_equal_to (0 )
121-
122- fs = FeatureStore (repo_path = str (repo_path ))
123- assertpy .assert_that (fs .list_feature_views ()).is_length (3 )
124-
125- result = runner .run (["teardown" ], cwd = repo_path )
126- assertpy .assert_that (result .returncode ).is_equal_to (0 )
85+ def make_feature_store_yaml (project , test_repo_config , repo_dir_name : PosixPath ):
86+ offline_creator : DataSourceCreator = test_repo_config .offline_store_creator (project )
87+
88+ offline_store_config = offline_creator .create_offline_store_config ()
89+ online_store = test_repo_config .online_store
90+
91+ config = RepoConfig (
92+ registry = str (Path (repo_dir_name ) / "registry.db" ),
93+ project = project ,
94+ provider = test_repo_config .provider ,
95+ offline_store = offline_store_config ,
96+ online_store = online_store ,
97+ repo_path = str (Path (repo_dir_name )),
98+ )
99+ config_dict = config .dict ()
100+ if (
101+ isinstance (config_dict ["online_store" ], dict )
102+ and "redis_type" in config_dict ["online_store" ]
103+ ):
104+ del config_dict ["online_store" ]["redis_type" ]
105+ config_dict ["repo_path" ] = str (config_dict ["repo_path" ])
106+
107+ return yaml .safe_dump (config_dict )
127108
128109
129110@contextmanager
0 commit comments