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

mp-rest config settings from application.properties are ignored when using test-profile #19456

Closed
m-brophy opened this issue Aug 17, 2021 · 5 comments
Labels
area/testing kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@m-brophy
Copy link

Describe the bug

I'm trying to load a file and validate some of the contents using data retrieved from a remote rest endpoint (TagService is my class to do this with @RegisterRestClient here). To set this up I've configured connection details in application.properties using mp-rest for TagService. This works fine.

In my unit tests I initially mocked out the operation of TagService succesfully using Mockito but I wanted to run the test methods in ImportServiceTest as a @NativeImageTest via extension so I removed this and set up a Wiremock mock http server for the remote Tag endpoint.

This fails, the GET request doesn't hit the wiremock server. By putting the connection details into the annotations on the TagService class (and commenting out the relevant application.properties lines) the wiremock server GET request is successful ( these lines are commented out in the reproducer and can be uncommented to prove the successful GET request).

It appears that in test mode mp-rest rest client config from application.properties is ignored or not used anyway.

This behaviour is the same whether running tests in jvm mode or as a NativeImageTest.

Expected behavior

the ImportServiceTest should pass and the list of tags retrieved from the wiremock server should be visible in the console output:

tag: Tomcat, tagType: Runtime
tag: Java EE, tagType: Language
tag: RHEL 8, tagType: Operating System
tag: Oracle, tagType: Database

Actual behavior

the ImportServiceTest method fails.

In the console output there's a wiremock error like this:
Screenshot from 2021-08-17 16-08-16

How to Reproduce?

Reproducer: https://github.com/m-brophy/quarkus-test-profile-mp-rest-reproducer

Steps to reproduce behaviour:
1: run ./mvnw clean test from project root to see the failure
2: uncomment the config definitions in TagService @RegisterRestClient and @path annotations and comment out the mp-rest definitions in application.properties
3: run ./mvnw clean test again and it will succeed.

Output of uname -a or ver

Linux localhost.localdomain 5.13.9-100.fc33.x86_64 #1 SMP Mon Aug 9 12:04:50 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment 18.9 (build 11.0.10+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode)

GraalVM version (if different from Java)

Running Quarkus native-image plugin on GraalVM Version 20.3.3.0-Final (Mandrel Distribution) (Java Version 11.0.12+7)

Quarkus version or git rev

Quarkus 1.13.1.Final

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

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

Additional information

No response

@m-brophy m-brophy added the kind/bug Something isn't working label Aug 17, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 17, 2021

/cc @galderz, @zakkak

@m-brophy m-brophy changed the title mp-rest config settings from application.proprties are ignored when using test-profile mp-rest config settings from application.properties are ignored when using test-profile Aug 17, 2021
@galderz
Copy link
Member

galderz commented Aug 19, 2021

This behaviour is the same whether running tests in jvm mode or as a NativeImageTest.

Removing the mandrel tag.

@m-brophy
Copy link
Author

m-brophy commented Aug 19, 2021

We've discovered that removing the /controls/tag part of the url from the mp-rest definition and putting that part in the @path annotation makes this work in test profile also.

It still doesn't seem right that the original url set up in the mp-rest config works in prod profile but not in test profile though.

@geoand
Copy link
Contributor

geoand commented Sep 2, 2021

Is this still an issue with 2.2.x? I wasn't able to verify. Can you please check?

@geoand
Copy link
Contributor

geoand commented Sep 2, 2021

From what I did see looking at the code, I would say this is expected behavior.
In your WiremockTagService you are setting io.tackle.applicationinventory.services.TagService/mp-rest/uri which overrides the same key in application.properties.

So I am going to close this. Feel free to reopen if you feel it has not been properly addressed

@geoand geoand closed this as completed Sep 2, 2021
@geoand geoand added the triage/invalid This doesn't seem right label Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants