Adding or reusing tests
Overview
This guide will go over:
how Feast tests are setup
how to extend the test suite to test new functionality
how to use the existing test suite to test a new custom offline / online store.
Test suite overview
Let's inspect the test setup in sdk/python/tests/integration
:
feature_repos
has setup files for most tests in the test suite and pytest fixtures for other tests. These fixtures parametrize on different offline stores, online stores, etc. and thus abstract away store specific implementations so tests don't need to rewrite e.g. uploading dataframes to a specific store for setup.
Understanding an example test
Let's look at a sample test using the universal repo:
The key fixtures are the environment
and universal_data_sources
fixtures, which are defined in the feature_repos
directories. This by default pulls in a standard dataset with driver and customer entities, certain feature views, and feature values. By including the environment as a parameter, the test automatically parametrizes across other offline / online store combinations.
Writing a new test or reusing existing tests
To add a new test to an existing test file
Use the same function signatures as an existing test (e.g. use
environment
as an argument) to include the relevant test fixtures.If possible, expand an individual test instead of writing a new test, due to the cost of standing up offline / online stores.
To test a new offline / online store from a plugin repo
Install Feast in editable mode with
pip install -e
.The core tests for offline / online store behavior are parametrized by the
FULL_REPO_CONFIGS
variable defined infeature_repos/repo_configuration.py
. To overwrite this variable without modifying the Feast repo, create your own file that contains aFULL_REPO_CONFIGS
(which will require adding a newIntegrationTestRepoConfig
or two) and set the environment variableFULL_REPO_CONFIGS_MODULE
to point to that file. Then the core offline / online store tests can be run withmake test-python-universal
.See the custom offline store demo and the custom online store demo for examples.
To include a new offline / online store in the main Feast repo
Extend
data_source_creator.py
for your offline store.In
repo_configuration.py
add a newIntegrationTestRepoConfig
or two (depending on how many online stores you want to test).Run the full test suite with
make test-python-integration.
Including a new offline / online store in the main Feast repo from external plugins with community maintainers.
This folder is for plugins that are officially maintained with community owners. Place the APIs in feast/infra/offline_stores/contrib/.
Extend
data_source_creator.py
for your offline store and implement the required APIs.In
contrib_repo_configuration.py
add a newIntegrationTestRepoConfig
(depending on how many online stores you want to test).Run the test suite on the contrib test suite with
make test-python-contrib-universal
.
To include a new online store
In
repo_configuration.py
add a new config that maps to a serialized version of configuration you need infeature_store.yaml
to setup the online store.In
repo_configuration.py
, add newIntegrationTestRepoConfig
for offline stores you want to test.Run the full test suite with
make test-python-integration
To use custom data in a new test
Check
test_universal_types.py
for an example of how to do this.
Running your own redis cluster for testing
Install redis on your computer. If you are a mac user, you should be able to
brew install redis
.Running
redis-server --help
andredis-cli --help
should show corresponding help menus.
Run
cd scripts/create-cluster
and run./create-cluster start
then./create-cluster create
to start the server. You should see output that looks like this:
You should be able to run the integration tests and have the redis cluster tests pass.
If you would like to run your own redis cluster, you can run the above commands with your own specified ports and connect to the newly configured cluster.
To stop the cluster, run
./create-cluster stop
and then./create-cluster clean
.
Last updated