Repository navigation
Update Tests - #147
Merged
Merged
Update Tests#147
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix MeterId hash, to_string ordering, and blank tags on the wire; run MeterID-test in CI
Summary
MeterID-testwas never registered with CTest, so CI did not run it. Four of its tests fail onmain:HashSameTagsandLookupTags:std::hash<MeterId>depends on tag iteration order, butoperator==does not, so equal ids can hash differently andunordered_map<MeterId, ...>lookups miss.ToString:to_string()prints tags in unordered-map order, which differs between standard libraries.SpectatordId: the test asserts one specific tag order from an unordered map.This PR fixes the code or the test for each, registers
MeterID-testwithadd_test, and fixes one more bug found along the way: tags that validation drops still reached spectatord.Changes
{a: 1, b: 2}and{a: 2, b: 1}hash differently). The declaration inmeter_id.his unchanged.to_string(): tags are sorted, so the output is deterministic.GetTags()already dropped tags with an empty or whitespace-only key or value, but the spectatord id still rendered them, publishing series likefoo,a=,b=2. The id now skips the same tags. One sharedIsValidTagis used by both, so they cannot drift apart.MeterID-testis registered withadd_test. TheSpectatordIdtest accepts either tag order. New tests cover hash equality across construction paths and insertion order, distinct ids hashing differently, blank tags being omitted from the id, andWithTag/WithTagsremoving a tag set to blank.No public API changes: helpers are in an anonymous namespace, no signatures change, and
WithStatis untouched. This is suitable for a patch release.Behavior change
A caller that passed a blank key or value used to publish a bogus series (for example
k=) alongside the valid tags. That series is no longer published. For valid tags the output is byte-identical tomain; IMeter creation and emit paths are unchanged. Nothing in the library calls
std::hash<MeterId>.