es-testbed
A way to create indices, datastreams, and snapshots to facilitate testing.
Preliminary Documentation
1. Create a Preset
Create a preset directory. An example preset directory is in
src/es_testbed/presets/searchable_test.
Your preset directory must include the following files:
- A plan YAML file, e.g.
plan.yml - A buildlist YAML file, e.g.
buildlist.yml - A
functions.pyfile (the actual python code), which must contain a function nameddoc_generator(). This function must accept all kwargs from the buildlist'soptions - A
definitions.pyfile, which is a Python variable file that helps find the path to the module, etc., as well as import the plan, the buildlist, the mappings and settings, etc. This must at least include aget_plan()function that returns a dictionary of a built/configured plan. - A
mappings.jsonfile (contains the index mappings your docs need) - A
settings.jsonfile (contains the index settings) Any other files can be included to help your doc_generator function, e.g. Faker definitions and classes, etc. Once the preset module is imported, relative imports should work.
Note: If ilm['enabled'] == False, the other subkeys will be ignored. In fact, ilm: False is also acceptable.
Acceptable values for readonly are the tier names where readonly is acceptable: hot, warm, or cold.
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, **kwargs)
For a builtin preset, like searchable_test, this is:
tb = TestBed(client, builtin='searchable_test', scenario=None)
scenario can be one of many, if configured.
For using your own preset in a filesystem path:
tb = TestBed(client, path='/path/to/preset/dir')
path must be a directory.
For importing from a Git repository:
tb = TestBed(client, url='user:token@https://github.com/GITUSER/reponame.git', ref='main', path='subpath/to/preset')
Note that user:token@ is only necessary if it's a protected repository.
In this case path must be a subdirectory of the repository. depth=1 is manually set, so only the most recent
bits will be pulled into a tmpdir, which will be destroyed as part of teardown().
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.
Metadata
Release files for es-testbed 0.11.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| es_testbed-0.11.3.tar.gz | 157.9 kB | Without provenance | Details for es_testbed-0.11.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| es_testbed-0.11.3-py3-none-any.whl | Python 3 | none | any | Details for es_testbed-0.11.3-py3-none-any.whl |
Total release size: 208.1 kB
Release files / es_testbed-0.11.3.tar.gz
| Download URL | es_testbed-0.11.3.tar.gz |
|---|---|
| Size | 157.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b92b6800203b43478c5052b223a136f3d1b86b9ea2ac5396ea319eac4647c089
|
|
BLAKE2b-256 checksum How to use checksums |
1ce2011310fdc0f69bfe624a710ec3eae7e7424dae48a8a251070c90cdc42d68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / es_testbed-0.11.3-py3-none-any.whl
| Download URL | es_testbed-0.11.3-py3-none-any.whl |
|---|---|
| Size | 50.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5b1b4107b85732d34b4f1f0c3849b1073f7aadccb6afe4cf671e34e85781e33
|
|
BLAKE2b-256 checksum How to use checksums |
0e7b10d1f0688f7d5e446c45e7c923e3488573b029ae66fe6c14ba8e1fbc2adc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for es-testbed 0.11.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.