Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
59 changes: 14 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ jobs:
- run: poe lint
- run: poe build-develop
- run: mkdir junit-xml
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
timeout-minutes: 15
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
timeout-minutes: 15
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
timeout-minutes: 15
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
timeout-minutes: 15
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
timeout-minutes: 15
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
timeout-minutes: 15
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
timeout-minutes: 15
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
timeout-minutes: 15
# Time skipping doesn't yet support ARM
Expand Down Expand Up @@ -103,43 +117,6 @@ jobs:
path: junit-xml
retention-days: 14

# Confirm protos are already generated properly with older protobuf
# library and run test with that older version. We must downgrade protobuf
# so we can generate 3.x and 4.x compatible API. We have to use older
# Python to run this check because the grpcio-tools version we use
# is <= 3.10.
- name: Check generated protos and test protobuf 3.x
if: ${{ matrix.protoCheckTarget }}
env:
TEMPORAL_TEST_PROTO3: 1
run: |
uv add --python 3.9 "protobuf<4"
uv sync --all-extras
poe build-develop
poe gen-protos
poe format
[[ -z $(git status --porcelain temporalio) ]] || (git diff temporalio; echo "Protos changed"; exit 1)
poe test -s
timeout-minutes: 10

# Do docs stuff (only on one host)
- name: Build API docs
if: ${{ matrix.docsTarget }}
run: poe gen-docs
- name: Deploy prod API docs
if: ${{ github.ref == 'refs/heads/main' && matrix.docsTarget }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
run: npx vercel deploy build/apidocs -t ${{ secrets.VERCEL_TOKEN }} --prod --yes

# Confirm README ToC is generated properly
- uses: actions/setup-node@v4
- name: Check generated README ToC
if: ${{ matrix.docsTarget }}
run: |
npx doctoc README.md
[[ -z $(git status --porcelain README.md) ]] || (git diff README.md; echo "README changed"; exit 1)
test-latest-deps:
timeout-minutes: 30
runs-on: ubuntu-latest
Expand Down Expand Up @@ -175,11 +152,3 @@ jobs:
name: junit-xml--${{github.run_id}}--${{github.run_attempt}}--latest-deps--time-skipping
path: junit-xml
retention-days: 14

# Runs the sdk features repo tests with this repo's current SDK code
features-tests:
uses: temporalio/features/.github/workflows/python.yaml@main
with:
python-repo-path: ${{github.event.pull_request.head.repo.full_name}}
version: ${{github.event.pull_request.head.ref}}
version-is-repo-ref: true
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ lint-types = [
{ cmd = "uv run mypy --namespace-packages --check-untyped-defs ."},
]
run-bench = "uv run python scripts/run_bench.py"
test = "uv run pytest"
test = "uv run pytest tests/nexus/test_timeout.py"


[tool.pytest.ini_options]
Expand Down
64 changes: 64 additions & 0 deletions tests/nexus/test_timeout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from __future__ import annotations

import asyncio
import uuid
from datetime import timedelta

import nexusrpc.handler
import pytest

import temporalio.exceptions
from temporalio import workflow
from temporalio.testing import WorkflowEnvironment
from tests.helpers import new_worker
from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name


@nexusrpc.service
class Service:
op_that_never_returns: nexusrpc.Operation[None, None]


@nexusrpc.handler.service_handler
class ServiceHandler:
@nexusrpc.handler.sync_operation
async def op_that_never_returns(
self, _ctx: nexusrpc.handler.StartOperationContext, id: None
) -> None:
await asyncio.Event().wait()


@workflow.defn
class NexusCallerWorkflow:
@workflow.run
async def run(self) -> None:
nexus_client = workflow.create_nexus_client(
endpoint=make_nexus_endpoint_name(workflow.info().task_queue),
service=ServiceHandler,
)
await nexus_client.execute_operation(
Service.op_that_never_returns,
None,
schedule_to_close_timeout=timedelta(seconds=1),
)


async def test_nexus_timeout(env: WorkflowEnvironment):
if env.supports_time_skipping:
pytest.skip("Nexus tests don't work with Java test server")

async with new_worker(
env.client,
NexusCallerWorkflow,
nexus_service_handlers=[ServiceHandler()],
) as worker:
await create_nexus_endpoint(worker.task_queue, env.client)

try:
await env.client.execute_workflow(
NexusCallerWorkflow.run,
id=str(uuid.uuid4()),
task_queue=worker.task_queue,
)
except Exception as err:
assert err.cause.cause.__class__ == temporalio.exceptions.TimeoutError # type: ignore
Loading