[ 
https://issues.apache.org/jira/browse/METRON-1845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16700353#comment-16700353
 ] 

ASF GitHub Bot commented on METRON-1845:
----------------------------------------

Github user nickwallen commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1247#discussion_r236644723
  
    --- Diff: 
metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/components/ElasticSearchComponent.java
 ---
    @@ -194,35 +215,41 @@ public Client getClient() {
         return client;
       }
     
    -  public BulkResponse add(String indexName, String sensorType, String... 
docs) throws IOException {
    +  public void add(UpdateDao updateDao, String indexName, String 
sensorType, String... docs)
    +          throws IOException, ParseException {
         List<String> d = new ArrayList<>();
         Collections.addAll(d, docs);
    -    return add(indexName, sensorType, d);
    +    add(updateDao, indexName, sensorType, d);
       }
     
    -  public BulkResponse add(String indexName, String sensorType, 
Iterable<String> docs)
    -      throws IOException {
    -    BulkRequestBuilder bulkRequest = getClient().prepareBulk();
    -    for (String doc : docs) {
    -      IndexRequestBuilder indexRequestBuilder = getClient()
    -          .prepareIndex(indexName, sensorType + "_doc");
    -
    -      indexRequestBuilder = indexRequestBuilder.setSource(doc);
    -      Map<String, Object> esDoc = JSONUtils.INSTANCE
    -          .load(doc, JSONUtils.MAP_SUPPLIER);
    -      indexRequestBuilder.setId((String) esDoc.get(Constants.GUID));
    -      Object ts = esDoc.get("timestamp");
    -      if (ts != null) {
    -        indexRequestBuilder = 
indexRequestBuilder.setTimestamp(ts.toString());
    -      }
    -      bulkRequest.add(indexRequestBuilder);
    -    }
    +  public void add(UpdateDao updateDao, String indexName, String 
sensorType, Iterable<String> docs)
    --- End diff --
    
    > Might it be better to just use IndexDao, which extends UpdateDao, 
SearchDao, RetrieveLatestDao, ColumnMetadataDao? 
    
    Why would that be better?  It needs to do updates, so it needs an 
`UpdateDao`.  Seemed logical to me.


> Correct Test Data Load in Elasticsearch Integration Tests
> ---------------------------------------------------------
>
>                 Key: METRON-1845
>                 URL: https://issues.apache.org/jira/browse/METRON-1845
>             Project: Metron
>          Issue Type: Sub-task
>            Reporter: Nick Allen
>            Assignee: Nick Allen
>            Priority: Major
>
> The Elasticsearch integration tests use the legacy Transport client to load 
> test data into the search indexes before running the tests. Loading the test 
> data like this does not accurately reflect how the indices will appear in a 
> production environment.
> This should be changed to use our existing ElasticsearchUpdateDao to write 
> the test data.  This ensures that any changes made to the 'write' portion of 
> our Elasticsearch code will function correctly with the 'read' portion. This 
> ensures that telemetry written into Elasticsearch by 'Indexing' can be read 
> correctly by the Alerts UI.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to