Skip to content

Test that the V7 AwaitingOn message is flushed before blocking - #662

Closed
StephanEwen wants to merge 1 commit into
mainfrom
test/awaiting-on-protocol-tests
Closed

StephanEwen wants to merge 1 commit into
mainfrom
test/awaiting-on-protocol-tests

Conversation

@StephanEwen

Copy link
Copy Markdown
Contributor

Restate Server will use the protocol V7 AwaitingOnMessage to suspend idle invocations early when concurrency slots run out. So the SDK must flush that message before it parks waiting for input. In Java only the native (FFM) state machine implements V7 and sends it.

What this adds

All files are test-only, under sdk-core/src/test/. No main code or build changes.

  • ProtocolConversation: a test driver that behaves like the runtime. It withholds input until an expected message has been decoded from the output, so a message that is buffered instead of flushed makes the test time out.
    • expectNoOutputUntilIdle() asserts that nothing more is written once the core thread is idle.
  • protocol_v7_test.proto: the V7 messages the vendored V6 protocol.proto lacks: Future, AwaitingOnMessage, ProposeRunCompletionAckMessage, and the V7 SuspensionMessage. They are in a separate proto package. Field numbers were checked against the upstream protocol.
  • AwaitingOnTest (Java) and kotlinapi/AwaitingOnTest (Kotlin) check that:
    • a single await is flushed before blocking and sent once;
    • DurableFuture.all/any and Kotlin awaitAll/select report the right tree, which shrinks after partial progress;
    • nothing is sent while a ctx.run closure executes, then one message is sent while waiting for the run-completion ack;
    • closing the input suspends with the same tree;
    • nothing is sent on V6, on both the native and the legacy state machine.

Verification

  • The V7 tests fail when the flush before parking is removed from HandlerContextImpl: all 7 fail with "No output within 10s".
  • The V7 tests are skipped, not failed, when the native state machine is unavailable (JDK < 23, no native library, or disableNewCore). CI (tests.yml, JDK 25 with Rust) builds the native library, so they run there.
  • *AwaitingOnTest passed 9/9 in 10 reruns, in about 0.8 s.
  • ./gradlew :sdk-core:build passes: 1368 tests, 0 failures, plus spotless, license check and javadoc.

Sibling PRs adding the same kind of tests: restatedev/sdk-python#318, restatedev/sdk-go#182, restatedev/sdk-rust#144.

🤖 Generated with Claude Code

Restate Server will use AwaitingOnMessage to suspend idle invocations
early, so the SDK must flush it before it parks waiting for input. Only
the native (FFM) state machine implements protocol V7 and sends it.

ProtocolConversation drives one invocation step by step, like the
runtime: it withholds input until an expected message is decoded, so a
message that is buffered instead of flushed makes the test time out.
The V7 messages that the vendored V6 protocol.proto lacks are defined
in a test-only proto, in a separate package.

The tests cover:
- a single await: flushed before blocking, and sent once
- DurableFuture.all/any and Kotlin awaitAll/select: the reported tree,
  and the tree shrinking after partial progress
- none while a ctx.run executes, then one while waiting for the
  ProposeRunCompletionAck
- closing the input after AwaitingOn suspends with the same tree
- none with protocol V6, on both the legacy and the native state machine

The V7 tests are skipped when the native state machine is unavailable
(JDK < 23, or no native library for the platform).

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This review covers the test-only addition of protocol V7 AwaitingOnMessage flush tests in sdk-core.

  • ProtocolConversation test driver. It steps one invocation on a single core executor and holds back input until an expected frame is decoded, so a buffered but unflushed message makes the test time out after 10s. 0x0006 frames decode as AwaitingOnMessage whatever the content type, so a stray frame on V6 still fails the next expect(...).
  • protocol_v7_test.proto. I compared CombinatorType, Future, the V7 SuspensionMessage (reserved 1–3, awaiting_on = 4), AwaitingOnMessage and ProposeRunCompletionAckMessage with upstream sdk-shared-core's service-protocol/dev/restate/service/protocol.proto. All field numbers and type ids (0x0006, 0x0007) match. The separate proto package and java_package keep these messages apart from the classes generated from the main protocol.
  • Java AwaitingOnTest. It covers a single await, the DurableFuture.all tree shrinking after one completion, DurableFuture.any, ctx.run, input close leading to a V7 suspension with the same tree, and a V6 negative case on both state machines. In the ctx.run test, the runStarted latch is a reliable barrier: HandlerContextImpl starts the closure from the await loop, so the handler is already blocked when the idle check runs.
  • Kotlin AwaitingOnTest. The awaitAll and select tests check that the Kotlin API reports the same trees.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  8 files  ±0    8 suites  ±0   4m 42s ⏱️ +31s
 60 tests ±0   60 ✅ ±0  0 💤 ±0  0 ❌ ±0 
267 runs  ±0  267 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 0af4419. ± Comparison against base commit 6b0a96c.

♻️ This comment has been updated with latest results.

@slinkydeveloper

Copy link
Copy Markdown
Contributor

im gonna close this as this test is not really mantainable long term, considering you tested and it works is good enough for me.

We're gonna need a proper e2e test on this behavior shipped via sdk-test-suite, instead of unit tests on each sdk.

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants