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

[mdatagen] Fix metric tests on boolean attributes #11169

Merged

Conversation

jade-guiton-dd
Copy link
Contributor

Description

Since commit 8f3ca8a, mdatagen improperly generates metric tests: boolean attributes are always expected to be true in the output, no matter what the injected test value was. For example, this line in collector-contrib is incorrectly changed to expect true instead of false after updating mdatagen and running it again.

The reason is this line, which attempts to generate assert.True or assert.False based on the expected test value. However, (attributeInfo $attr).TestValue does not return a boolean but the string true or false, 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.

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.28%. Comparing base (5141578) to head (4d9f1d6).
Report is 6 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@mx-psi mx-psi added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Sep 13, 2024
@jade-guiton-dd jade-guiton-dd marked this pull request as ready for review September 13, 2024 17:15
@jade-guiton-dd jade-guiton-dd requested review from a team and atoulme September 13, 2024 17:15
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

@jade-guiton-dd
Copy link
Contributor Author

Thanks for the fix @jade-guiton-dd, could you add a test with the value shown in the link you posted

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?

Copy link
Contributor

@codeboten codeboten left a 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

@codeboten codeboten merged commit 74729e7 into open-telemetry:main Sep 16, 2024
48 of 49 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants