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