Coverage for tests/integration/test_basic_rollover.py: 100%
36 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-24 22:41 -0600
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-24 22:41 -0600
1"""Test functions in es_testbed.TestBed"""
2# pylint: disable=redefined-outer-name,missing-function-docstring,missing-class-docstring
3import pytest
4from es_testbed import PlanBuilder, TestBed
5from es_testbed.defaults import NAMEMAPPER
6from es_testbed.helpers.es_api import get_write_index
8@pytest.fixture(scope='module')
9def settings(prefix, uniq):
10 return {
11 'type': 'indices',
12 'prefix': prefix,
13 'rollover_alias': True,
14 'uniq': uniq,
15 'ilm': False,
16 }
18class TestBasicRolloverIndices:
19 @pytest.fixture(scope="class")
20 def tb(self, client, settings):
21 theplan = PlanBuilder(settings=settings).plan
22 teebee = TestBed(client, plan=theplan)
23 teebee.setup()
24 yield teebee
25 teebee.teardown()
27 def test_entity_count(self, tb):
28 assert len(tb.tracker.entities.entity_list) == 3
30 def test_first_index(self, tb, prefix, uniq):
31 value = f'{prefix}-{NAMEMAPPER['index']}-{uniq}-000001'
32 assert tb.tracker.entities.entity_list[0].name == value
34 def test_last_index(self, tb, prefix, uniq):
35 value = f'{prefix}-{NAMEMAPPER['index']}-{uniq}-000003'
36 assert tb.tracker.entities.last.name == value
38 def test_write_index(self, tb, prefix, uniq):
39 alias = f'{prefix}-{NAMEMAPPER['index']}-{uniq}'
40 assert tb.tracker.entities.last.name == get_write_index(tb.client, alias)
42 def test_index_template(self, tb, prefix, uniq):
43 components = []
44 components.append(f'{prefix}-{NAMEMAPPER['component']}-{uniq}-000001')
45 components.append(f'{prefix}-{NAMEMAPPER['component']}-{uniq}-000002')
46 assert tb.tracker.components.entity_list == components
47 template = f'{prefix}-{NAMEMAPPER['template']}-{uniq}-000001'
48 assert tb.tracker.templates.last == template
49 result = tb.client.indices.get_index_template(name=template)['index_templates']
50 assert len(result) == 1
51 assert result[0]['index_template']['composed_of'] == components