-
Notifications
You must be signed in to change notification settings - Fork 791
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
Refactor all tests that use Config so that they don't fail locally #1310
Refactor all tests that use Config so that they don't fail locally #1310
Conversation
a5a6eb8
to
0615604
Compare
0615604
to
22e150c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the new config SPI is nice, but I think will require separate test sets for each different configuration that we want to test with, which feels a little awkward to have to split out test sets for different configuration values.
Also, I kind of like keeping the configuration close to the test that uses it.
And it's nice to have one way to deal with test configuration instead of two.
So I wonder if it's better to use ConfigUtils
everywhere for now, until we figure out our desired end state?
One option in the future (which would get rid of resetInstrumentation
) is to have Config.getBooleanProperty()
return a BooleanConfigValue
(etc) and by default BooleanConfigValue
can just have a final boolean value
in it, but when running tests we could sub out a different impl that always reads from Config.allProperties
, so we can update freely at runtime. Instrumentations would have to cache the BooleanConfigValue
instead of the raw boolean
, but the default impl should perform well since it's just a holder of a constant (non-volatile) value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @trask that it's probably simpler to stick with the same pattern for static config too. But in general, this looks like a great idea to me, closer to the usual setup/cleanup pattern of saving an old value before tests and restoring it after tests
@trask |
Does anybody have an idea how to solve our current problem when every test can its own, conflicting, configuration? |
My only idea is to have two different implementations of Config or Config storage: current one with WDYT @mateuszrzeszutek @anuraaga @trask ? |
Exactly. My idea was to remove the conflicts altogether -- the easy fix for this issue was just changing
I can remove all SPI calls and use
Hmm, but this doesn't actually solve the I can think of two options here:
|
Also, some explanation regarding |
The more I think about it the more I wonder: maybe we indeed use statics too much? |
💯 on a different topic, an option (if it helps) for more complex config data types that need to parse the string:
this would allow one implementation that calls the parser once and returns an immutable |
22e150c
to
19ed534
Compare
I've removed all SPI usage and made all tests use |
19ed534
to
be077f4
Compare
Does this fix the original issue? Or if somebody changes config in one of the api tests, it will fail again? |
It'll fail if somebody changes it. |
...-api/src/test/groovy/io/opentelemetry/instrumentation/api/tracer/HttpClientTracerTest.groovy
Outdated
Show resolved
Hide resolved
instrumentation/jms-1.1/src/jms2Test/groovy/SpringListenerJMS2Test.groovy
Outdated
Show resolved
Hide resolved
instrumentation/jms-1.1/src/jms2Test/groovy/SpringTemplateJMS2Test.groovy
Outdated
Show resolved
Hide resolved
I've created a new issue for the next |
Fixes #1306
Why did it work on the CI: we use retries on the CI, but not when running tests locally. I suspect that Gradle only re-ran the failing tests (since that would be the sane thing to do), so with each retry
NetPeerUtils
would be loaded again, but with different property value. And so on until it passed - we use 5 retries (java.gradle
) so that should be enough.I've decided to refactor all tests that modify
Config
to avoid the same situation in different places:ConfigUtils
, but I've refactored it and added Javadocs. I hoped that I could get rid ofAgentTestRunner.resetInstrumentation()
, but not in this PR unfortunately.