[Enrich] Add copy_raw_fields() method and refactor enrichers#864
[Enrich] Add copy_raw_fields() method and refactor enrichers#864valeriocos merged 2 commits intochaoss:masterfrom
copy_raw_fields() method and refactor enrichers#864Conversation
copy_raw_fields() method and refactored enrichers
copy_raw_fields() method and refactored enricherscopy_raw_fields() method and refactor enrichers
valeriocos
left a comment
There was a problem hiding this comment.
Thank you @imnitishng for the PR.
Can you add a test to https://github.com/chaoss/grimoirelab-elk/blob/master/tests/test_enrich.py to check that the method copy_raw_fields works fine
Probably some code could be added also here: https://github.com/chaoss/grimoirelab-elk/blob/master/tests/base.py#L197 to check that the default fields are copied to each enriched document.
The code could be as the one below:
url = self.es_con + "/" + self.enrich_index + "/_search"
response = enrich_backend.requests.get(url, verify=False).json()
for hit in response['hits']['hits']:
source = hit['_source']
...check that the default fields have been copied
WDYT?
|
Sure, will update the PR. |
|
Thanks @imnitishng |
|
Hi @valeriocos, I have added the tests here https://github.com/chaoss/grimoirelab-elk/blob/master/tests/test_enrich.py . WDYT? |
|
Good idea @imnitishng ! Ok for the new test (the name could be I would add this new test in this PR (as a separated commit) to make sure that ELK is working properly after this modification. WDYT? |
This commit adds a new method to get rid of redundant code snippet in enrichers to copy raw fields from raw item to rich item. Signed-off-by: Nitish Gupta <imnitish.ng@gmail.com>
79f6ffb to
ed27740
Compare
|
I have updated the tests @valeriocos, please have a look whenever you're free. |
valeriocos
left a comment
There was a problem hiding this comment.
Thank you @imnitishng for the PR. I left a minor comment
tests/test_crates.py
Outdated
| if attribute in item: | ||
| self.assertEqual(item[attribute], eitem[attribute]) | ||
| else: | ||
| self.assertEqual(eitem[attribute], None) |
This commit adds tests for the `copy_raw_fields()` method for all ELK backends to check if all the raw attributes are copied properly. Signed-off-by: Nitish Gupta <imnitish.ng@gmail.com>
This PR removes the following redundant code snippet from enrichers
and replaces with new method
copy_raw_fields()Based on the discussion here #851 (comment)
Signed-off-by: Nitish Gupta imnitish.ng@gmail.com