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

NMS-10597: Limit SNMP Datacollection by Table Index #2412

Open
wants to merge 5 commits into
base: develop
from

Conversation

Projects
None yet
2 participants
@pioto
Copy link
Contributor

commented Mar 26, 2019

This add a new "instance" variable to the expression context
for PersistRegexSelectorStrategy, which makes it possible
to only collect specific rows from a table based upon their
index.

I'll look at adapting any existing tests to verify this works as expected.

pioto added some commits Mar 4, 2019

NMS-10597: Limit SNMP Datacollection by Table Index
This add a new "instance" variable to the expression context
for PersistRegexSelectorStrategy, which makes it possible
to only collect specific rows from a table based upon their
index.
@pioto

This comment has been minimized.

Copy link
Contributor Author

commented Mar 27, 2019

@agalue, looks like you wrote these tests, would you mind reviewing them and seeing what I've gotten wrong here? Tests are failing like this for me currently:

-------------------------------------------------------------------------------
Test set: org.opennms.netmgt.collectd.PersistRegexSelectorStrategyTest
-------------------------------------------------------------------------------
Tests run: 3, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.586 sec <<< FAILURE! - in org.opennms.netmgt.collectd.PersistRegexSelectorStrategyTest
testPersistSelector(org.opennms.netmgt.collectd.PersistRegexSelectorStrategyTest)  Time elapsed: 0.023 sec  <<< FAILURE!
java.lang.AssertionError: resourceC matches instance expression
        at org.junit.Assert.fail(Assert.java:88)
        at org.junit.Assert.assertTrue(Assert.java:41)
        at org.opennms.netmgt.collectd.PersistRegexSelectorStrategyTest.testPersistSelector(PersistRegexSelectorStrategyTest.java:171)

testPersistSelector(org.opennms.netmgt.collectd.PersistRegexSelectorStrategyTest)  Time elapsed: 0 sec  <<< FAILURE!
java.lang.AssertionError: resourceC matches instance expression
        at org.junit.Assert.fail(Assert.java:88)
        at org.junit.Assert.assertTrue(Assert.java:41)
        at org.opennms.netmgt.collectd.PersistRegexSelectorStrategyTest.testPersistSelector(PersistRegexSelectorStrategyTest.java:171)
@agalue

This comment has been minimized.

Copy link
Member

commented Mar 27, 2019

I suggest you to try a simple SPEL example, like I did on testSpringEl (just to test the expression), as I believe the expression should be #instance matches '.*\.3$' (remember that . has a special meaning on regular expressions; and because of this is you want to match that same character, you have to escape it (i.e. \.), the .* at the beginning it to let the parser know that it may have any content before the section you want to match.

@pioto

This comment has been minimized.

Copy link
Contributor Author

commented Mar 27, 2019

Gotcha, forgot the .matches in Java is just looking for "matches the whole string", so the .* is probably enough.

I wasn't sure how many levels of escaping I'd need for the \, though... at least "\" for the string to parse right with Java, and maybe "\\" if SPEL wanted it, too... I"ll test that tomorrow and hopefully get it actually passing.

Lots of other tests in the opennms-services module are failing for me, though, so I may have something funky in my environment... (or maybe some of them don't want to be run on a host that is actively running OpenNMS?)

@pioto

This comment has been minimized.

Copy link
Contributor Author

commented Mar 28, 2019

OK, thanks, my tests pass now!

-------------------------------------------------------------------------------
Test set: org.opennms.netmgt.collectd.PersistRegexSelectorStrategyTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.598 sec - in org.opennms.netmgt.collectd.PersistRegexSelectorStrategyTest

Let me know if you see any other issues with this, or if you think it's good to merge now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.