-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[mdatagen] Fix metric tests on boolean attributes #11169
[mdatagen] Fix metric tests on boolean attributes #11169
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11169 +/- ##
==========================================
- Coverage 92.29% 92.28% -0.01%
==========================================
Files 413 413
Lines 19772 19761 -11
==========================================
- Hits 18248 18237 -11
Misses 1152 1152
Partials 372 372 ☔ View full report in Codecov by Sentry. |
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.
Thanks for the fix @jade-guiton-dd, could you add a test with the value shown in the link you posted: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/19b01db307d984e62f81f1880b63327ba092cd81/receiver/apachesparkreceiver/internal/metadata/generated_metrics_test.go#L1250
I added an attribute in the samplereceiver metrics which should trigger a test failure if this bug shows up again (as long as the computation of TestValues isn't changed). Is this what you had in mind @codeboten? |
6c8747d
to
bae18a6
Compare
bae18a6
to
4d9f1d6
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.
Yup, thanks @jade-guiton-dd, looks great
Description
Since commit 8f3ca8a,
mdatagen
improperly generates metric tests: boolean attributes are always expected to betrue
in the output, no matter what the injected test value was. For example, this line in collector-contrib is incorrectly changed to expecttrue
instead offalse
after updating mdatagen and running it again.The reason is this line, which attempts to generate
assert.True
orassert.False
based on the expected test value. However,(attributeInfo $attr).TestValue
does not return a boolean but the stringtrue
orfalse
, both of which are considered "truthy" by the templating engine.Testing
I manually rebuilt mdatagen, ran
make generate
in collector-contrib, and ran the tests, to confirm that the test related to the previously mentioned change was no longer failing.