Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subsequent @QuarkusTest's stuck when running with different @TestProfile for testing Lambdas #15195

Closed
nielsvonstein-8336 opened this issue Feb 19, 2021 · 2 comments · Fixed by #15796
Labels
area/amazon-lambda kind/bug Something isn't working
Milestone

Comments

@nielsvonstein-8336
Copy link

Describe the bug
The Gradle project consists of multiple RequestHandler which all need to be tested individually. We use one test profile for each handler test and one test class per handler.
The test profiles spawns test resources (WireMock, localstack) and sets the handler quarkus.lambda.handler accordingly with some other variables.
When running the tests we observe that the first @QuarkusTest class runs as expected but the subsequent class get stuck on the LambdaClient.invoke(...) call and blocks infinitely.

After some investigation it seems like the running AbstractLambdaPollLoop of the first QuarkusTest does not receive/check the interrupt of the Quarkus shutdown due to TestProfile switch.
Additionally the second QuarkusTest somehow does not wait until the old poll loop is destroyed and starts its poll loop and tests. The Lambda test call of the second QuarkusTest is queued into LambdaClient.REQUEST_QUEUE.
However, due to the fact that the first poll loop is still running, it requests another requestId in line AbstractLambdaPollLoop.java:60 which is then dequeued of the REQUEST_QUEUE by LambdaResourceManager.
Since the loop has been stopped, it exits and does not propagate the response to the CompletableFuture inside LambdaClient. The test call however of the second QuarkusTest is still waiting for the response.

Expected behavior
All tests run with their assigned profile without being blocking.

Actual behavior
A subsequent QuarkusTest blocks due to a not returning call inside AbstractLambdaPollLoop.

To Reproduce

We were not able to reproduce it in a small example project. However we hope that contributors of the lambda extension
with more in-depth knowledge of the Quarkus testing lifecycle will understand the above. If not we can only provide an example
of the testing setup based on the aws-lambda archetype project which somehow does not run in the stated problem.

Configuration

quarkus.lambda.enable-polling-jvm-mode=true

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of java -version:
    openjdk 13.0.2 2020-01-14
    OpenJDK Runtime Environment (build 13.0.2+8)
    OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)

  • Quarkus version or git rev:

1.11.3.Final

  • Build tool (ie. output of mvnw --version or gradlew --version):

Gradle 6.5.1

Additional context
(Add any other context about the problem here.)

@nielsvonstein-8336 nielsvonstein-8336 added the kind/bug Something isn't working label Feb 19, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 19, 2021

/cc @matejvasek, @patriot1burke

@gsmet
Copy link
Member

gsmet commented Mar 2, 2021

/cc @matejvasek, @patriot1burke

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Mar 17, 2021
It's possible that on shutdown the polling thread
could still have an active request. If this thread
gets a request from the queue it will break subsequent
test profile runs.

Fixes quarkusio#15195
@quarkus-bot quarkus-bot bot added this to the 1.13 - main milestone Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/amazon-lambda kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants