Skip to content

Commit 695f5dd

Browse files
authored
ci: Use testcontainers to spin up DynamoDB instances for local integration tests (#2531)
* feat: DynamoDBOnlineStoreCreator Signed-off-by: Miguel Trejo <[email protected]> * fix: DynamoDBOnlineStoreCreator return endpoint_url and aws region Signed-off-by: Miguel Trejo <[email protected]>
1 parent fc34981 commit 695f5dd

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ These tests create new temporary tables / datasets locally only, and they are cl
171171

172172
The services with containerized replacements currently implemented are:
173173
- Datastore
174+
- DynamoDB
174175
- Redis
175176

176177
You can run `make test-python-integration-container` to run tests against the containerized versions of dependencies.

sdk/python/tests/integration/feature_repos/repo_configuration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
from tests.integration.feature_repos.universal.online_store.datastore import (
4949
DatastoreOnlineStoreCreator,
5050
)
51+
from tests.integration.feature_repos.universal.online_store.dynamodb import (
52+
DynamoDBOnlineStoreCreator,
53+
)
5154
from tests.integration.feature_repos.universal.online_store.redis import (
5255
RedisOnlineStoreCreator,
5356
)
@@ -131,7 +134,10 @@
131134

132135
if os.getenv("FEAST_LOCAL_ONLINE_CONTAINER", "False").lower() == "true":
133136
replacements = {"datastore": DatastoreOnlineStoreCreator}
134-
replacement_dicts = [(REDIS_CONFIG, RedisOnlineStoreCreator)]
137+
replacement_dicts = [
138+
(REDIS_CONFIG, RedisOnlineStoreCreator),
139+
(DYNAMO_CONFIG, DynamoDBOnlineStoreCreator),
140+
]
135141
for c in FULL_REPO_CONFIGS:
136142
if isinstance(c.online_store, dict):
137143
for _replacement in replacement_dicts:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from typing import Dict
2+
3+
from testcontainers.core.container import DockerContainer
4+
from testcontainers.core.waiting_utils import wait_for_logs
5+
6+
from tests.integration.feature_repos.universal.online_store_creator import (
7+
OnlineStoreCreator,
8+
)
9+
10+
11+
class DynamoDBOnlineStoreCreator(OnlineStoreCreator):
12+
def __init__(self, project_name: str):
13+
super().__init__(project_name)
14+
self.container = DockerContainer(
15+
"amazon/dynamodb-local:latest"
16+
).with_exposed_ports("8000")
17+
18+
def create_online_store(self) -> Dict[str, str]:
19+
self.container.start()
20+
log_string_to_wait_for = (
21+
"Initializing DynamoDB Local with the following configuration:"
22+
)
23+
wait_for_logs(
24+
container=self.container, predicate=log_string_to_wait_for, timeout=5
25+
)
26+
exposed_port = self.container.get_exposed_port("8000")
27+
return {
28+
"type": "dynamodb",
29+
"endpoint_url": f"http://localhost:{exposed_port}",
30+
"region": "us-west-2",
31+
}
32+
33+
def teardown(self):
34+
self.container.stop()

0 commit comments

Comments
 (0)