From ec6141d9fc0b9af1e54d49d279b5d892ffb095af Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Fri, 31 Oct 2025 11:51:11 +0800 Subject: [PATCH 01/10] chore: support ci mutli tests --- .github/workflows/ci.yml | 37 ++++++++++++++++++- .../tests/test_ollama_chat_model.py | 7 +++- .../tests/test_ollama_embedding_model.py | 7 +++- python/pyproject.toml | 5 +++ tools/ut.sh | 7 +++- 5 files changed, 55 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35eed124..d16a2246 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: run: tools/ut.sh -j python_tests: - name: python tests on ${{ matrix.os }} ${{ matrix.python-version}} + name: python tests (non-ollama) on ${{ matrix.os }} ${{ matrix.python-version}} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -88,8 +88,41 @@ jobs: uses: astral-sh/setup-uv@v4 with: version: "latest" - - name: Run Python Tests + - name: Run Python Tests (excluding Ollama) run: tools/ut.sh -p + env: + PYTEST_ARGS: "-m 'not ollama'" + + ollama_integration_tests: + name: ollama integration tests (linux python 3.10) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install java + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'adopt' + - name: Install python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + - name: Run Ollama Integration Tests + run: tools/ut.sh -p + env: + PYTEST_ARGS: "-m ollama -v" + CI: true + - name: Upload Ollama logs on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: ollama-logs + path: /tmp/ollama*.log + retention-days: 7 e2e_tests: name: e2e tests on ${{ matrix.os }} ${{ matrix.python-version}} diff --git a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py index b230a3b6..8ac91f83 100644 --- a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py +++ b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py @@ -32,12 +32,15 @@ ) from flink_agents.plan.tools.function_tool import FunctionTool, from_callable +# Mark all tests in this module as ollama tests +pytestmark = pytest.mark.ollama + test_model = os.environ.get("OLLAMA_CHAT_MODEL", "qwen3:0.6b") current_dir = Path(__file__).parent try: - # only auto setup ollama in ci with python 3.10 to reduce ci cost. - if "3.10" in sys.version: + # Auto setup ollama in CI environment (when CI env var is set) + if os.environ.get("CI") and sys.platform == "linux": subprocess.run( ["bash", f"{current_dir}/start_ollama_server.sh"], timeout=300, check=True ) diff --git a/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py b/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py index 3dfc6e01..4e5bca41 100644 --- a/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py +++ b/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py @@ -29,12 +29,15 @@ OllamaEmbeddingModelSetup, ) +# Mark all tests in this module as ollama tests +pytestmark = pytest.mark.ollama + test_model = os.environ.get("OLLAMA_EMBEDDING_MODEL", "all-minilm:22m") current_dir = Path(__file__).parent try: - # only auto setup ollama in ci with python 3.10 to reduce ci cost. - if "3.10" in sys.version: + # Auto setup ollama in CI environment (when CI env var is set) + if os.environ.get("CI") and sys.platform == "linux": subprocess.run( ["bash", f"{current_dir}/start_ollama_server.sh"], timeout=300, check=True ) diff --git a/python/pyproject.toml b/python/pyproject.toml index 47231f6d..f94e957b 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -177,5 +177,10 @@ ban-relative-imports = "all" [tool.ruff.lint.flake8-type-checking] strict = true +[tool.pytest.ini_options] +markers = [ + "ollama: marks tests that require Ollama server (deselect with '-m \"not ollama\"')", +] + [tool.ruff.format] docstring-code-format = true \ No newline at end of file diff --git a/tools/ut.sh b/tools/ut.sh index acb0307c..6a99dd62 100755 --- a/tools/ut.sh +++ b/tools/ut.sh @@ -122,6 +122,9 @@ python_tests() { set +e pushd "${ROOT}"/python + # Get PYTEST_ARGS environment variable, default to empty + local pytest_args="${PYTEST_ARGS:-}" + # Install dependencies and run tests echo "Installing Python test dependencies..." if command -v uv >/dev/null 2>&1; then @@ -132,7 +135,7 @@ python_tests() { if $verbose; then echo "Running tests with uv..." fi - uv run pytest flink_agents + uv run pytest flink_agents $pytest_args testcode=$? else if $verbose; then @@ -153,7 +156,7 @@ python_tests() { if $verbose; then echo "Running tests with pytest..." fi - pytest flink_agents + pytest flink_agents $pytest_args testcode=$? fi From 73c63ad2fa412012cd55846e4008ee0c5d553f8c Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Fri, 31 Oct 2025 12:01:11 +0800 Subject: [PATCH 02/10] chore: fix bug --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d16a2246..15d8f322 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: - name: Run Python Tests (excluding Ollama) run: tools/ut.sh -p env: - PYTEST_ARGS: "-m 'not ollama'" + PYTEST_ARGS: "-m not ollama" ollama_integration_tests: name: ollama integration tests (linux python 3.10) @@ -114,7 +114,7 @@ jobs: - name: Run Ollama Integration Tests run: tools/ut.sh -p env: - PYTEST_ARGS: "-m ollama -v" + PYTEST_ARGS: "-m ollama -v -s" CI: true - name: Upload Ollama logs on failure if: failure() From 5e14def7bcb1c01a0bd085b24c2f1731aca34b35 Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Fri, 31 Oct 2025 12:02:59 +0800 Subject: [PATCH 03/10] chore: refactor code --- .github/workflows/ci.yml | 5 +++-- tools/ut.sh | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15d8f322..35d69dff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: - name: Run Python Tests (excluding Ollama) run: tools/ut.sh -p env: - PYTEST_ARGS: "-m not ollama" + PYTEST_SKIP_MARKERS: "ollama" ollama_integration_tests: name: ollama integration tests (linux python 3.10) @@ -114,7 +114,8 @@ jobs: - name: Run Ollama Integration Tests run: tools/ut.sh -p env: - PYTEST_ARGS: "-m ollama -v -s" + PYTEST_ONLY_MARKERS: "ollama" + PYTEST_VERBOSE: "true" CI: true - name: Upload Ollama logs on failure if: failure() diff --git a/tools/ut.sh b/tools/ut.sh index 6a99dd62..5fcea9df 100755 --- a/tools/ut.sh +++ b/tools/ut.sh @@ -122,8 +122,20 @@ python_tests() { set +e pushd "${ROOT}"/python - # Get PYTEST_ARGS environment variable, default to empty - local pytest_args="${PYTEST_ARGS:-}" + # Build pytest arguments based on environment variables + local pytest_cmd="pytest flink_agents" + + # Support marker-based filtering for cleaner argument handling + if [ -n "${PYTEST_SKIP_MARKERS:-}" ]; then + pytest_cmd="$pytest_cmd -m not ${PYTEST_SKIP_MARKERS}" + elif [ -n "${PYTEST_ONLY_MARKERS:-}" ]; then + pytest_cmd="$pytest_cmd -m ${PYTEST_ONLY_MARKERS}" + fi + + # Add verbose flag if requested + if [ "${PYTEST_VERBOSE:-false}" = "true" ]; then + pytest_cmd="$pytest_cmd -v" + fi # Install dependencies and run tests echo "Installing Python test dependencies..." @@ -134,8 +146,9 @@ python_tests() { uv sync --extra test if $verbose; then echo "Running tests with uv..." + echo "Command: uv run $pytest_cmd" fi - uv run pytest flink_agents $pytest_args + uv run $pytest_cmd testcode=$? else if $verbose; then @@ -155,8 +168,9 @@ python_tests() { fi if $verbose; then echo "Running tests with pytest..." + echo "Command: $pytest_cmd" fi - pytest flink_agents $pytest_args + $pytest_cmd testcode=$? fi From 7e78d064e8572b3c72dbcd7e28c70a4dbd6ec05f Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Fri, 31 Oct 2025 15:04:18 +0800 Subject: [PATCH 04/10] chore: add timeout --- .../integrations/chat_models/tests/test_ollama_chat_model.py | 4 +++- .../local/tests/test_ollama_embedding_model.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py index 8ac91f83..6fba98f1 100644 --- a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py +++ b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py @@ -97,7 +97,9 @@ def get_tool(name: str, type: ResourceType) -> FunctionTool: # noqa :D103 client is None, reason="Ollama client is not available or test model is missing" ) def test_ollama_chat_with_tools() -> None: # noqa :D103 - connection = OllamaChatModelConnection(name="ollama") + # Use longer timeout for tool calling in CI environment (slower resources) + request_timeout = 120.0 if os.environ.get("CI") else 30.0 + connection = OllamaChatModelConnection(name="ollama", request_timeout=request_timeout) def get_resource(name: str, type: ResourceType) -> Resource: if type == ResourceType.TOOL: diff --git a/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py b/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py index 4e5bca41..4135cded 100644 --- a/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py +++ b/python/flink_agents/integrations/embedding_models/local/tests/test_ollama_embedding_model.py @@ -61,9 +61,12 @@ ) def test_ollama_embedding_setup() -> None: """Test embedding functionality with OllamaEmbeddingModelSetup.""" + # Use longer timeout for embedding in CI environment (slower resources) + request_timeout = 120.0 if os.environ.get("CI") else 30.0 connection = OllamaEmbeddingModelConnection( name="ollama_embed", - base_url="http://localhost:11434" + base_url="http://localhost:11434", + request_timeout=request_timeout ) def get_resource(name: str, type: ResourceType) -> Resource: From f942c52a6f498ddb03308fa874611a0efd2e0f22 Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Fri, 31 Oct 2025 15:35:46 +0800 Subject: [PATCH 05/10] chore: change args --- tools/ut.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/ut.sh b/tools/ut.sh index 5fcea9df..07c5266a 100755 --- a/tools/ut.sh +++ b/tools/ut.sh @@ -122,19 +122,19 @@ python_tests() { set +e pushd "${ROOT}"/python - # Build pytest arguments based on environment variables - local pytest_cmd="pytest flink_agents" + # Build pytest arguments array based on environment variables + local pytest_args=("pytest" "flink_agents") # Support marker-based filtering for cleaner argument handling if [ -n "${PYTEST_SKIP_MARKERS:-}" ]; then - pytest_cmd="$pytest_cmd -m not ${PYTEST_SKIP_MARKERS}" + pytest_args+=("-m" "not ${PYTEST_SKIP_MARKERS}") elif [ -n "${PYTEST_ONLY_MARKERS:-}" ]; then - pytest_cmd="$pytest_cmd -m ${PYTEST_ONLY_MARKERS}" + pytest_args+=("-m" "${PYTEST_ONLY_MARKERS}") fi # Add verbose flag if requested if [ "${PYTEST_VERBOSE:-false}" = "true" ]; then - pytest_cmd="$pytest_cmd -v" + pytest_args+=("-v") fi # Install dependencies and run tests @@ -146,9 +146,9 @@ python_tests() { uv sync --extra test if $verbose; then echo "Running tests with uv..." - echo "Command: uv run $pytest_cmd" + echo "Command: uv run ${pytest_args[*]}" fi - uv run $pytest_cmd + uv run "${pytest_args[@]}" testcode=$? else if $verbose; then @@ -168,9 +168,9 @@ python_tests() { fi if $verbose; then echo "Running tests with pytest..." - echo "Command: $pytest_cmd" + echo "Command: ${pytest_args[*]}" fi - $pytest_cmd + "${pytest_args[@]}" testcode=$? fi From c9f8cf52d1ebe1a38a3540e6d4ff05a93e5c23a6 Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Fri, 31 Oct 2025 17:11:57 +0800 Subject: [PATCH 06/10] chore: add timeout --- .../integrations/chat_models/tests/test_ollama_chat_model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py index 6fba98f1..c0b157ac 100644 --- a/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py +++ b/python/flink_agents/integrations/chat_models/tests/test_ollama_chat_model.py @@ -63,7 +63,9 @@ client is None, reason="Ollama client is not available or test model is missing" ) def test_ollama_chat() -> None: # noqa :D103 - server = OllamaChatModelConnection(name="ollama") + # Use longer timeout in CI environment (slower resources) + request_timeout = 120.0 if os.environ.get("CI") else 30.0 + server = OllamaChatModelConnection(name="ollama", request_timeout=request_timeout) response = server.chat( [ChatMessage(role=MessageRole.USER, content="Hello!")], model=test_model ) From e12a640dfe544ade7b5807545cfe975eb6e95834 Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Thu, 6 Nov 2025 11:42:54 +0800 Subject: [PATCH 07/10] refactor: isloted integration tests --- .github/workflows/ci.yml | 31 +++++++++++++++++-- .../tests/test_anthropic_chat_model.py | 5 ++- .../openai/tests/test_openai_chat_model.py | 5 ++- .../tests/test_openai_embedding_model.py | 5 ++- .../chroma/tests/test_chroma_vector_store.py | 9 ++++-- python/pyproject.toml | 1 + 6 files changed, 47 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35d69dff..9c6a95de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: run: tools/ut.sh -j python_tests: - name: python tests (non-ollama) on ${{ matrix.os }} ${{ matrix.python-version}} + name: python tests (non-integration) on ${{ matrix.os }} ${{ matrix.python-version}} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -88,10 +88,10 @@ jobs: uses: astral-sh/setup-uv@v4 with: version: "latest" - - name: Run Python Tests (excluding Ollama) + - name: Run Python Tests (excluding Integration) run: tools/ut.sh -p env: - PYTEST_SKIP_MARKERS: "ollama" + PYTEST_SKIP_MARKERS: "integration" ollama_integration_tests: name: ollama integration tests (linux python 3.10) @@ -125,6 +125,31 @@ jobs: path: /tmp/ollama*.log retention-days: 7 + integration_tests: + name: integration tests (linux python 3.10) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install java + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'adopt' + - name: Install python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + - name: Run Integration Tests + run: tools/ut.sh -p + env: + PYTEST_ONLY_MARKERS: "integration" + PYTEST_VERBOSE: "true" + CI: true + e2e_tests: name: e2e tests on ${{ matrix.os }} ${{ matrix.python-version}} runs-on: ${{ matrix.os }} diff --git a/python/flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_chat_model.py b/python/flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_chat_model.py index 95a77e5c..b74b4b0c 100644 --- a/python/flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_chat_model.py +++ b/python/flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_chat_model.py @@ -19,6 +19,9 @@ import pytest +# Mark all tests in this module as integration tests +pytestmark = pytest.mark.integration + from flink_agents.api.chat_message import ChatMessage, MessageRole from flink_agents.api.resource import Resource, ResourceType from flink_agents.integrations.chat_models.anthropic.anthropic_chat_model import ( @@ -27,7 +30,7 @@ ) from flink_agents.plan.tools.function_tool import from_callable -test_model = os.environ.get("TEST_MODEL") +test_model = os.environ.get("TEST_MODEL", "claude-3-haiku-20240307") api_key = os.environ.get("TEST_API_KEY") diff --git a/python/flink_agents/integrations/chat_models/openai/tests/test_openai_chat_model.py b/python/flink_agents/integrations/chat_models/openai/tests/test_openai_chat_model.py index dfd67eae..bbf88df1 100644 --- a/python/flink_agents/integrations/chat_models/openai/tests/test_openai_chat_model.py +++ b/python/flink_agents/integrations/chat_models/openai/tests/test_openai_chat_model.py @@ -19,6 +19,9 @@ import pytest +# Mark all tests in this module as integration tests +pytestmark = pytest.mark.integration + from flink_agents.api.chat_message import ChatMessage, MessageRole from flink_agents.api.resource import Resource, ResourceType from flink_agents.integrations.chat_models.openai.openai_chat_model import ( @@ -27,7 +30,7 @@ ) from flink_agents.plan.tools.function_tool import from_callable -test_model = os.environ.get("TEST_MODEL") +test_model = os.environ.get("TEST_MODEL", "gpt-3.5-turbo") api_key = os.environ.get("TEST_API_KEY") api_base_url = os.environ.get("TEST_API_BASE_URL") diff --git a/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py b/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py index 3f50736c..998eda0b 100644 --- a/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py +++ b/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py @@ -19,6 +19,9 @@ import pytest +# Mark all tests in this module as integration tests +pytestmark = pytest.mark.integration + from flink_agents.api.resource import Resource, ResourceType from flink_agents.integrations.embedding_models.openai_embedding_model import ( OpenAIEmbeddingModelConnection, @@ -26,7 +29,7 @@ ) test_model = os.environ.get("TEST_EMBEDDING_MODEL", "text-embedding-3-small") -api_key = os.environ.get("TEST_API_KEY") +api_key = os.environ.get("TEST_API_KEY", "fake-key") @pytest.mark.skipif(api_key is None, reason="TEST_API_KEY is not set") diff --git a/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py b/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py index 233c6b6a..d63710f4 100644 --- a/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py +++ b/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py @@ -20,6 +20,9 @@ import pytest +# Mark all tests in this module as integration tests +pytestmark = pytest.mark.integration + try: import chromadb # noqa: F401 @@ -35,9 +38,9 @@ ChromaVectorStore, ) -api_key = os.environ.get("TEST_API_KEY") -tenant = os.environ.get("TEST_TENANT") -database = os.environ.get("TEST_DATABASE") +api_key = os.environ.get("TEST_API_KEY", "fake-key") +tenant = os.environ.get("TEST_TENANT", "fake-tenant") +database = os.environ.get("TEST_DATABASE", "fake-database") class MockEmbeddingModel(Resource): # noqa: D101 diff --git a/python/pyproject.toml b/python/pyproject.toml index f94e957b..fe53e439 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -180,6 +180,7 @@ strict = true [tool.pytest.ini_options] markers = [ "ollama: marks tests that require Ollama server (deselect with '-m \"not ollama\"')", + "integration: marks tests that require external services or integration (deselect with '-m \"not integration\"')", ] [tool.ruff.format] From 458fdc7971bb0de332063833456dadc14b6ae625 Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Thu, 6 Nov 2025 14:56:02 +0800 Subject: [PATCH 08/10] bugfix: add TEST_API_KEY collect info --- .../tests/test_openai_embedding_model.py | 5 +++-- .../chroma/tests/test_chroma_vector_store.py | 16 ++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py b/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py index 998eda0b..a5484bbe 100644 --- a/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py +++ b/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py @@ -29,13 +29,14 @@ ) test_model = os.environ.get("TEST_EMBEDDING_MODEL", "text-embedding-3-small") -api_key = os.environ.get("TEST_API_KEY", "fake-key") +api_key = os.environ.get("TEST_API_KEY") @pytest.mark.skipif(api_key is None, reason="TEST_API_KEY is not set") +@pytest.mark.integration def test_openai_embedding_model() -> None: # noqa: D103 connection = OpenAIEmbeddingModelConnection( - name="openai", api_key=api_key + name="openai", api_key=api_key or "fake-key" ) def get_resource(name: str, type: ResourceType) -> Resource: diff --git a/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py b/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py index d63710f4..92279839 100644 --- a/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py +++ b/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py @@ -38,12 +38,15 @@ ChromaVectorStore, ) -api_key = os.environ.get("TEST_API_KEY", "fake-key") -tenant = os.environ.get("TEST_TENANT", "fake-tenant") -database = os.environ.get("TEST_DATABASE", "fake-database") +api_key = os.environ.get("TEST_API_KEY") +tenant = os.environ.get("TEST_TENANT") +database = os.environ.get("TEST_DATABASE") class MockEmbeddingModel(Resource): # noqa: D101 + def __init__(self, name: str): # noqa: D107 + self._name = name + @classmethod def resource_type(cls) -> ResourceType: # noqa: D102 return ResourceType.EMBEDDING_MODEL @@ -116,6 +119,7 @@ def get_resource(name: str, resource_type: ResourceType) -> Resource: @pytest.mark.skipif(api_key is None, reason="TEST_API_KEY is not set") +@pytest.mark.integration def test_cloud_chroma_vector_store() -> None: """Test cloud ChromaDB vector store with embedding model integration.""" embedding_model = MockEmbeddingModel(name="mock_embeddings") @@ -131,9 +135,9 @@ def get_resource(name: str, resource_type: ResourceType) -> Resource: name="chroma_vector_store", embedding_model="mock_embeddings", collection="test_collection", - api_key=api_key, - tenant=tenant, - database=database, + api_key=api_key or "fake-key", + tenant=tenant or "fake-tenant", + database=database or "fake-database", get_resource=get_resource ) From 0ac6d238fee8112e5a72df155e573728566281be Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Thu, 6 Nov 2025 15:17:00 +0800 Subject: [PATCH 09/10] fix: codestyle fix --- .../tests/test_anthropic_chat_model.py | 6 +++--- .../openai/tests/test_openai_chat_model.py | 6 +++--- .../tests/test_openai_embedding_model.py | 6 +++--- .../chroma/tests/test_chroma_vector_store.py | 18 +++++++++--------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/python/flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_chat_model.py b/python/flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_chat_model.py index b74b4b0c..e86bafb1 100644 --- a/python/flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_chat_model.py +++ b/python/flink_agents/integrations/chat_models/anthropic/tests/test_anthropic_chat_model.py @@ -19,9 +19,6 @@ import pytest -# Mark all tests in this module as integration tests -pytestmark = pytest.mark.integration - from flink_agents.api.chat_message import ChatMessage, MessageRole from flink_agents.api.resource import Resource, ResourceType from flink_agents.integrations.chat_models.anthropic.anthropic_chat_model import ( @@ -30,6 +27,9 @@ ) from flink_agents.plan.tools.function_tool import from_callable +# Mark all tests in this module as integration tests +pytestmark = pytest.mark.integration + test_model = os.environ.get("TEST_MODEL", "claude-3-haiku-20240307") api_key = os.environ.get("TEST_API_KEY") diff --git a/python/flink_agents/integrations/chat_models/openai/tests/test_openai_chat_model.py b/python/flink_agents/integrations/chat_models/openai/tests/test_openai_chat_model.py index bbf88df1..a4f7d4e8 100644 --- a/python/flink_agents/integrations/chat_models/openai/tests/test_openai_chat_model.py +++ b/python/flink_agents/integrations/chat_models/openai/tests/test_openai_chat_model.py @@ -19,9 +19,6 @@ import pytest -# Mark all tests in this module as integration tests -pytestmark = pytest.mark.integration - from flink_agents.api.chat_message import ChatMessage, MessageRole from flink_agents.api.resource import Resource, ResourceType from flink_agents.integrations.chat_models.openai.openai_chat_model import ( @@ -30,6 +27,9 @@ ) from flink_agents.plan.tools.function_tool import from_callable +# Mark all tests in this module as integration tests +pytestmark = pytest.mark.integration + test_model = os.environ.get("TEST_MODEL", "gpt-3.5-turbo") api_key = os.environ.get("TEST_API_KEY") api_base_url = os.environ.get("TEST_API_BASE_URL") diff --git a/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py b/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py index a5484bbe..49e9d6cf 100644 --- a/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py +++ b/python/flink_agents/integrations/embedding_models/tests/test_openai_embedding_model.py @@ -19,15 +19,15 @@ import pytest -# Mark all tests in this module as integration tests -pytestmark = pytest.mark.integration - from flink_agents.api.resource import Resource, ResourceType from flink_agents.integrations.embedding_models.openai_embedding_model import ( OpenAIEmbeddingModelConnection, OpenAIEmbeddingModelSetup, ) +# Mark all tests in this module as integration tests +pytestmark = pytest.mark.integration + test_model = os.environ.get("TEST_EMBEDDING_MODEL", "text-embedding-3-small") api_key = os.environ.get("TEST_API_KEY") diff --git a/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py b/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py index 92279839..2b468441 100644 --- a/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py +++ b/python/flink_agents/integrations/vector_stores/chroma/tests/test_chroma_vector_store.py @@ -20,6 +20,14 @@ import pytest +from flink_agents.api.resource import Resource, ResourceType +from flink_agents.api.vector_stores.vector_store import ( + VectorStoreQuery, +) +from flink_agents.integrations.vector_stores.chroma.chroma_vector_store import ( + ChromaVectorStore, +) + # Mark all tests in this module as integration tests pytestmark = pytest.mark.integration @@ -30,21 +38,13 @@ except ImportError: chromadb_available = False -from flink_agents.api.resource import Resource, ResourceType -from flink_agents.api.vector_stores.vector_store import ( - VectorStoreQuery, -) -from flink_agents.integrations.vector_stores.chroma.chroma_vector_store import ( - ChromaVectorStore, -) - api_key = os.environ.get("TEST_API_KEY") tenant = os.environ.get("TEST_TENANT") database = os.environ.get("TEST_DATABASE") class MockEmbeddingModel(Resource): # noqa: D101 - def __init__(self, name: str): # noqa: D107 + def __init__(self, name: str) -> None: # noqa: D107 self._name = name @classmethod From 454bc3e3dbc669cb033c66582307fd87da5227a6 Mon Sep 17 00:00:00 2001 From: kaori-seasons Date: Thu, 6 Nov 2025 15:18:34 +0800 Subject: [PATCH 10/10] fix: remove ollama --- python/pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index e1a127c6..18c99a49 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -194,7 +194,6 @@ strict = true [tool.pytest.ini_options] markers = [ - "ollama: marks tests that require Ollama server (deselect with '-m \"not ollama\"')", "integration: marks tests that require external services or integration (deselect with '-m \"not integration\"')", ]