Coverage for tests/integration/test_rollover_frozen.py: 95%
37 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.helpers.es_api import get_write_index
7@pytest.fixture(scope='module')
8def settings(prefix, uniq, repo):
9 if not repo: 9 ↛ 10line 9 didn't jump to line 10, because the condition on line 9 was never true
10 pytest.skip('No snapshot repository', allow_module_level=True)
11 return {
12 'type': 'indices',
13 'prefix': prefix,
14 'rollover_alias': True,
15 'repository': repo,
16 'uniq': uniq,
17 'ilm': {},
18 'defaults': {
19 'entity_count': 3,
20 'docs': 10,
21 'match': True,
22 'searchable': 'frozen',
23 }
24 }
26class TestRolloverManualFrozenIndices:
27 @pytest.fixture(scope="class")
28 def tb(self, client, settings):
29 theplan = PlanBuilder(settings=settings).plan
30 teebee = TestBed(client, plan=theplan)
31 teebee.setup()
32 yield teebee
33 teebee.teardown()
35 def test_entity_count(self, tb):
36 assert len(tb.tracker.entities.entity_list) == 3
38 def test_first_index(self, tb, frozen, namecore):
39 value = f'{frozen}{namecore('index')}-000001'
40 assert tb.tracker.entities.entity_list[0].name == value
42 def test_last_index(self, tb, namecore):
43 value = f'{namecore('index')}-000003'
44 assert tb.tracker.entities.last.name == value
46 def test_write_index(self, tb, namecore):
47 alias = f'{namecore('index')}'
48 assert tb.tracker.entities.last.name == get_write_index(tb.client, alias)
50 def test_index_template(self, tb, namecore):
51 components = []
52 components.append(f'{namecore('component')}-000001')
53 components.append(f'{namecore('component')}-000002')
54 assert tb.tracker.components.entity_list == components
55 template = f'{namecore('template')}-000001'
56 assert tb.tracker.templates.last == template
57 result = tb.client.indices.get_index_template(name=template)['index_templates']
58 assert len(result) == 1
59 assert result[0]['index_template']['composed_of'] == components