allure-framework / allure-java

Allure integrations for Java test frameworks
Apache License 2.0
341 stars 218 forks source link

Improve AllureGrpc integartion for support non-blocking (streaming) stubs #1015

Open dtuchs opened 4 months ago

dtuchs commented 4 months ago

Context

In gRPC, client streaming and bidirectional streaming require to use a non-blocking (async) Stubs. These stubs uses different threads for handling sendMessage(T message) and onClose(status, trailers) events. Typically, it's not possible to create and commit a single Allure step within these methods, as AllureThreadContext internally uses ThreadLocal. However, it's possible to achieve this in a separate daemon thread.

Due to the asynchronous implementation of non-blocking stubs, we cannot guarantee that the Allure daemon thread committing the step will terminate immediately upon the completion of the non-blocking stub call. Therefore, for such non-blocking calls, it will be necessary to execute AllureGrpc.await() method after each test.

This approach is explained in the README and javadocs.

There is example report for bidirectional calls:

Screenshot 2024-03-02 at 22 32 33

Checklist

dtuchs commented 4 months ago

Also bug https://github.com/allure-framework/allure-java/pull/973 should be fixed.