Skip to content

Commit e6745f9

Browse files
chore: Update testing docs (feast-dev#3013)
* Make test_sql_registry tests unit tests Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Update testing docs Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent d4af068 commit e6745f9

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ benchmark-python-local:
6363
FEAST_USAGE=False IS_TEST=True FEAST_IS_LOCAL_TEST=True python -m pytest --integration --benchmark --benchmark-autosave --benchmark-save-data sdk/python/tests
6464

6565
test-python:
66-
FEAST_USAGE=False IS_TEST=True python -m pytest -n 8 sdk/python/tests
66+
@(docker info > /dev/null 2>&1 && \
67+
FEAST_USAGE=False \
68+
IS_TEST=True \
69+
python -m pytest -n 8 sdk/python/tests \
70+
) || echo "This script uses Docker, and it isn't running - please start the Docker Daemon and try again!";
6771

6872
test-python-integration:
6973
FEAST_USAGE=False IS_TEST=True python -m pytest -n 8 --integration sdk/python/tests

docs/how-to-guides/adding-or-reusing-tests.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ This guide will go over:
66

77
1. how Feast tests are setup
88
2. how to extend the test suite to test new functionality
9-
3. how to use the existing test suite to test a new custom offline / online store.
9+
3. how to use the existing test suite to test a new custom offline / online store
1010

1111
## Test suite overview
1212

13-
Let's inspect the test setup in `sdk/python/tests/integration`:
13+
Unit tests are contained in `sdk/python/tests/unit`.
14+
Integration tests are contained in `sdk/python/tests/integration`.
15+
Let's inspect the structure of `sdk/python/tests/integration`:
1416

1517
```bash
1618
$ tree
@@ -51,38 +53,38 @@ $ tree
5153
│ ├── test_s3_custom_endpoint.py
5254
│ └── test_universal_historical_retrieval.py
5355
├── online_store
54-
│ ├── test_online_retrieval.py
5556
│ ├── test_push_features_to_online_store.py
5657
│ └── test_universal_online.py
5758
└── registration
5859
├── test_feature_store.py
5960
├── test_inference.py
6061
├── test_registry.py
61-
├── test_sql_registry.py
6262
├── test_universal_cli.py
6363
├── test_universal_odfv_feature_inference.py
6464
└── test_universal_types.py
6565

6666
```
6767

6868
* `feature_repos` has setup files for most tests in the test suite.
69-
* `conftest.py` and some of the individual test files contain fixtures which can be used to on different offline stores, online stores, etc. and thus abstract away store specific implementations so we don't need to rewrite the same test implementation for different stores.
69+
* `conftest.py` (in the parent directory) contains the most common [fixtures](https://docs.pytest.org/en/6.2.x/fixture.html), which are designed as an abstraction on top of specific offline/online stores, so tests do not need to be rewritten for different stores. Individual test files also contain more specific fixtures.
70+
* The tests are organized by which Feast component(s) they test.
7071

7172
## Structure of the test suite
7273

73-
### What is the universal test suite?
74+
### Universal feature repo
7475

75-
The universal test suite verifies that crucial Feast functions (e.g `get_historical_features`, `get_online_features` etc.) have the correct behavior for each of the different environments that Feast could be used in. These environments are combinations of an offline store, online store, and provider and the universal test suite serves to run basic functional verification against all of these different permutations.
76+
The universal feature repo refers to a set of fixtures (e.g. `environment` and `universal_data_sources`) that can be parametrized to cover various combinations of offline stores, online stores, and providers.
77+
This allows tests to run against all these various combinations without requiring excess code.
78+
The universal feature repo is constructed by fixtures in `conftest.py` with help from the various files in `feature_repos`.
7679

77-
We use pytest [fixtures](https://docs.pytest.org/en/6.2.x/fixture.html) to accomplish this without writing excess code.
80+
### Integration vs. unit tests
7881

7982
Tests in Feast are split into integration and unit tests.
83+
If a test requires external resources (e.g. cloud resources on GCP or AWS), it is an integration test.
84+
If a test can be run purely locally (where locally includes Docker resources), it is a unit test.
8085

81-
### Is it an integration or unit test?
82-
83-
* Integration tests test non local Feast behavior. Integration tests mainly involve testing of Feast components that connect to services outside of Feast(e.g connecting to gcp or aws clients).
84-
* Generally if the test requires the initialization of a feature store in an external environment in order to test (i.e using our universal test fixtures), it is probably an integration test.
85-
* Unit tests, on the other hand, unit tests primarily test local and class level behavior that does not require spinning up an external service. If your test can be run locally without using any other services besides pytest, it is a unit test.
86+
* Integration tests test non-local Feast behavior. For example, tests that require reading data from BigQuery or materializing data to DynamoDB are integration tests. Integration tests also tend to involve more complex Feast functionality.
87+
* Unit tests test local Feast behavior. For example, tests that only require registering feature views are unit tests. Unit tests tend to only involve simple Feast functionality.
8688

8789
### Main types of tests
8890

sdk/python/tests/integration/registration/test_sql_registry.py renamed to sdk/python/tests/unit/test_sql_registry.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ def mysql_registry():
110110

111111
@pytest.fixture(scope="session")
112112
def sqlite_registry():
113-
114113
registry_config = RegistryConfig(
115114
registry_type="sql",
116115
path="sqlite://",
@@ -486,7 +485,6 @@ def odfv1(feature_df: pd.DataFrame) -> pd.DataFrame:
486485
sys.platform == "darwin" and "GITHUB_REF" in os.environ,
487486
reason="does not run on mac github actions",
488487
)
489-
@pytest.mark.integration
490488
@pytest.mark.parametrize(
491489
"sql_registry",
492490
[

0 commit comments

Comments
 (0)