Skip to content
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

Draft: Separating the keycloak integration tests into its own job #4903

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ test-python-unit:
test-python-integration:
python -m pytest --tb=short -v -n 8 --integration --color=yes --durations=10 --timeout=1200 --timeout_method=thread --dist loadgroup \
-k "(not snowflake or not test_historical_features_main)" \
--log-cli-level=INFO -s \
sdk/python/tests

test-python-integration-local:
FEAST_IS_LOCAL_TEST=True \
FEAST_LOCAL_ONLINE_CONTAINER=True \
python -m pytest --tb=short -v -n 8 --color=yes --integration --durations=10 --timeout=1200 --timeout_method=thread --dist loadgroup \
-k "not test_lambda_materialization and not test_snowflake_materialization" \
--log-cli-level=INFO -s \
sdk/python/tests

test-python-integration-container:
Expand Down
20 changes: 19 additions & 1 deletion sdk/python/tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import logging
import random
import time
from multiprocessing import Manager

import pytest
from testcontainers.keycloak import KeycloakContainer
Expand All @@ -9,15 +12,30 @@
from tests.utils.auth_permissions_util import setup_permissions_on_keycloak

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger.propagate = True

shared_state = Manager().dict()

@pytest.fixture(scope="session")
def start_keycloak_server():
# Add random sleep between 0 and 2 before checking the state to avoid concurrency issues.
random_sleep_time = random.uniform(0, 2)
time.sleep(random_sleep_time)

# If the Keycloak instance is already started (in any worker), reuse it
if shared_state.get("keycloak_started", False):
return shared_state["keycloak_url"]
logger.info("Starting keycloak instance")
with KeycloakContainer("quay.io/keycloak/keycloak:24.0.1") as keycloak_container:
setup_permissions_on_keycloak(keycloak_container.get_client())
yield keycloak_container.get_url()
shared_state["keycloak_started"] = True
shared_state["keycloak_url"] = keycloak_container.get_url()
yield shared_state["keycloak_url"]

# After the fixture is done, cleanup the shared state
del shared_state["keycloak_started"]
del shared_state["keycloak_url"]

@pytest.fixture(scope="session")
def mysql_server():
Expand Down
Loading