Skip to content

Commit

Permalink
fixing the integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Abdul Hameed <[email protected]>
  • Loading branch information
redhatHameed committed Jun 11, 2024
1 parent e34b070 commit 2818626
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
2 changes: 0 additions & 2 deletions sdk/python/requirements/py3.10-ci-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@ multidict==6.0.5
# yarl
multipledispatch==1.0.0
# via ibis-framework
multiprocess==0.70.16
# via feast (setup.py)
mypy==1.10.0
# via
# feast (setup.py)
Expand Down
2 changes: 0 additions & 2 deletions sdk/python/requirements/py3.11-ci-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,6 @@ multidict==6.0.5
# yarl
multipledispatch==1.0.0
# via ibis-framework
multiprocess==0.70.16
# via feast (setup.py)
mypy==1.10.0
# via
# feast (setup.py)
Expand Down
2 changes: 0 additions & 2 deletions sdk/python/requirements/py3.9-ci-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ multidict==6.0.5
# yarl
multipledispatch==1.0.0
# via ibis-framework
multiprocess==0.70.16
# via feast (setup.py)
mypy==1.10.0
# via
# feast (setup.py)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import logging
import os.path
import shutil
import tempfile
import uuid
from multiprocessing import Process
from typing import Any, Dict, List, Optional

import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
from minio import Minio
from multiprocess import Process
from testcontainers.core.generic import DockerContainer
from testcontainers.core.waiting_utils import wait_for_logs
from testcontainers.minio import MinioContainer
Expand All @@ -32,6 +33,8 @@
)
from tests.utils.http_server import check_port_open, free_port # noqa: E402

logger = logging.getLogger(__name__)


class FileDataSourceCreator(DataSourceCreator):
files: List[Any]
Expand Down Expand Up @@ -362,33 +365,34 @@ def create_offline_store_config(self):
class RemoteOfflineStoreDataSourceCreator(FileDataSourceCreator):
def __init__(self, project_name: str, *args, **kwargs):
super().__init__(project_name)
self.server_port: int = 0
self.server_port: int = 8815
self.proc: Process = None

def setup(self, registry: RegistryConfig):
parent_offline_config = super().create_offline_store_config()

fs = FeatureStore(
config=RepoConfig(
project=self.project_name,
provider="local",
offline_store=parent_offline_config,
registry=registry.path,
entity_key_serialization_version=2,
)
)
self.server_port = free_port()
host = "0.0.0.0"
self.proc = Process(
target=start_server,
args=(fs, host, self.server_port),
target=start_test_local_server,
args=(
parent_offline_config,
self.project_name,
registry.path,
host,
self.server_port,
),
)
self.proc.start()
_time_out_sec: int = 180

# Wait for server to start
wait_retry_backoff(
lambda: (None, check_port_open(host, self.server_port)),
timeout_secs=10,
timeout_secs=_time_out_sec,
timeout_msg=f"Unable to start the feast server in {_time_out_sec} seconds for remote offline store type, port={self.server_port}",
)
logger.info("Port has been freed.")
return "grpc+tcp://{}:{}".format(host, self.server_port)

def create_offline_store_config(self) -> FeastConfigBaseModel:
Expand All @@ -398,15 +402,31 @@ def create_offline_store_config(self) -> FeastConfigBaseModel:
return self.remote_offline_store_config

def teardown(self):
super().teardown()
if self.proc is None and self.proc.is_alive():
self.proc.kill()
logger.info("Server process killed.")

# wait server to free the port
wait_retry_backoff(
lambda: (
None,
not check_port_open("localhost", self.server_port),
),
timeout_secs=30,
timeout_secs=10,
)
super().teardown()


def start_test_local_server(
parent_offline_config, project_name, registry_path, host, port
):
fs = FeatureStore(
config=RepoConfig(
project=project_name,
provider="local",
offline_store=parent_offline_config,
registry=registry_path,
entity_key_serialization_version=2,
)
)
start_server(fs, host, port)
6 changes: 3 additions & 3 deletions sdk/python/tests/utils/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


def free_port():
sock = socket.socket()
sock.bind(("", 0))
return sock.getsockname()[1]
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.bind(("", 0))
return sock.getsockname()[1]


def check_port_open(host, port) -> bool:
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
"mock==2.0.0",
"moto<5",
"mypy>=1.4.1",
"multiprocess>=0.70.16",
"urllib3>=1.25.4,<3",
"psutil==5.9.0",
"py>=1.11.0", # https://github.com/pytest-dev/pytest/issues/10420
Expand Down

0 comments on commit 2818626

Please sign in to comment.