def test_replace_some_docs():
    if 'CIRCLECI' in os.environ:
        raise SkipTest
    es = elasticsearch.Elasticsearch(ES_HOST)
    test_fresh_index()

    # change 2 documents of our 4, and check they are updated.
    docs = [
        {
            'user': '******',
            'message': 'hello5',
        },
        {
            'user': '******',
            'message': 'hello2'
        },
        {
            'user': '******',
            'message': 'hello6',
        },
        {
            'user': '******',
            'message': 'hello4'
        },
    ]

    doc_type = 'user_message'
    batch = zip(range(4), docs)
    index_util.index_with_checksum(es, 'index_util_test1', doc_type, batch)

    for i in range(4):
        fetched = es.get('index_util_test1', i, 'user_message')
        doc = dict(fetched['_source'])
        assert docs[i] == doc, (p(docs[i]), p(fetched))
Exemple #2
0
def test_fresh_index():
  if 'CIRCLECI' in os.environ:
    raise SkipTest
  es = elasticsearch.Elasticsearch(ES_HOST)
  try:
    es.indices.delete('index_util_test1')
  except:
    pass
  es.indices.create('index_util_test1')
  time.sleep(0.1)

  docs = [
    { 'user': '******', 'message': 'hello1', },
    { 'user': '******', 'message': 'hello2' },
    { 'user': '******', 'message': 'hello3' },
    { 'user': '******', 'message': 'hello4' },
  ]

  doc_type = 'user_message'
  batch = zip(range(4), docs)
  index_util.index_with_checksum(es, 'index_util_test1', doc_type, batch)

  for i in range(4):
    fetched = es.get('index_util_test1', i, 'user_message')
    doc = dict(fetched['_source'])
    assert docs[i] == doc, (p(docs[i]), p(fetched))
Exemple #3
0
def test_replace_some_docs():
  if 'CIRCLECI' in os.environ:
    raise SkipTest
  es = elasticsearch.Elasticsearch(ES_HOST)
  test_fresh_index()

  # change 2 documents of our 4, and check they are updated.
  docs = [
    { 'user': '******', 'message': 'hello5', },
    { 'user': '******', 'message': 'hello2' },
    { 'user': '******', 'message': 'hello6', },
    { 'user': '******', 'message': 'hello4' },
  ]

  doc_type = 'user_message'
  batch = zip(range(4), docs)
  index_util.index_with_checksum(es, 'index_util_test1', doc_type, batch)

  for i in range(4):
    fetched = es.get('index_util_test1', i, 'user_message')
    doc = dict(fetched['_source'])
    assert docs[i] == doc, (p(docs[i]), p(fetched))
def test_fresh_index():
    if 'CIRCLECI' in os.environ:
        raise SkipTest
    es = elasticsearch.Elasticsearch(ES_HOST)
    try:
        es.indices.delete('index_util_test1')
    except:
        pass
    es.indices.create('index_util_test1')
    time.sleep(0.1)

    docs = [
        {
            'user': '******',
            'message': 'hello1',
        },
        {
            'user': '******',
            'message': 'hello2'
        },
        {
            'user': '******',
            'message': 'hello3'
        },
        {
            'user': '******',
            'message': 'hello4'
        },
    ]

    doc_type = 'user_message'
    batch = zip(range(4), docs)
    index_util.index_with_checksum(es, 'index_util_test1', doc_type, batch)

    for i in range(4):
        fetched = es.get('index_util_test1', i, 'user_message')
        doc = dict(fetched['_source'])
        assert docs[i] == doc, (p(docs[i]), p(fetched))