Fix expected matcher never populating expected_ in GenericAnalyzer#655
Open
matthew-t-watson wants to merge 2 commits into
Open
Fix expected matcher never populating expected_ in GenericAnalyzer#655matthew-t-watson wants to merge 2 commits into
matthew-t-watson wants to merge 2 commits into
Conversation
The `expected` parameter branch in GenericAnalyzer::init only pre-seeds the
base-class items_ map via addItem(); it never populates the expected_ vector.
But expected_ is what the initialisation guard, match() and report() all read,
so an analyzer whose only matcher is `expected`:
* fails to initialise ("was not initialized with any way of checking
diagnostics"), which leaves its AnalyzerGroup with no analyzers
("Group '<x>' doesn't contain any analyzers, can't match"), and
* never matches incoming statuses even when paired with another matcher,
since match() iterates the empty expected_.
This is a regression from the ROS 1 implementation, which populated expected_
via getParamVals(expected, expected_) before creating the pre-seeded items.
Restore the expected_ population alongside the existing addItem() loop.
Signed-off-by: Matthew Watson <matt@opteran.com>
Adds a create-analyzers launch test with an analyzer whose only matcher is `expected`. The success-only "Initialized ... with path '/ExpectedOnly'" log line is asserted, so the test fails (assertWaitFor times out on "not initialized with any way of checking diagnostics") without the fix and passes with it. Verified: fails against the released plugin, passes with the fix applied. Signed-off-by: Matthew Watson <matt@opteran.com>
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
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.
Fixes #656
Summary
GenericAnalyzer'sexpectedmatcher is currently non-functional: the branch that parses theexpectedparameter only pre-seeds the base-classitems_map (viaaddItem()) and never populates theexpected_vector.expected_is what the code actually relies on:startswith_.size() == 0 && name_.size() == 0 && contains_.size() == 0 && expected_.size() == 0 && regex_.size() == 0decides "was not initialized with any way of checking diagnostics";match()— iteratesexpected_(name == expected_[i]);report()— iteratesexpected_to detect missing expected items.Because
expected_is never written, an analyzer whose only matcher isexpected:GenericAnalyzer '<x>' was not initialized with any way of checking diagnostics), which leaves itsAnalyzerGroupempty and producesGroup '<x>' doesn't contain any analyzers, can't match; andmatch()reads the emptyexpected_.This is a regression from the ROS 1 implementation, where the
expectedbranch populated the vector viagetParamVals(expected, expected_)before creating the pre-seeded items (noetic-develgeneric_analyzer.cpp).Fix
Populate
expected_from the parameter's string array alongside the existingaddItem()loop:Reproduction
Minimal analyzer config (
aggregator_node --ros-args --params-file expected.yaml):Before this change the node logs
GenericAnalyzer 'LocTest' was not initialized with any way of checking diagnosticsandGroup 'Test' doesn't contain any analyzers. Swappingexpectedforstartswith/contains/regexworks, confirming the issue is specific toexpected.Verified against the installed Jazzy build (
diagnostic_aggregator4.2.7); the same code is present onros2(rolling).Testing
Adds a create-analyzers launch test (
test/expected_only_analyzer.yaml+test/expected_output/create_expected_only_analyzer.txt, wired intocreate_analyzers_tests) with an analyzer whose only matcher isexpected. It asserts the success-onlyInitialized analyzer ... with path '/ExpectedOnly'log line, so it times out ("was not initialized with any way of checking diagnostics") without the fix and passes with it.Verified locally on Jazzy:
Notes
Draft: opening early for maintainer feedback. If preferred, the fixture could also be extended to an
output_/behavioural test that publishes a matching status and checks aggregation.