datadouble-opensearch 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2026- Tight Line LLC
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ __pycache__/
5
+ *.py[cod]
6
+ .venv/
7
+ .env
8
+ .coverage
9
+ .coverage.*
10
+ coverage.xml
11
+ .reports/
12
+ .pytest_cache/
13
+ .mypy_cache/
14
+ .ruff_cache/
15
+ dist/
16
+ site/
17
+ .cache/
18
+
19
+ # The default work directory of `datadouble run`.
20
+ .datadouble/
21
+ node_modules/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026- Tight Line LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.5
2
+ Name: datadouble-opensearch
3
+ Version: 0.0.3
4
+ Summary: OpenSearch engine adapter for Datadouble
5
+ Project-URL: Homepage, https://datadouble.tightlinesoftware.com/
6
+ Project-URL: Source, https://github.com/datadouble/datadouble
7
+ Author: Tight Line LLC
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Programming Language :: Python :: 3.15
15
+ Classifier: Topic :: Database
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.13
18
+ Requires-Dist: datadouble
19
+ Requires-Dist: datadouble-elasticsearch
20
+ Description-Content-Type: text/markdown
21
+
22
+ # datadouble-opensearch
23
+
24
+ The OpenSearch engine adapter for [Datadouble](https://datadouble.tightlinesoftware.com/).
25
+
26
+ It is the [Elasticsearch adapter](https://github.com/datadouble/datadouble/tree/main/adapters/elasticsearch)
27
+ serving OpenSearch: the same tables, subsets, images and rules, described
28
+ there, with OpenSearch's image, security plugin and point-in-time API. The
29
+ source is OpenSearch 2.4 or later, the first version with points in time.
30
+
31
+ ```yaml
32
+ sources:
33
+ app:
34
+ engine: opensearch
35
+ connection:
36
+ url: # http[s]://[user:password@]host[:port], by reference
37
+ env: SEARCH_URL
38
+ indices: ["*", "-logs-*"] # index patterns; the default is every open index
39
+ ```
40
+
41
+ Working nodes and copies run in the official `opensearchproject/opensearch`
42
+ image of the source's exact version, with the security plugin's
43
+ demonstration configuration over plain HTTP. Datadouble and consumers sign
44
+ in as `admin`, whose password a node or copy gets at its first start and
45
+ keeps in its data directory.
46
+
47
+ ## Plugins
48
+
49
+ Plugins are requirements as for
50
+ [Elasticsearch](https://github.com/datadouble/datadouble/tree/main/adapters/elasticsearch#plugins),
51
+ listed in the image with `opensearch-plugin list`. The official image
52
+ bundles the project's plugins (security, k-NN, alerting and the rest) at the
53
+ source version's own release, so a source running the same bundle needs
54
+ nothing more; any others need an image built `FROM` the official one.
55
+
56
+ The catalog leaves out the indices plugins write for themselves: those
57
+ starting with a dot, and query insights' daily `top_queries-*` indices,
58
+ which its mapping's `_meta` marks.
@@ -0,0 +1,37 @@
1
+ # datadouble-opensearch
2
+
3
+ The OpenSearch engine adapter for [Datadouble](https://datadouble.tightlinesoftware.com/).
4
+
5
+ It is the [Elasticsearch adapter](https://github.com/datadouble/datadouble/tree/main/adapters/elasticsearch)
6
+ serving OpenSearch: the same tables, subsets, images and rules, described
7
+ there, with OpenSearch's image, security plugin and point-in-time API. The
8
+ source is OpenSearch 2.4 or later, the first version with points in time.
9
+
10
+ ```yaml
11
+ sources:
12
+ app:
13
+ engine: opensearch
14
+ connection:
15
+ url: # http[s]://[user:password@]host[:port], by reference
16
+ env: SEARCH_URL
17
+ indices: ["*", "-logs-*"] # index patterns; the default is every open index
18
+ ```
19
+
20
+ Working nodes and copies run in the official `opensearchproject/opensearch`
21
+ image of the source's exact version, with the security plugin's
22
+ demonstration configuration over plain HTTP. Datadouble and consumers sign
23
+ in as `admin`, whose password a node or copy gets at its first start and
24
+ keeps in its data directory.
25
+
26
+ ## Plugins
27
+
28
+ Plugins are requirements as for
29
+ [Elasticsearch](https://github.com/datadouble/datadouble/tree/main/adapters/elasticsearch#plugins),
30
+ listed in the image with `opensearch-plugin list`. The official image
31
+ bundles the project's plugins (security, k-NN, alerting and the rest) at the
32
+ source version's own release, so a source running the same bundle needs
33
+ nothing more; any others need an image built `FROM` the official one.
34
+
35
+ The catalog leaves out the indices plugins write for themselves: those
36
+ starting with a dot, and query insights' daily `top_queries-*` indices,
37
+ which its mapping's `_meta` marks.
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2026- Tight Line LLC
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ [project]
5
+ name = "datadouble-opensearch"
6
+ # All packages share one version until 1.0 (decision 38); scripts/make_tag.py
7
+ # sets it at release time.
8
+ version = "0.0.3"
9
+ description = "OpenSearch engine adapter for Datadouble"
10
+ readme = "README.md"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Tight Line LLC" }]
14
+ requires-python = ">=3.13"
15
+ dependencies = ["datadouble", "datadouble-elasticsearch"]
16
+ classifiers = [
17
+ "Development Status :: 2 - Pre-Alpha",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Programming Language :: Python :: 3.15",
22
+ "Topic :: Database",
23
+ "Typing :: Typed",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://datadouble.tightlinesoftware.com/"
28
+ Source = "https://github.com/datadouble/datadouble"
29
+
30
+ [project.entry-points."datadouble.engines"]
31
+ opensearch = "datadouble_opensearch:engine"
32
+
33
+ [build-system]
34
+ requires = ["hatchling>=1.33.0"]
35
+ build-backend = "hatchling.build"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["src/datadouble_opensearch"]
@@ -0,0 +1,63 @@
1
+ # Copyright (c) 2026- Tight Line LLC
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """The OpenSearch engine adapter for Datadouble.
5
+
6
+ Spec settings::
7
+
8
+ sources:
9
+ app:
10
+ engine: opensearch
11
+ connection:
12
+ url: {env: SEARCH_URL} # http[s]://[user:password@]host[:port], by reference
13
+ indices: ["*", "-logs-*"] # index patterns; the default is every open index
14
+ sample: 1000 # documents sampled for fields mappings do not declare
15
+ server:
16
+ heap: 512m # the Java heap of working nodes
17
+
18
+ The source is OpenSearch 2.4 or later, the first with points in time. The
19
+ adapter is the Elasticsearch adapter's package serving OpenSearch
20
+ (decision 96): the same catalog, extract, images and rules, with
21
+ OpenSearch's image, security plugin and point-in-time API. Working nodes and
22
+ copies run the security plugin's demonstration configuration over plain
23
+ HTTP, with the ``admin`` user's password set at their first start.
24
+ """
25
+
26
+ from datadouble.names import EngineName
27
+ from datadouble_elasticsearch import ElasticEngine
28
+ from datadouble_elasticsearch.product import COMMON_SETTINGS, PointInTimeApi, Product
29
+
30
+ _HOME = "/usr/share/opensearch"
31
+
32
+ OPENSEARCH = Product(
33
+ engine=EngineName("opensearch"),
34
+ name="OpenSearch",
35
+ distribution="opensearch",
36
+ owner="1000:1000",
37
+ repository="opensearchproject/opensearch",
38
+ user="admin",
39
+ launch=f"{_HOME}/opensearch-docker-entrypoint.sh opensearch",
40
+ # The image's entrypoint would refuse a password without capitals and
41
+ # symbols; the demonstration installer takes any with -t. Once a node has
42
+ # started, its users live in its data directory and this changes nothing.
43
+ setup=(
44
+ "export DISABLE_INSTALL_DEMO_CONFIG=true"
45
+ f' && OPENSEARCH_INITIAL_ADMIN_PASSWORD="$DATADOUBLE_PASSWORD"'
46
+ f" bash {_HOME}/plugins/opensearch-security/tools/install_demo_configuration.sh"
47
+ " -y -i -s -t > /dev/null"
48
+ ),
49
+ heap="OPENSEARCH_JAVA_OPTS",
50
+ settings=(
51
+ *COMMON_SETTINGS,
52
+ "plugins.security.ssl.http.enabled=false",
53
+ "plugins.security.audit.type=noop",
54
+ ),
55
+ pit=PointInTimeApi(
56
+ open="_search/point_in_time", key="pit_id", close="/_search/point_in_time", listed=True
57
+ ),
58
+ )
59
+
60
+
61
+ def engine() -> ElasticEngine:
62
+ """The entry point named in ``datadouble.engines``."""
63
+ return ElasticEngine(OPENSEARCH)
@@ -0,0 +1,90 @@
1
+ # Copyright (c) 2026- Tight Line LLC
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """OpenSearch behavior beyond the conformance suite: copies of its images.
5
+
6
+ Everything else is the Elasticsearch adapter's code, tested there.
7
+ """
8
+
9
+ import json
10
+ import shutil
11
+ from pathlib import Path
12
+
13
+ import pytest
14
+
15
+ from datadouble.catalog import CatalogLock
16
+ from datadouble.planner import PlanOptions
17
+ from datadouble.registry import Registry, installed
18
+ from datadouble.run import Run, RunOptions, Stage
19
+ from datadouble.runtime import Container
20
+ from datadouble.spec import ImageFormat, parse_spec
21
+ from datadouble.storage import filesystem_store
22
+ from datadouble_conformance.engine import runtime_for_tests
23
+ from datadouble_elasticsearch import ElasticEngine
24
+ from datadouble_elasticsearch.client import Client, document, items, path
25
+ from datadouble_elasticsearch.server import LOGIN_ENV, PORT, Tools, ready_command
26
+ from datadouble_elasticsearch.working import ElasticWorking, serve_command
27
+ from datadouble_opensearch import OPENSEARCH, engine
28
+ from test_elasticsearch_conformance import scratch
29
+ from test_opensearch_conformance import URL
30
+
31
+ pytestmark = pytest.mark.integration
32
+
33
+ VERSION = "3.9.0"
34
+
35
+
36
+ def test_served_copies(tmp_path: Path) -> None:
37
+ """A copy restores its image at first start and keeps its password after."""
38
+ ((kind, settings),) = runtime_for_tests().items()
39
+ runtime = installed().runtime(kind, settings)
40
+ with scratch(URL, OPENSEARCH) as source:
41
+ for item in (1, 2, 3):
42
+ source.insert(item)
43
+ spec = parse_spec(
44
+ "name: items\n"
45
+ f"sources: {{app: {{engine: opensearch,"
46
+ f" connection: {json.dumps(dict(source.connection))}}}}}\n"
47
+ 'subset: {seeds: {items: \'{"range": {"id": {"lte": 2}}}\'}}\n'
48
+ f"runtime: {json.dumps(runtime_for_tests())}\n"
49
+ )
50
+ with engine().connect(source.connection) as session:
51
+ lock = CatalogLock.of(session.catalog())
52
+ registry = Registry(
53
+ engines={"opensearch": engine},
54
+ stores={"filesystem": filesystem_store},
55
+ runtimes=installed().runtimes,
56
+ )
57
+ stages = (Stage.PLAN, Stage.EXTRACT, Stage.LOAD, Stage.TRANSFORM)
58
+ options = RunOptions(stages=stages, work=tmp_path / "work", plan=PlanOptions())
59
+ result = Run(spec, lock, registry, options).execute()
60
+ image = tmp_path / "image"
61
+ image.mkdir()
62
+ tools = Tools(OPENSEARCH, runtime, OPENSEARCH.image(VERSION))
63
+ assert ElasticWorking(tools, tmp_path / "scratch").server_version() == VERSION
64
+ ElasticWorking(tools, tmp_path / "scratch").package(
65
+ Path(result.work) / "transform" / "all" / "db", ImageFormat.PHYSICAL, image
66
+ )
67
+ plan = ElasticEngine(OPENSEARCH).server(image, None)
68
+ assert (plan.image, plan.user, plan.owner) == (OPENSEARCH.image(VERSION), "admin", "1000:1000")
69
+ # The plan's mount is a fixed path; serve the copy where it is instead,
70
+ # with a password like the ones replicate adapters make.
71
+ copy = tmp_path / "copy"
72
+ shutil.copytree(image, copy)
73
+ command, marker = serve_command(OPENSEARCH, str(copy), "512m")
74
+ login = "0123456789abcdef0123456789abcdef"
75
+ container = Container(
76
+ image=OPENSEARCH.image(VERSION),
77
+ command=("sh", "-c", command),
78
+ owner=copy,
79
+ mounts=(copy,),
80
+ secrets={LOGIN_ENV: login},
81
+ port=PORT,
82
+ ready=ready_command(OPENSEARCH, marker),
83
+ )
84
+ for _start in range(2):
85
+ with runtime.serve(container) as server:
86
+ client = Client.at(server.endpoint.host, server.endpoint.port, login, OPENSEARCH)
87
+ reply = client.request("POST", path("items", "_search"), "reading", body={})
88
+ hits = items(document(reply.get("hits"), "hits").get("hits"), "hits")
89
+ assert sorted(str(document(hit, "a hit").get("_id")) for hit in hits) == ["1", "2"]
90
+ client.close()
@@ -0,0 +1,62 @@
1
+ # Copyright (c) 2026- Tight Line LLC
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """The engine conformance suite against the generated indices in the Compose opensearch service.
5
+
6
+ The service holds the same indices as the elasticsearch service, so the
7
+ sample spec is the Elasticsearch one with OpenSearch's engine, URL and image.
8
+ """
9
+
10
+ from collections.abc import Generator
11
+ from contextlib import contextmanager
12
+
13
+ import pytest
14
+
15
+ from datadouble.names import ColumnName, ColumnRef, TableName
16
+ from datadouble_conformance.engine import (
17
+ EngineConformance,
18
+ EngineHarness,
19
+ ScratchSource,
20
+ runtime_for_tests,
21
+ )
22
+ from datadouble_elasticsearch import ElasticEngine
23
+ from datadouble_opensearch import OPENSEARCH
24
+ from test_elasticsearch_conformance import IMAGE as ELASTICSEARCH_IMAGE
25
+ from test_elasticsearch_conformance import SAMPLE_SPEC as ELASTICSEARCH_SPEC
26
+ from test_elasticsearch_conformance import URL as ELASTICSEARCH_URL
27
+ from test_elasticsearch_conformance import scratch
28
+
29
+ pytestmark = pytest.mark.integration
30
+
31
+ URL = "DATADOUBLE_TEST_OPENSEARCH_URL"
32
+ IMAGE = (
33
+ "opensearchproject/opensearch:3.9.0"
34
+ "@sha256:3b55f6b6249cfdb92b52ee59adc8a266203ba9ef9f5d82544fad6f1af2f3609e"
35
+ )
36
+ SAMPLE_SPEC = (
37
+ ELASTICSEARCH_SPEC.replace("engine: elasticsearch", "engine: opensearch")
38
+ .replace(ELASTICSEARCH_URL, URL)
39
+ .replace(ELASTICSEARCH_IMAGE, IMAGE)
40
+ )
41
+
42
+
43
+ @contextmanager
44
+ def _scratch() -> Generator[ScratchSource]:
45
+ with scratch(URL, OPENSEARCH) as source:
46
+ yield source
47
+
48
+
49
+ @pytest.fixture
50
+ def harness() -> EngineHarness:
51
+ """The OpenSearch harness."""
52
+ return EngineHarness(
53
+ engine=ElasticEngine(OPENSEARCH),
54
+ sample_spec=SAMPLE_SPEC,
55
+ sample_column=ColumnRef(table=TableName.of("customers"), column=ColumnName("email")),
56
+ scratch=_scratch,
57
+ runtime=runtime_for_tests(),
58
+ )
59
+
60
+
61
+ class TestConformance(EngineConformance):
62
+ """OpenSearch passes the engine conformance suite."""