Coverage for tests/integration/test_cold_indices.py: 95%
37 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, repo):
11 if not repo: 11 ↛ 12line 11 didn't jump to line 12, because the condition on line 11 was never true
12 pytest.skip('No snapshot repository', allow_module_level=True)
13 return {
14 'type': 'indices',
15 'prefix': prefix,
16 'rollover_alias': True,
17 'uniq': uniq,
18 'repository': repo,
19 'ilm': {
20 'enabled': True,
21 'tiers': ['hot', 'cold', 'delete'],
22 'forcemerge': False,
23 'max_num_segments': 1,
24 },
25 }
28class TestFrozenIndices:
29 @pytest.fixture(scope="class")
30 def tb(self, client, settings):
31 theplan = PlanBuilder(settings=settings).plan
32 teebee = TestBed(client, plan=theplan)
33 teebee.setup()
34 yield teebee
35 teebee.teardown()
37 def test_entity_count(self, tb):
38 assert len(tb.tracker.entities.entity_list) == 3
40 def test_first_index(self, tb, cold, namecore):
41 value = f'{cold}{namecore("index")}-000001'
42 assert tb.tracker.entities.entity_list[0].name == value
44 def test_last_index(self, tb, namecore):
45 value = f'{namecore("index")}-000003'
46 assert tb.tracker.entities.last.name == value
48 def test_write_index(self, tb, namecore):
49 alias = f'{namecore("index")}'
50 assert tb.tracker.entities.last.name == get_write_index(tb.client, alias)
52 def test_index_template(self, tb, namecore):
53 components = []
54 components.append(f'{namecore("component")}-000001')
55 components.append(f'{namecore("component")}-000002')
56 assert tb.tracker.components.entity_list == components
57 template = f'{namecore("template")}-000001'
58 assert tb.tracker.templates.last == template
59 result = tb.client.indices.get_index_template(name=template)['index_templates']
60 assert len(result) == 1
61 assert result[0]['index_template']['composed_of'] == components