Split out GRPC tests (#5431)

This commit is contained in:
Jack Gerrits 2025-02-07 11:57:30 -05:00 committed by GitHub
parent 362d6a4e6b
commit f7f5507c70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 66 additions and 0 deletions

View File

@ -149,6 +149,38 @@ jobs:
name: coverage-${{ env.PKG_NAME }}
path: ./python/coverage_${{ env.PKG_NAME }}.xml
test-grpc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
version: "0.5.18"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Run uv sync
run: |
uv sync --locked --all-extras
working-directory: ./python
- name: Run task
run: |
source ${{ github.workspace }}/python/.venv/bin/activate
poe --directory ./packages/autogen-ext test-grpc
working-directory: ./python
- name: Move coverage file
run: |
mv ./packages/autogen-ext/coverage.xml coverage_autogen-ext-grpc.xml
working-directory: ./python
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-autogen-ext-grpc
path: ./python/coverage_autogen-ext-grpc.xml
codecov:
runs-on: ubuntu-latest
needs: [test]
@ -159,6 +191,7 @@ jobs:
"./packages/autogen-core",
"./packages/autogen-ext",
"./packages/autogen-agentchat",
"autogen-ext-grpc",
]
steps:
- uses: actions/checkout@v4

View File

@ -0,0 +1,17 @@
import pytest
def pytest_addoption(parser):
parser.addoption(
"--grpc", action="store_true", default=False, help="run grpc tests"
)
def pytest_collection_modifyitems(config, items):
grpc_option_passed = config.getoption("--grpc")
skip_grpc = pytest.mark.skip(reason="Need --grpc option to run")
skip_non_grpc = pytest.mark.skip(reason="Skipped since --grpc passed")
for item in items:
if "grpc" in item.keywords and not grpc_option_passed:
item.add_marker(skip_grpc)
elif "grpc" not in item.keywords and grpc_option_passed:
item.add_marker(skip_non_grpc)

View File

@ -136,6 +136,9 @@ exclude = ["src/autogen_ext/runtimes/grpc/protos", "tests/protos"]
[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]
markers = [
"grpc",
]
[tool.poe]
include = "../../shared_tasks.toml"
@ -146,6 +149,7 @@ test.sequence = [
"pytest -n 1 --cov=src --cov-report=term-missing --cov-report=xml",
]
test.default_item_type = "cmd"
test-grpc = "pytest -n 1 --cov=src --cov-report=term-missing --cov-report=xml --grpc"
mypy = "mypy --config-file ../../pyproject.toml --exclude src/autogen_ext/runtimes/grpc/protos --exclude tests/protos src tests"
[tool.mypy]

View File

@ -32,6 +32,7 @@ from autogen_test_utils import (
from protos.serialization_test_pb2 import ProtoMessage
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_agent_types_must_be_unique_single_worker() -> None:
host_address = "localhost:50051"
@ -54,6 +55,7 @@ async def test_agent_types_must_be_unique_single_worker() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_agent_types_must_be_unique_multiple_workers() -> None:
host_address = "localhost:50052"
@ -79,6 +81,7 @@ async def test_agent_types_must_be_unique_multiple_workers() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_register_receives_publish() -> None:
host_address = "localhost:50053"
@ -124,6 +127,7 @@ async def test_register_receives_publish() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_register_receives_publish_cascade_single_worker() -> None:
host_address = "localhost:50054"
@ -159,6 +163,7 @@ async def test_register_receives_publish_cascade_single_worker() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.skip(reason="Fix flakiness")
@pytest.mark.asyncio
async def test_register_receives_publish_cascade_multiple_workers() -> None:
@ -204,6 +209,7 @@ async def test_register_receives_publish_cascade_multiple_workers() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_default_subscription() -> None:
host_address = "localhost:50056"
@ -238,6 +244,7 @@ async def test_default_subscription() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_default_subscription_other_source() -> None:
host_address = "localhost:50057"
@ -272,6 +279,7 @@ async def test_default_subscription_other_source() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_type_subscription() -> None:
host_address = "localhost:50058"
@ -309,6 +317,7 @@ async def test_type_subscription() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_duplicate_subscription() -> None:
host_address = "localhost:50059"
@ -340,6 +349,7 @@ async def test_duplicate_subscription() -> None:
await host.stop()
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_disconnected_agent() -> None:
host_address = "localhost:50060"
@ -418,6 +428,7 @@ class ProtoReceivingAgent(RoutedAgent):
self.received_messages.append(message)
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_proto_payloads() -> None:
host_address = "localhost:50057"
@ -461,6 +472,7 @@ async def test_proto_payloads() -> None:
# TODO add tests for failure to deserialize
@pytest.mark.grpc
@pytest.mark.asyncio
async def test_grpc_max_message_size() -> None:
default_max_size = 2**22