summaryrefslogtreecommitdiffstats
path: root/utils/test/dashboard
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-09-28 06:26:12 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-09-28 06:26:12 +0000
commit4ba53f4e81549104f0ba785a6d072f56305d42f8 (patch)
tree9efd48a180187de40c27a77e20037a15e8995f26 /utils/test/dashboard
parente9c79c7e8b4d67ee0c8ab3ccc31ce76544fb6266 (diff)
parentb20ca1c82855a689f926397af4e422b85d8f6f7d (diff)
Merge "only get specific docs when checking the existed ones in elasticsearch"
Diffstat (limited to 'utils/test/dashboard')
-rw-r--r--utils/test/dashboard/dashboard/common/elastic_access.py22
-rw-r--r--utils/test/dashboard/dashboard/mongo2elastic/main.py31
2 files changed, 30 insertions, 23 deletions
diff --git a/utils/test/dashboard/dashboard/common/elastic_access.py b/utils/test/dashboard/dashboard/common/elastic_access.py
index b454e9a12..6d82e8e43 100644
--- a/utils/test/dashboard/dashboard/common/elastic_access.py
+++ b/utils/test/dashboard/dashboard/common/elastic_access.py
@@ -48,25 +48,3 @@ def get_docs(url, creds=None, body=None, field='_source'):
for hit in res_data['hits']['hits']:
docs.append(hit[field])
return docs
-
-
-def get_elastic_docs_by_days(elastic_url, creds, days):
- if days == 0:
- body = '''{
- "query": {
- "match_all": {}
- }
- }'''
- elif days > 0:
- body = '''{{
- "query" : {{
- "range" : {{
- "start_date" : {{
- "gte" : "now-{}d"
- }}
- }}
- }}
- }}'''.format(days)
- else:
- raise Exception('Update days must be non-negative')
- return get_docs(elastic_url, creds, body)
diff --git a/utils/test/dashboard/dashboard/mongo2elastic/main.py b/utils/test/dashboard/dashboard/mongo2elastic/main.py
index 82b01e4b3..ad043728f 100644
--- a/utils/test/dashboard/dashboard/mongo2elastic/main.py
+++ b/utils/test/dashboard/dashboard/mongo2elastic/main.py
@@ -200,7 +200,36 @@ class DocumentsPublisher:
exit(-1)
def get_existed_docs(self):
- self.existed_docs = elastic_access.get_elastic_docs_by_days(self.elastic_url, self.creds, self.days)
+ if self.days == 0:
+ body = '''{{
+ "query": {{
+ "bool": {{
+ "must": [
+ {{ "match": {{ "project_name": "{}" }} }},
+ {{ "match": {{ "case_name": "{}" }} }}
+ ]
+ }}
+ }}
+ }}'''.format(self.project, self.case)
+ elif self.days > 0:
+ body = '''{{
+ "query": {{
+ "bool": {{
+ "must": [
+ {{ "match": {{ "project_name": "{}" }} }},
+ {{ "match": {{ "case_name": "{}" }} }}
+ ],
+ "filter": {{
+ "range": {{
+ "start_date": {{ "gte": "now-{}d" }}
+ }}
+ }}
+ }}
+ }}
+ }}'''.format(self.project, self.case, self.days)
+ else:
+ raise Exception('Update days must be non-negative')
+ self.existed_docs = elastic_access.get_docs(self.elastic_url, self.creds, body)
return self
def publish(self):