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

Add kserve private endpoint tests #22

Merged
merged 36 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a0bccd6
Add kserve private endpoint tests
lugi0 Oct 23, 2024
f920126
Merge branch 'main' into feature/kserve_private_endpoint
lugi0 Oct 23, 2024
078605a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2024
b44312f
Fix typing annotations
lugi0 Oct 23, 2024
9fbaf1f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2024
df6c2e0
Fix pre-commit checks, add mypy ini file for vscode extension integra…
lugi0 Oct 23, 2024
863127c
Fix typo in function signature
lugi0 Oct 23, 2024
39dc8ba
Update renovate.json (#26)
rnetser Oct 27, 2024
87104c5
Lock file maintenance (#28)
renovate[bot] Oct 28, 2024
e8f8f36
[pre-commit.ci] pre-commit autoupdate (#29)
pre-commit-ci[bot] Oct 29, 2024
0895f32
[pre-commit.ci] pre-commit autoupdate (#32)
pre-commit-ci[bot] Nov 5, 2024
bd1b606
Lock file maintenance (#31)
renovate[bot] Nov 5, 2024
08201c6
add CONTRIBUTING and update README (#25)
rnetser Nov 6, 2024
657cf22
Move to Python 3.9 (#33)
rnetser Nov 6, 2024
4b50b4a
move aws creds and buckets config to pytest_addoption (#34)
rnetser Nov 7, 2024
9212ed0
Add kserve private endpoint tests
lugi0 Oct 23, 2024
411fb7b
Fix pre-commit checks, add mypy ini file for vscode extension integra…
lugi0 Oct 23, 2024
7bdf91d
Address PR comments
lugi0 Nov 11, 2024
54e619d
Merge branch 'main' into feature/kserve_private_endpoint
lugi0 Nov 11, 2024
6326c45
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 11, 2024
9f74122
fix failures, pre-commit
lugi0 Nov 11, 2024
6ca8d2b
Merge branch 'main' into feature/kserve_private_endpoint
lugi0 Nov 11, 2024
c31c902
Merge branch 'main' into feature/kserve_private_endpoint
lugi0 Nov 14, 2024
c67627a
Fix typo in gitignore
lugi0 Nov 14, 2024
38b1f72
Remove duplicated lines
lugi0 Nov 14, 2024
384860d
Merge branch 'main' into feature/kserve_private_endpoint
lugi0 Nov 22, 2024
c9ade8a
Address review comments
lugi0 Nov 22, 2024
22619a2
fix broken import
lugi0 Nov 22, 2024
8e6f07d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2024
55be899
Address PR comments, improve typing, remove mypy.ini, update CONTRIBU…
lugi0 Nov 25, 2024
fc93abf
add typing to storage_check func
lugi0 Nov 25, 2024
471360f
update deployment readiness check
lugi0 Nov 25, 2024
bb7b21c
Address PR comments
lugi0 Nov 25, 2024
174f4a5
Address PR comments
lugi0 Nov 26, 2024
841ef05
Address new comments
lugi0 Nov 26, 2024
e713bcd
Remove Enum inheritance
lugi0 Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# OS generated files #
.DS_Store
.DS_Store?
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ pre-commit install
## General

- Add typing to new code; typing is enforced using [mypy](https://mypy-lang.org/)
- Rules are defined in [our pyproject.toml file](//pyproject.toml#L10)

If you use Visual Studio Code as your IDE, we recommend using the [Mypy Type Checker](https://marketplace.visualstudio.com/items?itemName=ms-python.mypy-type-checker) extension.
After installing it, make sure to update the `Mypy-type-checkers: Args` setting
to `"mypy-type-checker.args" = ["--config-file=pyproject.toml"]`.
50 changes: 40 additions & 10 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import os
import pathlib
import shutil
from pytest import Parser, Session, FixtureRequest, FixtureDef, Item, Config, CollectReport
from _pytest.terminal import TerminalReporter
from typing import Optional, Any

from utilities.logger import separator, setup_logging

Expand All @@ -10,7 +13,7 @@
BASIC_LOGGER = logging.getLogger("basic")


def pytest_addoption(parser):
def pytest_addoption(parser: Parser) -> None:
aws_group = parser.getgroup(name="AWS")
buckets_group = parser.getgroup(name="Buckets")

Expand All @@ -31,8 +34,34 @@ def pytest_addoption(parser):
"--ci-s3-bucket-name", default=os.environ.get("CI_S3_BUCKET_NAME"), help="Ci S3 bucket name"
)

buckets_group.addoption(
lugi0 marked this conversation as resolved.
Show resolved Hide resolved
"--ci-s3-bucket-region", default=os.environ.get("CI_S3_BUCKET_REGION"), help="Ci S3 bucket region"
)

buckets_group.addoption(
"--ci-s3-bucket-endpoint", default=os.environ.get("CI_S3_BUCKET_ENDPOINT"), help="Ci S3 bucket endpoint"
)

buckets_group.addoption(
"--models-s3-bucket-name",
default=os.environ.get("MODELS_S3_BUCKET_NAME"),
help="Models S3 bucket name",
)

buckets_group.addoption(
"--models-s3-bucket-region",
default=os.environ.get("MODELS_S3_BUCKET_REGION"),
help="Models S3 bucket region",
)

buckets_group.addoption(
"--models-s3-bucket-endpoint",
default=os.environ.get("MODELS_S3_BUCKET_ENDPOINT"),
help="Models S3 bucket endpoint",
)


def pytest_sessionstart(session):
def pytest_sessionstart(session: Session) -> None:
tests_log_file = session.config.getoption("log_file") or "pytest-tests.log"
if os.path.exists(tests_log_file):
pathlib.Path(tests_log_file).unlink()
Expand All @@ -43,24 +72,24 @@ def pytest_sessionstart(session):
)


def pytest_fixture_setup(fixturedef, request):
def pytest_fixture_setup(fixturedef: FixtureDef[Any], request: FixtureRequest) -> None:
LOGGER.info(f"Executing {fixturedef.scope} fixture: {fixturedef.argname}")


def pytest_runtest_setup(item):
def pytest_runtest_setup(item: Item) -> None:
BASIC_LOGGER.info(f"\n{separator(symbol_='-', val=item.name)}")
BASIC_LOGGER.info(f"{separator(symbol_='-', val='SETUP')}")


def pytest_runtest_call(item):
def pytest_runtest_call(item: Item) -> None:
BASIC_LOGGER.info(f"{separator(symbol_='-', val='CALL')}")


def pytest_runtest_teardown(item):
def pytest_runtest_teardown(item: Item) -> None:
BASIC_LOGGER.info(f"{separator(symbol_='-', val='TEARDOWN')}")


def pytest_report_teststatus(report, config):
def pytest_report_teststatus(report: CollectReport, config: Config) -> None:
test_name = report.head_line
when = report.when
call_str = "call"
Expand All @@ -78,8 +107,9 @@ def pytest_report_teststatus(report, config):
BASIC_LOGGER.info(f"\nTEST: {test_name} STATUS: \033[0;31mFAILED\033[0m")


def pytest_sessionfinish(session, exitstatus):
def pytest_sessionfinish(session: Session, exitstatus: int) -> None:
shutil.rmtree(path=session.config.option.basetemp, ignore_errors=True)

reporter = session.config.pluginmanager.get_plugin("terminalreporter")
reporter.summary_stats()
reporter: Optional[TerminalReporter] = session.config.pluginmanager.get_plugin("terminalreporter")
if reporter:
reporter.summary_stats()
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ disallow_untyped_defs = true
no_implicit_optional = true
show_error_codes = true
warn_unused_ignores = true
ignore_missing_imports = true

[tool.uv]
dev-dependencies = [
Expand Down
98 changes: 97 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import Tuple, Any, Generator

import pytest
from pytest import FixtureRequest, Config
from kubernetes.dynamic import DynamicClient
from ocp_resources.namespace import Namespace
from ocp_resources.resource import get_client
Expand All @@ -12,6 +15,99 @@ def admin_client() -> DynamicClient:


@pytest.fixture(scope="class")
def model_namespace(request, admin_client: DynamicClient) -> Namespace:
def model_namespace(request: FixtureRequest, admin_client: DynamicClient) -> Generator[Namespace, Any, Any]:
with create_ns(client=admin_client, name=request.param["name"]) as ns:
yield ns


@pytest.fixture(scope="session")
def aws_access_key_id(pytestconfig: Config) -> str:
access_key = pytestconfig.option.aws_access_key_id
if not access_key:
raise ValueError(
"AWS access key id is not set. "
"Either pass with `--aws-access-key-id` or set `AWS_ACCESS_KEY_ID` environment variable"
)
return access_key


@pytest.fixture(scope="session")
def aws_secret_access_key(pytestconfig: Config) -> str:
secret_access_key = pytestconfig.option.aws_secret_access_key
if not secret_access_key:
raise ValueError(
"AWS secret access key is not set. "
"Either pass with `--aws-secret-access-key` or set `AWS_SECRET_ACCESS_KEY` environment variable"
)
return secret_access_key


@pytest.fixture(scope="session")
def valid_aws_config(aws_access_key_id: str, aws_secret_access_key: str) -> Tuple[str, str]:
return aws_access_key_id, aws_secret_access_key


@pytest.fixture(scope="session")
def ci_s3_bucket_name(pytestconfig: Config) -> str:
bucket_name = pytestconfig.option.ci_s3_bucket_name
if not bucket_name:
raise ValueError(
"CI S3 bucket name is not set. "
"Either pass with `--ci-s3-bucket-name` or set `CI_S3_BUCKET_NAME` environment variable"
)
return bucket_name


@pytest.fixture(scope="session")
def ci_s3_bucket_region(pytestconfig: pytest.Config) -> str:
ci_bucket_region = pytestconfig.option.ci_s3_bucket_region
if not ci_bucket_region:
raise ValueError(
"Bucket name for the models bucket is not defined."
lugi0 marked this conversation as resolved.
Show resolved Hide resolved
"Either pass with `--ci-s3-bucket-region` or set `CI_S3_BUCKET_REGION` environment variable"
)
return ci_bucket_region


@pytest.fixture(scope="session")
def ci_s3_bucket_endpoint(pytestconfig: pytest.Config) -> str:
ci_bucket_endpoint = pytestconfig.option.ci_s3_bucket_endpoint
if not ci_bucket_endpoint:
raise ValueError(
"Bucket name for the models bucket is not defined."
lugi0 marked this conversation as resolved.
Show resolved Hide resolved
"Either pass with `--ci-s3-bucket-endpoint` or set `CI_S3_BUCKET_ENDPOINT` environment variable"
)
return ci_bucket_endpoint


@pytest.fixture(scope="session")
def models_s3_bucket_name(pytestconfig: pytest.Config) -> str:
models_bucket = pytestconfig.option.models_s3_bucket_name
if not models_bucket:
raise ValueError(
"Bucket name for the models bucket is not defined."
"Either pass with `--models-s3-bucket-name` or set `MODELS_S3_BUCKET_NAME` environment variable"
)
return models_bucket
adolfo-ab marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(scope="session")
def models_s3_bucket_region(pytestconfig: pytest.Config) -> str:
models_bucket_region = pytestconfig.option.models_s3_bucket_region
if not models_bucket_region:
raise ValueError(
"Bucket name for the models bucket is not defined."
lugi0 marked this conversation as resolved.
Show resolved Hide resolved
"Either pass with `--models-s3-bucket-region` or set `MODELS_S3_BUCKET_REGION` environment variable"
)
return models_bucket_region


@pytest.fixture(scope="session")
def models_s3_bucket_endpoint(pytestconfig: pytest.Config) -> str:
models_bucket_endpoint = pytestconfig.option.models_s3_bucket_endpoint
if not models_bucket_endpoint:
raise ValueError(
"Bucket name for the models bucket is not defined."
lugi0 marked this conversation as resolved.
Show resolved Hide resolved
"Either pass with `--models-s3-bucket-endpoint` or set `MODELS_S3_BUCKET_ENDPOINT` environment variable"
)
return models_bucket_endpoint
2 changes: 2 additions & 0 deletions tests/model_serving/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
KSERVE_SERVERLESS: str = "Serverless"
KSERVE_RAWDEPLOYMENT: str = "RawDeployment"
lugi0 marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
Loading