Exemple #1
0
 def _set_up_sms_es(self):
     sms_doc = {
         '_id': 'some_sms_id',
         'domain': self.domain.name,
         'direction': INCOMING,
         'date': json_format_datetime(datetime.datetime.utcnow()),
         'doc_type': SMS_INDEX_INFO.type,
     }
     send_to_elasticsearch("sms", sms_doc)
     refresh_elasticsearch_index('sms')
Exemple #2
0
 def create_sms_in_es(domain_name, direction):
     sms_doc = {
         '_id': 'some_sms_id',
         'domain': domain_name,
         'direction': direction,
         'date': json_format_datetime(datetime.datetime.utcnow()),
         'doc_type': SMS_INDEX_INFO.type,
     }
     send_to_elasticsearch("sms", sms_doc)
     refresh_elasticsearch_index('sms')
     return sms_doc
def check_elasticsearch():
    cluster_health = check_es_cluster_health()
    if cluster_health != 'green':
        return ServiceStatus(False, "Cluster health at %s" % cluster_health)

    doc = {'_id': 'elasticsearch-service-check',
           'date': datetime.datetime.now().isoformat()}
    send_to_elasticsearch('groups', doc)
    refresh_elasticsearch_index('groups')
    hits = GroupES().remove_default_filters().doc_id(doc['_id']).run().hits
    send_to_elasticsearch('groups', doc, delete=True)  # clean up
    if doc in hits:
        return ServiceStatus(True, "Successfully sent a doc to ES and read it back")
    return ServiceStatus(False, "Something went wrong sending a doc to ES")
def check_elasticsearch():
    cluster_health = check_es_cluster_health()
    if cluster_health != 'green':
        return ServiceStatus(False, "Cluster health at %s" % cluster_health)

    doc = {'_id': 'elasticsearch-service-check-{}'.format(random_hex()[:7]),
           'date': datetime.datetime.now().isoformat()}
    try:
        send_to_elasticsearch('groups', doc)
        refresh_elasticsearch_index('groups')
        hits = GroupES().remove_default_filters().doc_id(doc['_id']).run().hits
        if doc in hits:
            return ServiceStatus(True, "Successfully sent a doc to ES and read it back")
        else:
            return ServiceStatus(False, "Something went wrong sending a doc to ES")
    finally:
        send_to_elasticsearch('groups', doc, delete=True)  # clean up
Exemple #5
0
 def _set_up_sms_es(self):
     sms_doc = {
         '_id': 'some_sms_id',
         'domain': self.domain.name,
         'direction': INCOMING,
         'date': json_format_datetime(datetime.datetime.utcnow()),
         'doc_type': SMS_INDEX_INFO.type,
     }
     send_to_elasticsearch(
         alias=SMS_INDEX_INFO.alias,
         doc_type=SMS_INDEX_INFO.type,
         doc_id=sms_doc['_id'],
         es_getter=get_es_new,
         name='ElasticProcessor',
         data=sms_doc,
         update=False,
     )
     refresh_elasticsearch_index('sms')
Exemple #6
0
 def delete_sms_in_es(sms_doc):
     send_to_elasticsearch("sms", sms_doc, delete=True)
     refresh_elasticsearch_index('sms')
 def test_deleting_location_updates_user(self):
     self.user.reset_locations(self.loc_ids)
     refresh_elasticsearch_index('users')
     self.loc1.sql_location.full_delete()
     self.loc2.sql_location.full_delete()
     self.assertAssignedLocations([])