Coverage for tests/integration/test_rollover_frozen.py: 95%

37 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-27 07:35 -0600

1"""Test functions in es_testbed.TestBed""" 

2 

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 

7 

8 

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 'repository': repo, 

18 'uniq': uniq, 

19 'ilm': {}, 

20 'defaults': { 

21 'entity_count': 3, 

22 'docs': 10, 

23 'match': True, 

24 'searchable': 'frozen', 

25 }, 

26 } 

27 

28 

29class TestRolloverManualFrozenIndices: 

30 @pytest.fixture(scope="class") 

31 def tb(self, client, settings): 

32 theplan = PlanBuilder(settings=settings).plan 

33 teebee = TestBed(client, plan=theplan) 

34 teebee.setup() 

35 yield teebee 

36 teebee.teardown() 

37 

38 def test_entity_count(self, tb): 

39 assert len(tb.tracker.entities.entity_list) == 3 

40 

41 def test_first_index(self, tb, frozen, namecore): 

42 value = f'{frozen}{namecore("index")}-000001' 

43 assert tb.tracker.entities.entity_list[0].name == value 

44 

45 def test_last_index(self, tb, namecore): 

46 value = f'{namecore("index")}-000003' 

47 assert tb.tracker.entities.last.name == value 

48 

49 def test_write_index(self, tb, namecore): 

50 alias = f'{namecore("index")}' 

51 assert tb.tracker.entities.last.name == get_write_index(tb.client, alias) 

52 

53 def test_index_template(self, tb, namecore): 

54 components = [] 

55 components.append(f'{namecore("component")}-000001') 

56 components.append(f'{namecore("component")}-000002') 

57 assert tb.tracker.components.entity_list == components 

58 template = f'{namecore("template")}-000001' 

59 assert tb.tracker.templates.last == template 

60 result = tb.client.indices.get_index_template(name=template)['index_templates'] 

61 assert len(result) == 1 

62 assert result[0]['index_template']['composed_of'] == components