Coverage for /Users/buh/.pyenv/versions/3.12.2/envs/es-testbed/lib/python3.12/site-packages/es_testbed/classes/tracker.py: 90%
28 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"""Tracker Class Definition"""
3import typing as t
4from dotmap import DotMap
5from elasticsearch8 import Elasticsearch
6from es_testbed.helpers.utils import getlogger
7from .entitymgrs import (
8 ComponentMgr,
9 DataStreamMgr,
10 IlmMgr,
11 IndexMgr,
12 SnapshotMgr,
13 TemplateMgr,
14)
16# pylint: disable=missing-docstring,too-many-instance-attributes
18TYPEMAP = {'indices': IndexMgr, 'data_stream': DataStreamMgr}
21class Tracker:
22 """Object for tracking entities created in TestBed"""
24 def __init__(
25 self,
26 client: Elasticsearch = None,
27 plan: DotMap = None,
28 autobuild: t.Optional[bool] = False,
29 ):
30 """Initialize"""
31 self.logger = getlogger('es_testbed.Tracker')
32 self.client = client
33 self.plan = plan
34 self.ilm_policies = None
35 self.components = None
36 self.templates = None
37 self.entities = None
38 self.snapshots = None
39 if autobuild: 39 ↛ 40line 39 didn't jump to line 40, because the condition on line 39 was never true
40 self.setup()
42 def setup(self):
43 kw = {'client': self.client, 'plan': self.plan}
44 self.ilm_policies = IlmMgr(**kw)
45 self.components = ComponentMgr(**kw)
46 self.templates = TemplateMgr(**kw)
47 self.snapshots = SnapshotMgr(**kw)
48 etype = TYPEMAP[self.plan.type]
49 self.entities = etype(**kw, snapmgr=self.snapshots)
51 def teardown(self):
52 pass
53 # These are ordered this way on purpose
54 # self.entities.teardown()
55 # self.snapshots.teardown()
56 # self.templates.teardown()
57 # self.components.teardown()
58 # self.ilm_policies.teardown()