Hi

So the conclusion is that it isn’t possible at all to test key functions using the new DataStream api as it requires state V2 and test support is missing. 

And it isn’t possible to declare and use state V1 together with the new DataStream api as a temporary solution because you don’t have access to the RuntimeContext. 

Right?

Best regards
Lasse Nedergaard


Den 11. jun. 2025 kl. 12.31 skrev Zakelly Lan <zakelly....@gmail.com>:


Hi Nate,

Glad to see you trying out the new API.

Well, you're right that the `ProcessFunctionTestHarnesses` doesn't support the new state API yet. There are operators tailored for async state access, as well the operator test harness. But unfortunately we can't tell in advance if a `KeyedProcessFunction` is using the new state api or not, so current `forKeyedProcessFunction` still uses the operator without async state support. I've created a ticket[1] and will add a method for the case. 



Best,
Zakelly

On Wed, Jun 11, 2025 at 3:29 AM Nate Drake <ndr...@gmail.com> wrote:
Hi,

I'm attempting to unit test a KeyedProcessFunction that uses v2 Async State API using "ProcessFunctionTestHarnesses.forKeyedProcessFunction()".  When I run my test it fails with:

"Caused by: java.lang.IllegalStateException: Current operator integrates the async processing logic, thus only supports state v2 APIs. Please use StateDescriptor under 'org.apache.flink.runtime.state.v2'."

I ran into a similar issue when attempting to run integration tests for the function even though I confirmed I'm using the .v2. packages and properly calling ".enableAsyncState()".  After finding these two issues in Jira:

https://issues.apache.org/jira/browse/FLINK-37621
https://issues.apache.org/jira/browse/FLINK-37623

I updated my project to use Flink 2.1.0-SNAPSHOT.  That fixed my integration test, but my unit test is still failing.  

I'm not sure if I'm doing something wrong in my test or if maybe ProcessFunctionTestHarnesses doesn't support Async State yet.

Any ideas?

Thanks!

Nate

Reply via email to