-
Notifications
You must be signed in to change notification settings - Fork 505
METRON-2172 Solr Updates Not Tested in Integration Test #1465
Conversation
| } | ||
|
|
||
|
|
||
| private SolrDocument createSolrDocument(String sensorType, Long timestamp) { |
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.
Thank you for this - simple types like this should not be mocked. Good improvement.
| solrDocument.addField(Constants.GUID, UUID.randomUUID().toString()); | ||
| solrDocument.addField(Constants.SENSOR_TYPE, sensorType); | ||
| solrDocument.addField(Constants.Fields.TIMESTAMP.getName(), timestamp); | ||
| solrDocument.addField("ip_src_addr", "192.168.1.1"); |
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.
Constants.Fields.SRC_ADDR
metron/metron-platform/metron-common/src/main/java/org/apache/metron/common/Constants.java
Line 52 in 3754ff3
| SRC_ADDR("ip_src_addr") |
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.
Done. Thanks
| * as maps, so they look the same when validation occurs in the integration tests. | ||
| * @param fields | ||
| */ | ||
| protected static void reformatComments(Map<String, Object> fields) { |
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.
How about normalizeCommentsAsMap for a name?
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.
That is more descriptive. Done.
|
Looks pretty good. A couple small nits and I think this is good to go. |
|
+1 thanks @nickwallen |
The
SolrUpdateIntegrationTestis not testing that theSolrDaocan update and retrieve values. This fix is similar to what was done for Elasticsearch in #1451.This replaces #1454 which was a more involved refactor that fixed some issues with code duplication and provided additional unit tests. I am going to break-off just the bare minimum of what we need to fix the broken tests, rather than fix and refactor in the same PR.
What?
This gap in the integration test is hiding a couple bugs.
A timestamp is not being populated in the documents returned from Solr.
The integration test is not accounting for the fact that comments are serialized differently when written to Solr versus Elasticsearch. When comments are written to Solr, they are serialized as a list of JSON strings. When comments are written to Elasticsearch, they are serialized as a list of maps.
Why?
These problems arise because of the way the test is setup. Instead of directly testing a
SolrDaothis test runs against aMultiIndexDaoinitialized with both aSolrDaoand anHBaseDao. On retrievals theMultIndexDaowill return the document from whichever index responds first.With the current test setup, the underlying
SolrDaowill never retrieve the document that the test case is expecting. In all cases where the test passes, the document is actually being returned from theHBaseDaowhich is actually just interacting with a mock backend. The test needs to actually test that we can update and retrieve documents from Elasticsearch.Changes
The
SolrUpdateIntegrationTestwas changed so that it specifically tests aSolrDao.The
UpdateIntegrationTestwas changed so that it can handle comments stored as either strings or maps. This allows the same integration tests to continue to work when run against either Solr or Elasticsearch.Acceptance Testing
Validate against Elasticsearch.
Validate against Solr.
Pull Request Checklist