Coverage for tests/integration/test_frozen_ds.py: 95%
37 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-25 19:21 -0600
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-25 19:21 -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_ds_current
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': 'data_stream',
13 'prefix': prefix,
14 'uniq': uniq,
15 'repository': repo,
16 'ilm': {
17 'enabled': True,
18 'tiers': ['hot', 'frozen', 'delete'],
19 'forcemerge': False,
20 'max_num_segments': 1,
21 }
22 }
24class TestFrozenDataStream:
25 @pytest.fixture(scope="class")
26 def tb(self, client, settings):
27 theplan = PlanBuilder(settings=settings).plan
28 teebee = TestBed(client, plan=theplan)
29 teebee.setup()
30 yield teebee
31 teebee.teardown()
33 def test_entity_count(self, tb):
34 assert len(tb.tracker.entities.entity_list) == 1
36 def test_name(self, tb, namecore):
37 value = f'{namecore('data_stream')}'
38 assert tb.tracker.entities.last == value
40 def test_first_backing(self, frozen, namecore, ymd, tb):
41 idx = f'{frozen}.ds-{namecore('data_stream')}-{ymd}-000001'
42 assert tb.tracker.entities.ds.backing_indices[0] == idx
44 def test_write_index(self, tb, namecore):
45 ds = f'{namecore('data_stream')}'
46 assert tb.tracker.entities.indexlist[-1] == get_ds_current(tb.client, ds)
48 def test_index_template(self, tb, namecore):
49 components = []
50 components.append(f'{namecore('component')}-000001')
51 components.append(f'{namecore('component')}-000002')
52 assert tb.tracker.components.entity_list == components
53 template = f'{namecore('template')}-000001'
54 assert tb.tracker.templates.last == template
55 result = tb.client.indices.get_index_template(name=template)['index_templates']
56 assert len(result) == 1
57 assert result[0]['index_template']['composed_of'] == components