# es-testbed
A way to create indices, datastreams, and snapshots to facilitate testing.
# Preliminary Documentation
## 1. Create a TestPlan
```
from es_testbed import TestPlan
plan = {
'type': 'indices',
'prefix': 'es-testbed',
'uniq': 'mytest',
'ilm': {
'enabled': False,
'tiers': ['hot', 'delete'],
'forcemerge': False,
'max_num_segments': 1,
},
'defaults': {
'entity_count': 3,
'docs': 10,
'match': True,
'searchable': None,
}
}
tp = TestPlan(settings=plan)
```
**Note:** If ``ilm['enabled'] == False``, the other subkeys will be ignored. In fact, ``ilm: False`` is also acceptable.
Save this for step 2.
## 2. Create a TestBed
**Must have an Elasticsearch client established to proceed**
```
from es_testbed import TestBed
tb = TestBed(client, plan=tp)
```
### 2.1 Index Template creation (behind the scenes)
Based on the settings in step 1, you will have 2 component templates and one index template that
references them:
#### Component Template 1
```
es-testbed-cmp-mytest-000001
```
Settings:
```
{'index.number_of_replicas': 0}
```
If using a `rollover_alias` or ILM Policy, then additional values will automatically be added.
#### Component Template 2
```
es-testbed-cmp-mytest-000002
```
Mappings:
```
{
'properties': {
'@timestamp': {'type': 'date'},
'message': {'type': 'keyword'},
'number': {'type': 'long'},
'nested': {'properties': {'key': {'type': 'keyword'}}},
'deep': {'properties': {'l1': {'properties': {'l2': {
'properties': {'l3': {'type': 'keyword'}}}}}}
}
}
}
```
#### Index Template
```
es-testbed-tmpl-mytest-000001
```
### 2.2 You have indices
Based on what was provided in step 1, you will have 3 indices with a basic mapping, and 10 documents each:
```
es-testbed-idx-mytest-000001
es-testbed-idx-mytest-000002
es-testbed-idx-mytest-000003
```
Documents will have been added per the TestPlan settings. The orthography for these documents is in
`es_testbed.helpers.utils.doc_gen()`. Counts are preserved and continue to grow from one index to
the next.
## 3. Perform your tests.
This is where the testing can be performed.
## 4. Teardown
```
tb.teardown()
```
Barring anything unusual happening, all indices, data_streams, ILM policies, index & component
templates, and snapshots (if an index is promoted to searchable snapshots) will be deleted as part
of the `teardown()` method.
Raw data
{
"_id": null,
"home_page": null,
"name": "es-testbed",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "datastream, elasticsearch, index, repository, snapshot, testing",
"author": null,
"author_email": "Elastic <info@elastic.co>",
"download_url": "https://files.pythonhosted.org/packages/92/9c/6f312e7c28ea45b1f012a20ff1e09ad80d703500b528f2264decf906c94e/es_testbed-0.7.2.tar.gz",
"platform": null,
"description": "# es-testbed\nA way to create indices, datastreams, and snapshots to facilitate testing.\n\n# Preliminary Documentation\n\n## 1. Create a TestPlan\n\n```\nfrom es_testbed import TestPlan\n\nplan = {\n 'type': 'indices',\n 'prefix': 'es-testbed',\n 'uniq': 'mytest',\n 'ilm': {\n 'enabled': False,\n 'tiers': ['hot', 'delete'],\n 'forcemerge': False,\n 'max_num_segments': 1,\n },\n 'defaults': {\n 'entity_count': 3,\n 'docs': 10,\n 'match': True,\n 'searchable': None,\n }\n}\n\ntp = TestPlan(settings=plan)\n```\n\n**Note:** If ``ilm['enabled'] == False``, the other subkeys will be ignored. In fact, ``ilm: False`` is also acceptable.\n\nSave this for step 2.\n\n## 2. Create a TestBed\n\n**Must have an Elasticsearch client established to proceed**\n\n```\nfrom es_testbed import TestBed\n\ntb = TestBed(client, plan=tp)\n```\n\n### 2.1 Index Template creation (behind the scenes)\n\nBased on the settings in step 1, you will have 2 component templates and one index template that\nreferences them:\n\n#### Component Template 1\n\n```\nes-testbed-cmp-mytest-000001\n```\n\nSettings:\n\n```\n{'index.number_of_replicas': 0}\n```\n\nIf using a `rollover_alias` or ILM Policy, then additional values will automatically be added.\n\n#### Component Template 2\n\n```\nes-testbed-cmp-mytest-000002\n```\n\nMappings:\n\n```\n{\n 'properties': {\n '@timestamp': {'type': 'date'},\n 'message': {'type': 'keyword'},\n 'number': {'type': 'long'},\n 'nested': {'properties': {'key': {'type': 'keyword'}}},\n 'deep': {'properties': {'l1': {'properties': {'l2': {\n 'properties': {'l3': {'type': 'keyword'}}}}}}\n }\n }\n}\n```\n\n#### Index Template\n```\nes-testbed-tmpl-mytest-000001\n```\n\n### 2.2 You have indices\n\nBased on what was provided in step 1, you will have 3 indices with a basic mapping, and 10 documents each:\n\n```\nes-testbed-idx-mytest-000001\nes-testbed-idx-mytest-000002\nes-testbed-idx-mytest-000003\n```\n\nDocuments will have been added per the TestPlan settings. The orthography for these documents is in\n`es_testbed.helpers.utils.doc_gen()`. Counts are preserved and continue to grow from one index to\nthe next.\n\n## 3. Perform your tests.\n\nThis is where the testing can be performed.\n\n## 4. Teardown\n\n```\ntb.teardown()\n```\n\nBarring anything unusual happening, all indices, data_streams, ILM policies, index & component\ntemplates, and snapshots (if an index is promoted to searchable snapshots) will be deleted as part\nof the `teardown()` method.",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Library to help with building and tearing down indices, data streams, repositories and snapshots",
"version": "0.7.2",
"project_urls": {
"Documentation": "https://github.com/untergeek/es-testbed#readme",
"Issues": "https://github.com/untergeek/es-testbed/issues",
"Source": "https://github.com/untergeek/es-testbed"
},
"split_keywords": [
"datastream",
" elasticsearch",
" index",
" repository",
" snapshot",
" testing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ced553660d1c51e75b5ec59f9b8e52883a99c06bc81d6e333a2dfc8dd507a1bd",
"md5": "09a0eeb9dd86fcc5eba1c9869eac6fe0",
"sha256": "109226467ea4eab2e15a83e626d35e7fc40fc4ac6e4f4a82512fdc9de5308538"
},
"downloads": -1,
"filename": "es_testbed-0.7.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "09a0eeb9dd86fcc5eba1c9869eac6fe0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 36428,
"upload_time": "2024-05-04T00:33:26",
"upload_time_iso_8601": "2024-05-04T00:33:26.758623Z",
"url": "https://files.pythonhosted.org/packages/ce/d5/53660d1c51e75b5ec59f9b8e52883a99c06bc81d6e333a2dfc8dd507a1bd/es_testbed-0.7.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "929c6f312e7c28ea45b1f012a20ff1e09ad80d703500b528f2264decf906c94e",
"md5": "9d41d500a21ddd027dc3dc0e59e72a46",
"sha256": "808931cc40eb53c229f06311744dc2e8efb523764b156ab6d5467dc48e8aa04c"
},
"downloads": -1,
"filename": "es_testbed-0.7.2.tar.gz",
"has_sig": false,
"md5_digest": "9d41d500a21ddd027dc3dc0e59e72a46",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 118068,
"upload_time": "2024-05-04T00:33:28",
"upload_time_iso_8601": "2024-05-04T00:33:28.603483Z",
"url": "https://files.pythonhosted.org/packages/92/9c/6f312e7c28ea45b1f012a20ff1e09ad80d703500b528f2264decf906c94e/es_testbed-0.7.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-04 00:33:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "untergeek",
"github_project": "es-testbed#readme",
"travis_ci": false,
"coveralls": true,
"github_actions": false,
"lcname": "es-testbed"
}