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

Enable tracing in the SmallRye GraphQL extension #9439

Merged
merged 1 commit into from
May 27, 2020

Conversation

jmartisk
Copy link
Contributor

@jmartisk
Copy link
Contributor Author

jmartisk commented May 19, 2020

It seems that io.quarkus.smallrye.graphql.deployment.ui.DisabledTest starts failing as soon as I add the quarkus-smallrye-opentracing dependency to the test classpath - if I do that, the graphql-ui directory with some static resources seems to be picked up and served as a static resource even if quarkus.smallrye-graphql.enable-ui=false, therefore a call to /graphql-ui/index.html will return 200 (but will return a broken UI because it's not wired correctly). The test expects 404.
Interestingly, it only happens during test, I wasn't able to duplicate this with devmode or prod mode. Anyone has an idea how to prevent this from happening?

@geoand
Copy link
Contributor

geoand commented May 19, 2020

It seems like we need to have a way for QuarkusUnitTest to exclude a dependency when running one of the internal tests.
We don't have that now AFAIK, but it would probably make sense to have it down the line. @aloubyansky WDYT? If you think it's a good idea, I can look into it.

@jmartisk
Copy link
Contributor Author

That could be useful, but it does not explain or fix the root cause why the graphql-ui directory is picked up and served as static resources (in test mode only). I tried debugging into it, but got lost within vert.x code that I don't understand much.

@aloubyansky
Copy link
Member

Are the dependencies and the configuration the same for devmode, prod and tests in this case? If they are the same, we should observe the same responses in all modes, iiuc.

@jmartisk
Copy link
Contributor Author

The dependencies will never be exactly the same because we're talking about a regular application versus a unit test within the codebase of a Quarkus extension. But generally I'd say they are more or less the same. Also tried reproducing the same with @QuarkusTest within an application project, but couldn't. It only happens with a QuarkusUnitTest.

@geoand
Copy link
Contributor

geoand commented May 19, 2020

Hm, can't you do the following:

Instead of adding

quarkus-smallrye-opentracing

as a Maven project dependency, can't you just add it via forcedDependencies to whatever @QuarkusUnitTest you need it in?

@jmartisk
Copy link
Contributor Author

If I remove it from the pom and add it just to GraphQLTracingTest via

.setForcedDependencies(
                    Collections.singletonList(
                            new AppArtifact("io.quarkus", "quarkus-smallrye-opentracing", Version.getVersion())));

then the test passes only if I run that test separately. If I run any other test along with it in the same Maven execution, it behaves as if the opentracing dependency is not there.
I have absolutely no idea why. There must be something fishy with tests not being properly isolated.

@geoand
Copy link
Contributor

geoand commented May 19, 2020

I have absolutely no idea why. There must be something fishy with tests not being properly isolated.

You can probably just add quarkus-smallrye-opentracing as a provided dependency to make it come before graphql in the Maven reactor and that should work.
We do use a similar trick elsewhere IIRC

@jmartisk
Copy link
Contributor Author

You mean in pom.xml? Making it provided won't make it available during tests.

@geoand
Copy link
Contributor

geoand commented May 19, 2020

You mean in pom.xml? Making it provided won't make it available during tests.

Yeah, that's what I'm saying. But I just now saw that you actually need opentracing in your tests, so forget everything I have said in this issue :)

@jmartisk
Copy link
Contributor Author

I removed the line from DisabledTest which asserts a 404 response from the /graphql-ui/index.html path. It still asserts a 404 from /graphql-ui, that passes without problem, so I suppose the tests should pass now.
It's a bit of a shortcut, but I have no idea how else to fix it, and apparently it only affects tests, so I think it shouldn't really matter. I hope no one will be strongly against this shortcut :D

@geoand
Copy link
Contributor

geoand commented May 25, 2020

Fine with me

@gsmet
Copy link
Member

gsmet commented May 27, 2020

@phillip-kruger can you review that one?

@gsmet gsmet added this to the 1.6.0 - master milestone May 27, 2020
Copy link
Member

@phillip-kruger phillip-kruger left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @jmartisk !

@geoand geoand merged commit aa4edf1 into quarkusio:master May 27, 2020
@jmartisk jmartisk deleted the graphql-tracing branch June 1, 2020 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenTracing integration in the SmallRye GraphQL extension
5 participants