-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ci: Use testcontainers to spin up redis and datastore instances #2493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
feast-ci-bot
merged 12 commits into
feast-dev:master
from
achals:achal/redis-test-container
Apr 7, 2022
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
80b58e4
ci: Use testcontainers to spin up redis instances for tests
achals bb5aacd
fix test
achals aac2f07
fix test
achals f6fdc50
fix type
achals 235b7fa
fix type
achals 9c52468
fix typo and repr
achals 6f00801
datastore baby
achals 50aa0ed
Make containers optional
achals f16ed52
more optionality
achals 95b0c1f
makefile target and docs
achals 9b37133
makefile target and docs
achals b8c0936
cr
achals File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
38 changes: 38 additions & 0 deletions
38
sdk/python/tests/integration/feature_repos/universal/online_store/datastore.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import os | ||
| from typing import Dict | ||
|
|
||
| from google.cloud import datastore | ||
| from testcontainers.core.container import DockerContainer | ||
| from testcontainers.core.waiting_utils import wait_for_logs | ||
|
|
||
| from tests.integration.feature_repos.universal.online_store_creator import ( | ||
| OnlineStoreCreator, | ||
| ) | ||
|
|
||
|
|
||
| class DatastoreOnlineStoreCreator(OnlineStoreCreator): | ||
| def __init__(self, project_name: str): | ||
| super().__init__(project_name) | ||
| self.container = ( | ||
| DockerContainer( | ||
| "gcr.io/google.com/cloudsdktool/cloud-sdk:380.0.0-emulators" | ||
| ) | ||
| .with_command( | ||
| "gcloud beta emulators datastore start --project test-project --host-port 0.0.0.0:8081" | ||
| ) | ||
| .with_exposed_ports("8081") | ||
| ) | ||
|
|
||
| def create_online_store(self) -> Dict[str, str]: | ||
| self.container.start() | ||
| log_string_to_wait_for = r"\[datastore\] Dev App Server is now running" | ||
| wait_for_logs( | ||
| container=self.container, predicate=log_string_to_wait_for, timeout=5 | ||
| ) | ||
| exposed_port = self.container.get_exposed_port("8081") | ||
| os.environ[datastore.client.DATASTORE_EMULATOR_HOST] = f"0.0.0.0:{exposed_port}" | ||
| return {"type": "datastore", "project_id": "test-project"} | ||
|
|
||
| def teardown(self): | ||
| del os.environ[datastore.client.DATASTORE_EMULATOR_HOST] | ||
| self.container.stop() |
26 changes: 26 additions & 0 deletions
26
sdk/python/tests/integration/feature_repos/universal/online_store/redis.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| from typing import Dict | ||
|
|
||
| from testcontainers.core.container import DockerContainer | ||
| from testcontainers.core.waiting_utils import wait_for_logs | ||
|
|
||
| from tests.integration.feature_repos.universal.online_store_creator import ( | ||
| OnlineStoreCreator, | ||
| ) | ||
|
|
||
|
|
||
| class RedisOnlineStoreCreator(OnlineStoreCreator): | ||
| def __init__(self, project_name: str): | ||
| super().__init__(project_name) | ||
| self.container = DockerContainer("redis").with_exposed_ports("6379") | ||
|
|
||
| def create_online_store(self) -> Dict[str, str]: | ||
| self.container.start() | ||
| log_string_to_wait_for = "Ready to accept connections" | ||
| wait_for_logs( | ||
| container=self.container, predicate=log_string_to_wait_for, timeout=5 | ||
| ) | ||
| exposed_port = self.container.get_exposed_port("6379") | ||
| return {"type": "redis", "connection_string": f"localhost:{exposed_port},db=0"} | ||
|
|
||
| def teardown(self): | ||
| self.container.stop() |
14 changes: 14 additions & 0 deletions
14
sdk/python/tests/integration/feature_repos/universal/online_store_creator.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from abc import ABC | ||
|
|
||
| from feast.repo_config import FeastConfigBaseModel | ||
|
|
||
|
|
||
| class OnlineStoreCreator(ABC): | ||
| def __init__(self, project_name: str): | ||
| self.project_name = project_name | ||
|
|
||
| def create_online_store(self) -> FeastConfigBaseModel: | ||
| ... | ||
|
|
||
| def teardown(self): | ||
| ... |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.