metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject metron git commit: METRON-1202 ElasticsearchDao Has extraneous sleep call (justinleet) closes apache/metron#770
Date Fri, 22 Sep 2017 16:57:01 GMT
Repository: metron
Updated Branches:
  refs/heads/master 5f13e14be -> 64490b60f


METRON-1202 ElasticsearchDao Has extraneous sleep call (justinleet) closes apache/metron#770


Project: http://git-wip-us.apache.org/repos/asf/metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/64490b60
Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/64490b60
Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/64490b60

Branch: refs/heads/master
Commit: 64490b60f5e270bf10fb07d86f726ec63806a259
Parents: 5f13e14
Author: justinleet <justinjleet@gmail.com>
Authored: Fri Sep 22 12:55:57 2017 -0400
Committer: leet <leet@apache.org>
Committed: Fri Sep 22 12:55:57 2017 -0400

----------------------------------------------------------------------
 .../elasticsearch/dao/ElasticsearchDao.java     |  3 ---
 .../ElasticsearchMetaAlertIntegrationTest.java  | 20 ++++++++++++++++----
 2 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metron/blob/64490b60/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchDao.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchDao.java
b/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchDao.java
index 0a06c80..62706e3 100644
--- a/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchDao.java
+++ b/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchDao.java
@@ -308,9 +308,6 @@ public class ElasticsearchDao implements IndexDao {
       if (failed > 0) {
         throw new IOException("ElasticsearchDao upsert failed: " + Arrays.toString(shardInfo.getFailures()));
       }
-      Thread.sleep(10000);
-      org.elasticsearch.action.search.SearchResponse resultAfter = client.prepareSearch("test*").setFetchSource(true).setQuery(QueryBuilders.matchAllQuery()).get();
-      resultAfter.getHits();
     } catch (Exception e) {
       throw new IOException(e.getMessage(), e);
     }

http://git-wip-us.apache.org/repos/asf/metron/blob/64490b60/metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/ElasticsearchMetaAlertIntegrationTest.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/ElasticsearchMetaAlertIntegrationTest.java
b/metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/ElasticsearchMetaAlertIntegrationTest.java
index fda62ab..c562e0b 100644
--- a/metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/ElasticsearchMetaAlertIntegrationTest.java
+++ b/metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/ElasticsearchMetaAlertIntegrationTest.java
@@ -198,8 +198,8 @@ public class ElasticsearchMetaAlertIntegrationTest {
 
       {
         //ensure alerts in ES are up-to-date
-        Document doc = metaDao.getLatest(guid, SENSOR_NAME);
-        Assert.assertEquals(message0, doc.getDocument());
+        boolean found = findUpdatedDoc(message0, guid);
+        Assert.assertTrue("Unable to find updated document", found);
         long cnt = 0;
         for (int t = 0; t < MAX_RETRIES && cnt == 0; ++t, Thread.sleep(SLEEP_MS))
{
           docs = es.getAllIndexedDocs(INDEX, SENSOR_NAME + "_doc");
@@ -257,8 +257,8 @@ public class ElasticsearchMetaAlertIntegrationTest {
         }
       }, Optional.empty());
 
-      Document doc = metaDao.getLatest(guid, SENSOR_NAME);
-      Assert.assertEquals(message0, doc.getDocument());
+      boolean found = findUpdatedDoc(message0, guid);
+      Assert.assertTrue("Unable to find updated document", found);
       {
         //ensure ES is up-to-date
         long cnt = 0;
@@ -302,6 +302,18 @@ public class ElasticsearchMetaAlertIntegrationTest {
     }
   }
 
+  protected boolean findUpdatedDoc(Map<String, Object> message0, String guid)
+      throws InterruptedException, IOException {
+    boolean found = false;
+    for (int t = 0; t < MAX_RETRIES && !found; ++t, Thread.sleep(SLEEP_MS)) {
+      Document doc = metaDao.getLatest(guid, SENSOR_NAME);
+      if (message0.equals(doc.getDocument())) {
+        found = true;
+      }
+    }
+    return found;
+  }
+
   protected void elasticsearchAdd(List<Map<String, Object>> inputData, String
index, String docType)
       throws IOException {
     es.add(index, docType, inputData.stream().map(m -> {


Mime
View raw message