continuo-engine-contract 0.9.0__tar.gz → 0.11.0__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.
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/PKG-INFO +18 -7
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/README.md +17 -6
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/port.py +72 -3
- continuo_engine_contract-0.11.0/continuo_engine_contract/result.py +59 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/testing/conformance.py +119 -1
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/pyproject.toml +1 -1
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_conformance_suite.py +49 -2
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_port.py +21 -6
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_result.py +33 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_startup_conformance.py +13 -0
- continuo_engine_contract-0.9.0/continuo_engine_contract/result.py +0 -34
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/.gitignore +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/LICENSE +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/NOTICE +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/__init__.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/config.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/keys.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/sql.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/testing/__init__.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/types.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/__init__.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_config.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_contract_keys.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_contract_packaging.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_contract_types.py +0 -0
- {continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_sql.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: continuo-engine-contract
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: The contract a Continuo warehouse engine must satisfy: the WarehouseAdapter port and the result-block wire format.
|
|
5
5
|
Author: Simone Carolini
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -22,13 +22,13 @@ validation runner alike — and every engine adapter library. Seven modules:
|
|
|
22
22
|
|
|
23
23
|
| Module | What it holds |
|
|
24
24
|
|---|---|
|
|
25
|
-
| `continuo_engine_contract.port` | The `WarehouseAdapter` port — one port covering both the data plane (`fetch`/`ensure_table`/`load`) and validation (engine-specific empty-table DDL) — the opt-in write capabilities (`TableIntrospection`, `AppendCapable`, `UpsertCapable`, with `LiveColumn`), plus entry-point discovery |
|
|
25
|
+
| `continuo_engine_contract.port` | The `WarehouseAdapter` port — one port covering both the data plane (`fetch`/`ensure_table`/`load`) and validation (engine-specific empty-table DDL) — the opt-in write capabilities (`TableIntrospection`, `AppendCapable`, `UpsertCapable`, with `LiveColumn`, and `DependentsIntrospection`, with `Dependent` and `Dependents`), the `drop_semantics` every adapter declares, plus entry-point discovery |
|
|
26
26
|
| `continuo_engine_contract.keys` | `ensure_unique_key` and `DuplicateKeyError`: the primary-key check `UpsertCapable.upsert` runs before any engine sees the rows |
|
|
27
27
|
| `continuo_engine_contract.types` | The SQL column-type grammar that DDL-emitting methods validate against |
|
|
28
28
|
| `continuo_engine_contract.sql` | `ensure_single_read`, the parse-backed gate `check_binds` runs before it lets a declared read near an engine |
|
|
29
29
|
| `continuo_engine_contract.config` | `ensure_known_keys`, the fail-closed gate `build_empty_from_columns` runs before it lets a node's physical-layout `config` block reach DDL |
|
|
30
30
|
| `continuo_engine_contract.result` | The sentinel-framed result-block wire format the runner emits and the k8s-controller parses |
|
|
31
|
-
| `continuo_engine_contract.testing.conformance` | The pytest conformance suite that an adapter's integration tests subclass: `StartupConformance`, which every adapter runs (`from_env` waits out a warehouse that refuses connections at first
|
|
31
|
+
| `continuo_engine_contract.testing.conformance` | The pytest conformance suite that an adapter's integration tests subclass: `StartupConformance`, which every adapter runs (`from_env` waits out a warehouse that refuses connections at first and the adapter declares a `drop_semantics`; fixtures `warehouse_address` and `adapter_from_env`), and the write capabilities' `IntrospectionConformance`, `AppendConformance`, `UpsertConformance`, `DependentsConformance` (fixtures `adapter` and `schema`; `DependentsConformance` creates views through its overridable `create_view` hook). Needs the `testing` extra |
|
|
32
32
|
|
|
33
33
|
Each `continuo-python-runtime-<engine>` library depends on this package and
|
|
34
34
|
implements the port.
|
|
@@ -50,7 +50,7 @@ either. It's the interface both callers agree on: `continuo-python-runtime`
|
|
|
50
50
|
`continuo-python-runtime-<engine>` adapter package (which implements it). The
|
|
51
51
|
whole contract is the twelve `WarehouseAdapter` methods (`required_env`,
|
|
52
52
|
`from_env`, `ensure_schema`, `drop_schema`, `build_empty_from_sql`,
|
|
53
|
-
`
|
|
53
|
+
`build_empty_from_prod`, `build_empty_from_columns`, `check_binds`, `fetch`,
|
|
54
54
|
`ensure_table`, `load`, `close`) plus the sentinel result-block format, both
|
|
55
55
|
reached through the single `continuo_engine.adapters` entry-point group that
|
|
56
56
|
`discover_adapter` resolves against — and the three shared guards
|
|
@@ -59,12 +59,19 @@ implementations are required to run rather than reinvent:
|
|
|
59
59
|
`sql.ensure_single_read` before letting a declared read reach an engine, and
|
|
60
60
|
`config.ensure_known_keys` before building any DDL from a node's
|
|
61
61
|
physical-layout `config` block, to reject keys this engine doesn't recognize.
|
|
62
|
-
|
|
62
|
+
Every adapter also declares the class attribute `drop_semantics`, with no
|
|
63
|
+
default: `"cascade"` when dropping a table destroys the objects that read it,
|
|
64
|
+
`"late_binding"` when they survive and fail on their next read. Continuo's seed
|
|
65
|
+
reload rules follow it.
|
|
66
|
+
Four capability interfaces are opt-in on top of the port. An adapter that
|
|
63
67
|
also inherits `AppendCapable` (`table_columns`, `append`) or `UpsertCapable`
|
|
64
68
|
(`table_columns`, `_upsert`; the port's own `upsert` checks key uniqueness
|
|
65
69
|
first) can run `append` / `upsert` nodes; an adapter that inherits neither
|
|
66
70
|
still runs every `replace` node. `ensure_table` takes an optional
|
|
67
|
-
keyword-only `primary_key`, passed only for upsert nodes.
|
|
71
|
+
keyword-only `primary_key`, passed only for upsert nodes. An adapter that
|
|
72
|
+
inherits `DependentsIntrospection` (`dependents`) lists every object a drop of
|
|
73
|
+
a table would destroy or leave reading a missing table, and gives none for a
|
|
74
|
+
missing table or schema.
|
|
68
75
|
|
|
69
76
|
Because the port *is* the contract, this package is very unlikely to need
|
|
70
77
|
changes — new warehouse support is a new adapter package implementing the
|
|
@@ -73,4 +80,8 @@ version that the co-located runtime and adapters in this workspace consume
|
|
|
73
80
|
immediately, and that external adapter authors pin from PyPI, so treat it as
|
|
74
81
|
a deliberate, coordinated change. The `result` module is stricter still: its
|
|
75
82
|
wire format is frozen against Continuo's Go parser (`pkg/validationresult`)
|
|
76
|
-
and must not change from this side at all.
|
|
83
|
+
and must not change from this side at all. The only additions are two optional
|
|
84
|
+
keyword-only arguments. `reason` is written after `unique_id` and only when
|
|
85
|
+
non-empty, so a block without one keeps the five standard keys byte for byte.
|
|
86
|
+
`fields` holds an op's own keys, written after `reason` in the order given; a
|
|
87
|
+
key equal to a standard key or to `reason` raises `ValueError`.
|
|
@@ -5,13 +5,13 @@ validation runner alike — and every engine adapter library. Seven modules:
|
|
|
5
5
|
|
|
6
6
|
| Module | What it holds |
|
|
7
7
|
|---|---|
|
|
8
|
-
| `continuo_engine_contract.port` | The `WarehouseAdapter` port — one port covering both the data plane (`fetch`/`ensure_table`/`load`) and validation (engine-specific empty-table DDL) — the opt-in write capabilities (`TableIntrospection`, `AppendCapable`, `UpsertCapable`, with `LiveColumn`), plus entry-point discovery |
|
|
8
|
+
| `continuo_engine_contract.port` | The `WarehouseAdapter` port — one port covering both the data plane (`fetch`/`ensure_table`/`load`) and validation (engine-specific empty-table DDL) — the opt-in write capabilities (`TableIntrospection`, `AppendCapable`, `UpsertCapable`, with `LiveColumn`, and `DependentsIntrospection`, with `Dependent` and `Dependents`), the `drop_semantics` every adapter declares, plus entry-point discovery |
|
|
9
9
|
| `continuo_engine_contract.keys` | `ensure_unique_key` and `DuplicateKeyError`: the primary-key check `UpsertCapable.upsert` runs before any engine sees the rows |
|
|
10
10
|
| `continuo_engine_contract.types` | The SQL column-type grammar that DDL-emitting methods validate against |
|
|
11
11
|
| `continuo_engine_contract.sql` | `ensure_single_read`, the parse-backed gate `check_binds` runs before it lets a declared read near an engine |
|
|
12
12
|
| `continuo_engine_contract.config` | `ensure_known_keys`, the fail-closed gate `build_empty_from_columns` runs before it lets a node's physical-layout `config` block reach DDL |
|
|
13
13
|
| `continuo_engine_contract.result` | The sentinel-framed result-block wire format the runner emits and the k8s-controller parses |
|
|
14
|
-
| `continuo_engine_contract.testing.conformance` | The pytest conformance suite that an adapter's integration tests subclass: `StartupConformance`, which every adapter runs (`from_env` waits out a warehouse that refuses connections at first
|
|
14
|
+
| `continuo_engine_contract.testing.conformance` | The pytest conformance suite that an adapter's integration tests subclass: `StartupConformance`, which every adapter runs (`from_env` waits out a warehouse that refuses connections at first and the adapter declares a `drop_semantics`; fixtures `warehouse_address` and `adapter_from_env`), and the write capabilities' `IntrospectionConformance`, `AppendConformance`, `UpsertConformance`, `DependentsConformance` (fixtures `adapter` and `schema`; `DependentsConformance` creates views through its overridable `create_view` hook). Needs the `testing` extra |
|
|
15
15
|
|
|
16
16
|
Each `continuo-python-runtime-<engine>` library depends on this package and
|
|
17
17
|
implements the port.
|
|
@@ -33,7 +33,7 @@ either. It's the interface both callers agree on: `continuo-python-runtime`
|
|
|
33
33
|
`continuo-python-runtime-<engine>` adapter package (which implements it). The
|
|
34
34
|
whole contract is the twelve `WarehouseAdapter` methods (`required_env`,
|
|
35
35
|
`from_env`, `ensure_schema`, `drop_schema`, `build_empty_from_sql`,
|
|
36
|
-
`
|
|
36
|
+
`build_empty_from_prod`, `build_empty_from_columns`, `check_binds`, `fetch`,
|
|
37
37
|
`ensure_table`, `load`, `close`) plus the sentinel result-block format, both
|
|
38
38
|
reached through the single `continuo_engine.adapters` entry-point group that
|
|
39
39
|
`discover_adapter` resolves against — and the three shared guards
|
|
@@ -42,12 +42,19 @@ implementations are required to run rather than reinvent:
|
|
|
42
42
|
`sql.ensure_single_read` before letting a declared read reach an engine, and
|
|
43
43
|
`config.ensure_known_keys` before building any DDL from a node's
|
|
44
44
|
physical-layout `config` block, to reject keys this engine doesn't recognize.
|
|
45
|
-
|
|
45
|
+
Every adapter also declares the class attribute `drop_semantics`, with no
|
|
46
|
+
default: `"cascade"` when dropping a table destroys the objects that read it,
|
|
47
|
+
`"late_binding"` when they survive and fail on their next read. Continuo's seed
|
|
48
|
+
reload rules follow it.
|
|
49
|
+
Four capability interfaces are opt-in on top of the port. An adapter that
|
|
46
50
|
also inherits `AppendCapable` (`table_columns`, `append`) or `UpsertCapable`
|
|
47
51
|
(`table_columns`, `_upsert`; the port's own `upsert` checks key uniqueness
|
|
48
52
|
first) can run `append` / `upsert` nodes; an adapter that inherits neither
|
|
49
53
|
still runs every `replace` node. `ensure_table` takes an optional
|
|
50
|
-
keyword-only `primary_key`, passed only for upsert nodes.
|
|
54
|
+
keyword-only `primary_key`, passed only for upsert nodes. An adapter that
|
|
55
|
+
inherits `DependentsIntrospection` (`dependents`) lists every object a drop of
|
|
56
|
+
a table would destroy or leave reading a missing table, and gives none for a
|
|
57
|
+
missing table or schema.
|
|
51
58
|
|
|
52
59
|
Because the port *is* the contract, this package is very unlikely to need
|
|
53
60
|
changes — new warehouse support is a new adapter package implementing the
|
|
@@ -56,4 +63,8 @@ version that the co-located runtime and adapters in this workspace consume
|
|
|
56
63
|
immediately, and that external adapter authors pin from PyPI, so treat it as
|
|
57
64
|
a deliberate, coordinated change. The `result` module is stricter still: its
|
|
58
65
|
wire format is frozen against Continuo's Go parser (`pkg/validationresult`)
|
|
59
|
-
and must not change from this side at all.
|
|
66
|
+
and must not change from this side at all. The only additions are two optional
|
|
67
|
+
keyword-only arguments. `reason` is written after `unique_id` and only when
|
|
68
|
+
non-empty, so a block without one keeps the five standard keys byte for byte.
|
|
69
|
+
`fields` holds an op's own keys, written after `reason` in the order given; a
|
|
70
|
+
key equal to a standard key or to `reason` raises `ValueError`.
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/port.py
RENAMED
|
@@ -5,7 +5,7 @@ One port covers both roles an engine plays in Continuo:
|
|
|
5
5
|
* **validation DDL** — a release gate builds each node as an EMPTY table in the
|
|
6
6
|
candidate schema and bind-checks its compiled SQL (``ensure_schema``,
|
|
7
7
|
``drop_schema``, ``build_empty_from_sql``, ``build_empty_from_columns``,
|
|
8
|
-
``
|
|
8
|
+
``build_empty_from_prod``, ``check_binds``);
|
|
9
9
|
* **python-node data-plane I/O** — the runtime harness reads declared inputs and
|
|
10
10
|
writes a node's result (``fetch``, ``ensure_table``, ``load``).
|
|
11
11
|
|
|
@@ -13,6 +13,13 @@ Writing modes beyond replace are opt-in capabilities an adapter declares by
|
|
|
13
13
|
inheritance (``TableIntrospection``, ``AppendCapable``, ``UpsertCapable``): an
|
|
14
14
|
adapter that declares none still runs every ``replace`` node, and one that
|
|
15
15
|
declares a capability must implement all of it to be instantiated.
|
|
16
|
+
``DependentsIntrospection`` is a further opt-in capability: it lists the objects
|
|
17
|
+
a drop of a table would destroy or leave reading a missing table.
|
|
18
|
+
|
|
19
|
+
Every adapter also declares ``drop_semantics``: what dropping a table does to
|
|
20
|
+
the objects that read it. It decides the seed reload rules continuo applies: a
|
|
21
|
+
drop that destroys the dependants (``cascade``), or one that leaves them reading
|
|
22
|
+
a missing table (``late_binding``).
|
|
16
23
|
|
|
17
24
|
Both roles are served by the same connection to the same warehouse, so they are
|
|
18
25
|
one implementation per engine rather than two. Engine packages register a single
|
|
@@ -25,12 +32,24 @@ from abc import ABC, abstractmethod
|
|
|
25
32
|
from collections.abc import Sequence
|
|
26
33
|
from dataclasses import dataclass
|
|
27
34
|
from importlib.metadata import entry_points
|
|
28
|
-
from typing import TYPE_CHECKING
|
|
35
|
+
from typing import TYPE_CHECKING, ClassVar, Literal
|
|
29
36
|
|
|
30
37
|
from continuo_engine_contract.keys import ensure_unique_key
|
|
31
38
|
|
|
32
39
|
ENTRY_POINT_GROUP = "continuo_engine.adapters"
|
|
33
40
|
|
|
41
|
+
DropSemantics = Literal["cascade", "late_binding"]
|
|
42
|
+
DROP_SEMANTICS: frozenset[str] = frozenset({"cascade", "late_binding"})
|
|
43
|
+
|
|
44
|
+
# How far a dependents listing can be trusted: ``exact`` lists every object a
|
|
45
|
+
# drop would affect, ``best_effort`` may miss some the engine cannot report.
|
|
46
|
+
COMPLETENESS: frozenset[str] = frozenset({"exact", "best_effort"})
|
|
47
|
+
|
|
48
|
+
DEPENDENT_KINDS: frozenset[str] = frozenset({
|
|
49
|
+
"view", "materialized_view", "table", "function", "procedure",
|
|
50
|
+
"constraint", "policy", "rule", "other",
|
|
51
|
+
})
|
|
52
|
+
|
|
34
53
|
if TYPE_CHECKING: # pragma: no cover
|
|
35
54
|
import pyarrow # type: ignore[import-untyped]
|
|
36
55
|
|
|
@@ -48,8 +67,14 @@ class WarehouseAdapter(ABC):
|
|
|
48
67
|
rather than printing them, must never write to stdout, and must never emit
|
|
49
68
|
the ``===CONTINUO_VALIDATION_RESULT_BEGIN/END===`` marker strings
|
|
50
69
|
themselves.
|
|
70
|
+
|
|
71
|
+
``drop_semantics`` is declared by every concrete adapter (there is no
|
|
72
|
+
default): ``"cascade"`` when dropping a table also destroys the objects that
|
|
73
|
+
read it, ``"late_binding"`` when they survive and fail on their next read.
|
|
51
74
|
"""
|
|
52
75
|
|
|
76
|
+
drop_semantics: ClassVar[DropSemantics]
|
|
77
|
+
|
|
53
78
|
@classmethod
|
|
54
79
|
@abstractmethod
|
|
55
80
|
def required_env(cls) -> list[str]:
|
|
@@ -87,7 +112,7 @@ class WarehouseAdapter(ABC):
|
|
|
87
112
|
"""Create ``schema.table`` empty, shaped by the compiled SELECT."""
|
|
88
113
|
|
|
89
114
|
@abstractmethod
|
|
90
|
-
def
|
|
115
|
+
def build_empty_from_prod(self, candidate_schema: str, prod_schema: str, table: str) -> None:
|
|
91
116
|
"""Create ``candidate_schema.table`` empty, shaped like ``prod_schema.table``."""
|
|
92
117
|
|
|
93
118
|
@abstractmethod
|
|
@@ -261,6 +286,50 @@ class UpsertCapable(TableIntrospection):
|
|
|
261
286
|
"""
|
|
262
287
|
|
|
263
288
|
|
|
289
|
+
@dataclass(frozen=True)
|
|
290
|
+
class Dependent:
|
|
291
|
+
"""One object that reads a table: *schema*.*name* of *kind*, *owner* its engine owner.
|
|
292
|
+
|
|
293
|
+
*depth* is 1 for an object that reads the table directly, 2 for one that
|
|
294
|
+
reads a depth-1 object, and so on.
|
|
295
|
+
"""
|
|
296
|
+
|
|
297
|
+
schema: str
|
|
298
|
+
name: str
|
|
299
|
+
kind: str
|
|
300
|
+
owner: str
|
|
301
|
+
depth: int
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
@dataclass(frozen=True)
|
|
305
|
+
class Dependents:
|
|
306
|
+
"""The objects a drop would affect, with how far the listing can be trusted.
|
|
307
|
+
|
|
308
|
+
*kind* values come from ``DEPENDENT_KINDS`` and *completeness* from
|
|
309
|
+
``COMPLETENESS``.
|
|
310
|
+
"""
|
|
311
|
+
|
|
312
|
+
objects: tuple[Dependent, ...]
|
|
313
|
+
completeness: str
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
class DependentsIntrospection(ABC):
|
|
317
|
+
"""Lists the objects that read a table.
|
|
318
|
+
|
|
319
|
+
Declare it by inheritance, e.g. ``class MyAdapter(WarehouseAdapter,
|
|
320
|
+
DependentsIntrospection)``.
|
|
321
|
+
"""
|
|
322
|
+
|
|
323
|
+
@abstractmethod
|
|
324
|
+
def dependents(self, schema: str, table: str) -> Dependents:
|
|
325
|
+
"""Every object a drop of ``schema.table`` would destroy or leave reading a missing table.
|
|
326
|
+
|
|
327
|
+
Only objects that read exactly this table are listed, never one that
|
|
328
|
+
reads a table whose name merely starts with it. A missing table or
|
|
329
|
+
schema gives no objects and never raises.
|
|
330
|
+
"""
|
|
331
|
+
|
|
332
|
+
|
|
264
333
|
def discover_adapter() -> tuple[str, type[WarehouseAdapter]]:
|
|
265
334
|
"""Return ``(engine_name, adapter_class)`` from the single installed plugin.
|
|
266
335
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Cross-language contract for one validation node's structured result.
|
|
2
|
+
|
|
3
|
+
validation_runner.py prints exactly one sentinel-framed block on stdout as its LAST
|
|
4
|
+
output. The k8s-controller extracts the block from the pod log, uploads the JSON to
|
|
5
|
+
S3, and surfaces it as run_results_uri. The remediation classifier reads status +
|
|
6
|
+
message deterministically, falling back to the text log when the block is absent.
|
|
7
|
+
|
|
8
|
+
status uses dbt's RunStatus vocabulary (success | error | fail | skipped).
|
|
9
|
+
"""
|
|
10
|
+
import json
|
|
11
|
+
from collections.abc import Mapping
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
SENTINEL_BEGIN = "===CONTINUO_VALIDATION_RESULT_BEGIN==="
|
|
15
|
+
SENTINEL_END = "===CONTINUO_VALIDATION_RESULT_END==="
|
|
16
|
+
|
|
17
|
+
SCHEMA_VERSION = 1
|
|
18
|
+
|
|
19
|
+
# The keys ``result_block`` writes itself; a caller's ``fields`` may not reuse them.
|
|
20
|
+
_RESERVED_KEYS = frozenset(
|
|
21
|
+
{"schema_version", "status", "message", "failures", "unique_id", "reason"}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def result_block(
|
|
26
|
+
status: str,
|
|
27
|
+
message: str = "",
|
|
28
|
+
failures: int = 0,
|
|
29
|
+
unique_id: str = "",
|
|
30
|
+
*,
|
|
31
|
+
reason: str = "",
|
|
32
|
+
fields: Mapping[str, Any] | None = None,
|
|
33
|
+
) -> str:
|
|
34
|
+
"""Return the sentinel-framed, single-line-JSON block for one node.
|
|
35
|
+
|
|
36
|
+
The JSON is compact (no embedded newlines) so the consumer can split the
|
|
37
|
+
block out of a multi-line pod log by marker lines alone. ``reason``, a
|
|
38
|
+
machine-readable failure code, is written after ``unique_id`` and only when
|
|
39
|
+
non-empty, so a block without one keeps the five standard keys byte for byte.
|
|
40
|
+
``fields`` carries an op's own keys; they follow ``reason`` in the order
|
|
41
|
+
given, and a key that is one of the standard keys or ``reason`` raises
|
|
42
|
+
``ValueError`` naming it.
|
|
43
|
+
"""
|
|
44
|
+
extra = dict(fields or {})
|
|
45
|
+
for key in extra:
|
|
46
|
+
if key in _RESERVED_KEYS:
|
|
47
|
+
raise ValueError(f"result field {key!r} shadows a standard result key")
|
|
48
|
+
doc: dict[str, Any] = {
|
|
49
|
+
"schema_version": SCHEMA_VERSION,
|
|
50
|
+
"status": status,
|
|
51
|
+
"message": message or "",
|
|
52
|
+
"failures": int(failures or 0),
|
|
53
|
+
"unique_id": unique_id or "",
|
|
54
|
+
}
|
|
55
|
+
if reason:
|
|
56
|
+
doc["reason"] = reason
|
|
57
|
+
doc.update(extra)
|
|
58
|
+
body = json.dumps(doc, separators=(",", ":"))
|
|
59
|
+
return f"{SENTINEL_BEGIN}\n{body}\n{SENTINEL_END}"
|
|
@@ -43,7 +43,13 @@ import pyarrow as pa # type: ignore[import-untyped]
|
|
|
43
43
|
import pytest
|
|
44
44
|
|
|
45
45
|
from continuo_engine_contract.keys import DuplicateKeyError
|
|
46
|
-
from continuo_engine_contract.port import
|
|
46
|
+
from continuo_engine_contract.port import (
|
|
47
|
+
COMPLETENESS,
|
|
48
|
+
DEPENDENT_KINDS,
|
|
49
|
+
DROP_SEMANTICS,
|
|
50
|
+
Dependents,
|
|
51
|
+
LiveColumn,
|
|
52
|
+
)
|
|
47
53
|
|
|
48
54
|
# More rows than one insert statement carries in any shipped adapter (postgres
|
|
49
55
|
# pages 1000 rows, trino batches 500), so an atomicity case spans statements.
|
|
@@ -224,6 +230,18 @@ class StartupConformance:
|
|
|
224
230
|
if rows != [{"one": 1}]:
|
|
225
231
|
raise AssertionError(f"SELECT 1 AS one returned {rows}, expected [{{'one': 1}}]")
|
|
226
232
|
|
|
233
|
+
def test_declares_a_drop_semantics(self, warehouse_address, adapter_from_env):
|
|
234
|
+
adapter = adapter_from_env(*warehouse_address)
|
|
235
|
+
try:
|
|
236
|
+
declared = getattr(type(adapter), "drop_semantics", None)
|
|
237
|
+
finally:
|
|
238
|
+
adapter.close()
|
|
239
|
+
if declared not in DROP_SEMANTICS:
|
|
240
|
+
raise AssertionError(
|
|
241
|
+
f"{type(adapter).__name__}.drop_semantics is {declared!r}, "
|
|
242
|
+
f"expected one of {sorted(DROP_SEMANTICS)}"
|
|
243
|
+
)
|
|
244
|
+
|
|
227
245
|
|
|
228
246
|
class ConformanceBase:
|
|
229
247
|
"""Helpers shared by the capability classes (fixtures: see the module docstring)."""
|
|
@@ -429,3 +447,103 @@ class UpsertConformance(ConformanceBase):
|
|
|
429
447
|
(day2, "EUR", None),
|
|
430
448
|
],
|
|
431
449
|
)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
class DependentsConformance(ConformanceBase):
|
|
453
|
+
"""For an adapter that is a ``DependentsIntrospection``.
|
|
454
|
+
|
|
455
|
+
Views are created through :meth:`create_view`; an engine whose view syntax
|
|
456
|
+
differs from ANSI overrides it. Tables are made by ``ensure_table`` with an
|
|
457
|
+
``id`` column, and every view and schema a case makes is dropped with the
|
|
458
|
+
``schema`` fixture or in the case's own ``finally``.
|
|
459
|
+
"""
|
|
460
|
+
|
|
461
|
+
def create_view(
|
|
462
|
+
self, adapter: Any, view_schema: str, view: str, table_schema: str, table: str
|
|
463
|
+
) -> None:
|
|
464
|
+
"""Create ``view_schema.view`` as a read of ``table_schema.table``'s ``id`` column."""
|
|
465
|
+
adapter.fetch(
|
|
466
|
+
f"CREATE VIEW {quote(view_schema)}.{quote(view)} AS "
|
|
467
|
+
f"SELECT {quote('id')} FROM {quote(table_schema)}.{quote(table)}"
|
|
468
|
+
)
|
|
469
|
+
|
|
470
|
+
def expect_dependents(
|
|
471
|
+
self,
|
|
472
|
+
adapter: Any,
|
|
473
|
+
schema: str,
|
|
474
|
+
table: str,
|
|
475
|
+
expected: Iterable[tuple[str, str, str, int]],
|
|
476
|
+
) -> None:
|
|
477
|
+
"""Fail unless a drop of ``schema.table`` lists exactly *expected*, in any order.
|
|
478
|
+
|
|
479
|
+
Each entry is ``(schema, name, kind, depth)``; names compare in lower case.
|
|
480
|
+
"""
|
|
481
|
+
result: Dependents = adapter.dependents(schema, table)
|
|
482
|
+
if result.completeness not in COMPLETENESS:
|
|
483
|
+
raise AssertionError(
|
|
484
|
+
f"dependents({schema}.{table}) reports completeness {result.completeness!r}, "
|
|
485
|
+
f"expected one of {sorted(COMPLETENESS)}"
|
|
486
|
+
)
|
|
487
|
+
for found in result.objects:
|
|
488
|
+
if found.kind not in DEPENDENT_KINDS:
|
|
489
|
+
raise AssertionError(
|
|
490
|
+
f"dependents({schema}.{table}) lists {found.schema}.{found.name} "
|
|
491
|
+
f"of kind {found.kind!r}, expected one of {sorted(DEPENDENT_KINDS)}"
|
|
492
|
+
)
|
|
493
|
+
if found.depth < 1:
|
|
494
|
+
raise AssertionError(
|
|
495
|
+
f"dependents({schema}.{table}) lists {found.schema}.{found.name} "
|
|
496
|
+
f"at depth {found.depth}, expected 1 or more"
|
|
497
|
+
)
|
|
498
|
+
actual = sorted(
|
|
499
|
+
(found.schema.lower(), found.name.lower(), found.kind, found.depth)
|
|
500
|
+
for found in result.objects
|
|
501
|
+
)
|
|
502
|
+
wanted = sorted(
|
|
503
|
+
(entry[0].lower(), entry[1].lower(), entry[2], entry[3]) for entry in expected
|
|
504
|
+
)
|
|
505
|
+
if actual != wanted:
|
|
506
|
+
raise AssertionError(f"dependents({schema}.{table}) lists {actual}, expected {wanted}")
|
|
507
|
+
|
|
508
|
+
def test_dependents_of_a_table_nothing_reads_is_empty(self, adapter, schema):
|
|
509
|
+
table = self.new_table(adapter, schema, COLUMNS)
|
|
510
|
+
self.expect_dependents(adapter, schema, table, [])
|
|
511
|
+
|
|
512
|
+
def test_dependents_of_a_missing_table_or_schema_is_empty(self, adapter, schema):
|
|
513
|
+
self.new_table(adapter, schema, COLUMNS) # the schema exists; only the table is missing
|
|
514
|
+
suffix = uuid.uuid4().hex[:8]
|
|
515
|
+
self.expect_dependents(adapter, schema, f"conf_missing_{suffix}", [])
|
|
516
|
+
self.expect_dependents(adapter, f"conf_noschema_{suffix}", "seed", [])
|
|
517
|
+
|
|
518
|
+
def test_dependents_lists_a_view_that_reads_the_table(self, adapter, schema):
|
|
519
|
+
table = self.new_table(adapter, schema, COLUMNS)
|
|
520
|
+
view = f"conf_view_{uuid.uuid4().hex[:8]}"
|
|
521
|
+
self.create_view(adapter, schema, view, schema, table)
|
|
522
|
+
self.expect_dependents(adapter, schema, table, [(schema, view, "view", 1)])
|
|
523
|
+
|
|
524
|
+
def test_dependents_lists_a_view_in_another_schema(self, adapter, schema):
|
|
525
|
+
table = self.new_table(adapter, schema, COLUMNS)
|
|
526
|
+
other = f"conf_other_{uuid.uuid4().hex[:8]}"
|
|
527
|
+
view = f"conf_view_{uuid.uuid4().hex[:8]}"
|
|
528
|
+
adapter.ensure_schema(other)
|
|
529
|
+
try:
|
|
530
|
+
self.create_view(adapter, other, view, schema, table)
|
|
531
|
+
self.expect_dependents(adapter, schema, table, [(other, view, "view", 1)])
|
|
532
|
+
finally:
|
|
533
|
+
adapter.drop_schema(other)
|
|
534
|
+
|
|
535
|
+
def test_dependents_ignores_a_view_of_a_table_whose_name_extends_this_one(
|
|
536
|
+
self, adapter, schema
|
|
537
|
+
):
|
|
538
|
+
table = self.new_table(adapter, schema, COLUMNS)
|
|
539
|
+
extended = f"{table}_ext"
|
|
540
|
+
adapter.ensure_table(schema, extended, COLUMNS, config={})
|
|
541
|
+
view = f"conf_view_{uuid.uuid4().hex[:8]}"
|
|
542
|
+
self.create_view(adapter, schema, view, schema, extended)
|
|
543
|
+
result = adapter.dependents(schema, table)
|
|
544
|
+
listed = [(found.schema, found.name) for found in result.objects]
|
|
545
|
+
if listed:
|
|
546
|
+
raise AssertionError(
|
|
547
|
+
f"dependents({schema}.{table}) lists {listed}, which read {schema}.{extended}: "
|
|
548
|
+
f"a table whose name extends {table!r} is not {table!r}"
|
|
549
|
+
)
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_conformance_suite.py
RENAMED
|
@@ -9,23 +9,31 @@ import pytest
|
|
|
9
9
|
|
|
10
10
|
from continuo_engine_contract.port import (
|
|
11
11
|
AppendCapable,
|
|
12
|
+
Dependent,
|
|
13
|
+
Dependents,
|
|
14
|
+
DependentsIntrospection,
|
|
12
15
|
LiveColumn,
|
|
13
16
|
UpsertCapable,
|
|
14
17
|
WarehouseAdapter,
|
|
15
18
|
)
|
|
16
19
|
from continuo_engine_contract.testing.conformance import (
|
|
17
20
|
AppendConformance,
|
|
21
|
+
DependentsConformance,
|
|
18
22
|
IntrospectionConformance,
|
|
19
23
|
UpsertConformance,
|
|
20
24
|
canonical,
|
|
21
25
|
)
|
|
22
26
|
|
|
23
27
|
|
|
24
|
-
class _MemoryWarehouse(WarehouseAdapter, AppendCapable, UpsertCapable):
|
|
28
|
+
class _MemoryWarehouse(WarehouseAdapter, AppendCapable, UpsertCapable, DependentsIntrospection):
|
|
25
29
|
"""A reference adapter over Python lists: NOT NULL enforced, every write all-or-nothing."""
|
|
26
30
|
|
|
31
|
+
drop_semantics = "late_binding"
|
|
32
|
+
|
|
27
33
|
def __init__(self):
|
|
28
34
|
self.tables: dict[tuple[str, str], dict] = {}
|
|
35
|
+
# view (schema, name) -> the table (schema, name) it reads
|
|
36
|
+
self.views: dict[tuple[str, str], tuple[str, str]] = {}
|
|
29
37
|
|
|
30
38
|
@classmethod
|
|
31
39
|
def required_env(cls):
|
|
@@ -41,11 +49,23 @@ class _MemoryWarehouse(WarehouseAdapter, AppendCapable, UpsertCapable):
|
|
|
41
49
|
def drop_schema(self, schema):
|
|
42
50
|
for key in [key for key in self.tables if key[0] == schema]:
|
|
43
51
|
del self.tables[key]
|
|
52
|
+
for key in [key for key in self.views if key[0] == schema]:
|
|
53
|
+
del self.views[key]
|
|
54
|
+
|
|
55
|
+
def dependents(self, schema, table):
|
|
56
|
+
return Dependents(
|
|
57
|
+
tuple(
|
|
58
|
+
Dependent(view_schema, view, "view", "memory", 1)
|
|
59
|
+
for (view_schema, view), source in self.views.items()
|
|
60
|
+
if source == (schema, table)
|
|
61
|
+
),
|
|
62
|
+
"exact",
|
|
63
|
+
)
|
|
44
64
|
|
|
45
65
|
def build_empty_from_sql(self, schema, table, compiled_sql):
|
|
46
66
|
...
|
|
47
67
|
|
|
48
|
-
def
|
|
68
|
+
def build_empty_from_prod(self, candidate_schema, prod_schema, table):
|
|
49
69
|
...
|
|
50
70
|
|
|
51
71
|
def build_empty_from_columns(self, schema, table, columns, config):
|
|
@@ -124,6 +144,9 @@ class _ReadsMemory:
|
|
|
124
144
|
rows = adapter.tables[(schema, table)]["rows"]
|
|
125
145
|
return canonical(tuple(row[name] for name in names) for row in rows)
|
|
126
146
|
|
|
147
|
+
def create_view(self, adapter, view_schema, view, table_schema, table):
|
|
148
|
+
adapter.views[(view_schema, view)] = (table_schema, table)
|
|
149
|
+
|
|
127
150
|
|
|
128
151
|
@pytest.fixture
|
|
129
152
|
def adapter():
|
|
@@ -148,6 +171,24 @@ class TestMemoryUpsert(_ReadsMemory, UpsertConformance):
|
|
|
148
171
|
pass
|
|
149
172
|
|
|
150
173
|
|
|
174
|
+
class TestMemoryDependents(_ReadsMemory, DependentsConformance):
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class _PrefixMatchingWarehouse(_MemoryWarehouse):
|
|
179
|
+
"""Lists a view whose table name merely starts with the one asked."""
|
|
180
|
+
|
|
181
|
+
def dependents(self, schema, table):
|
|
182
|
+
return Dependents(tuple(
|
|
183
|
+
Dependent(vs, v, "view", "memory", 1)
|
|
184
|
+
for (vs, v), (ts, t) in self.views.items() if ts == schema and t.startswith(table)
|
|
185
|
+
), "exact")
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class _MemoryDependentsCase(_ReadsMemory, DependentsConformance):
|
|
189
|
+
pass
|
|
190
|
+
|
|
191
|
+
|
|
151
192
|
class _MemoryAppendCase(_ReadsMemory, AppendConformance):
|
|
152
193
|
pass
|
|
153
194
|
|
|
@@ -166,3 +207,9 @@ def test_the_suite_catches_an_upsert_that_loses_other_rows():
|
|
|
166
207
|
_MemoryUpsertCase().test_upsert_overwrites_existing_keys_and_leaves_other_rows_untouched(
|
|
167
208
|
_ReplacingUpsertWarehouse(), "conf"
|
|
168
209
|
)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def test_the_suite_catches_a_scan_that_matches_name_prefixes():
|
|
213
|
+
with pytest.raises(AssertionError, match="extends"):
|
|
214
|
+
_MemoryDependentsCase().test_dependents_ignores_a_view_of_a_table_whose_name_extends_this_one(
|
|
215
|
+
_PrefixMatchingWarehouse(), "conf")
|
|
@@ -17,7 +17,11 @@ import pytest
|
|
|
17
17
|
from continuo_engine_contract.keys import DuplicateKeyError
|
|
18
18
|
from continuo_engine_contract.port import (
|
|
19
19
|
ENTRY_POINT_GROUP,
|
|
20
|
+
COMPLETENESS,
|
|
21
|
+
DEPENDENT_KINDS,
|
|
22
|
+
DROP_SEMANTICS,
|
|
20
23
|
AppendCapable,
|
|
24
|
+
DependentsIntrospection,
|
|
21
25
|
LiveColumn,
|
|
22
26
|
TableIntrospection,
|
|
23
27
|
UpsertCapable,
|
|
@@ -56,7 +60,7 @@ def test_warehouse_adapter_requires_drop_schema():
|
|
|
56
60
|
def build_empty_from_sql(self, schema, table, compiled_sql):
|
|
57
61
|
...
|
|
58
62
|
|
|
59
|
-
def
|
|
63
|
+
def build_empty_from_prod(self, candidate_schema, prod_schema, table):
|
|
60
64
|
...
|
|
61
65
|
|
|
62
66
|
def build_empty_from_columns(self, schema, table, columns, config):
|
|
@@ -85,7 +89,7 @@ def test_warehouse_adapter_requires_columns_and_binds_methods():
|
|
|
85
89
|
"""A subclass missing the 0.4.0 methods cannot be instantiated.
|
|
86
90
|
|
|
87
91
|
Adapters implementing only the 0.3.0 surface (required_env, from_env,
|
|
88
|
-
ensure_schema, drop_schema, build_empty_from_sql,
|
|
92
|
+
ensure_schema, drop_schema, build_empty_from_sql, build_empty_from_prod,
|
|
89
93
|
close) must still be abstract, so callers can rely on build_empty_from_columns
|
|
90
94
|
and check_binds existing on every installed engine.
|
|
91
95
|
"""
|
|
@@ -108,7 +112,7 @@ def test_warehouse_adapter_requires_columns_and_binds_methods():
|
|
|
108
112
|
def build_empty_from_sql(self, schema, table, compiled_sql):
|
|
109
113
|
...
|
|
110
114
|
|
|
111
|
-
def
|
|
115
|
+
def build_empty_from_prod(self, candidate_schema, prod_schema, table):
|
|
112
116
|
...
|
|
113
117
|
|
|
114
118
|
def close(self):
|
|
@@ -148,7 +152,7 @@ def test_partial_engine_cannot_be_instantiated():
|
|
|
148
152
|
def build_empty_from_columns(self, schema, table, columns, config):
|
|
149
153
|
...
|
|
150
154
|
|
|
151
|
-
def
|
|
155
|
+
def build_empty_from_prod(self, schema, prod_schema, table):
|
|
152
156
|
...
|
|
153
157
|
|
|
154
158
|
def check_binds(self, sql):
|
|
@@ -274,7 +278,7 @@ class _PortOnly(WarehouseAdapter):
|
|
|
274
278
|
def build_empty_from_sql(self, schema, table, compiled_sql):
|
|
275
279
|
...
|
|
276
280
|
|
|
277
|
-
def
|
|
281
|
+
def build_empty_from_prod(self, candidate_schema, prod_schema, table):
|
|
278
282
|
...
|
|
279
283
|
|
|
280
284
|
def build_empty_from_columns(self, schema, table, columns, config):
|
|
@@ -331,7 +335,7 @@ class OneAdapter(WarehouseAdapter):
|
|
|
331
335
|
def build_empty_from_sql(self, schema, table, compiled_sql):
|
|
332
336
|
...
|
|
333
337
|
|
|
334
|
-
def
|
|
338
|
+
def build_empty_from_prod(self, candidate_schema, prod_schema, table):
|
|
335
339
|
...
|
|
336
340
|
|
|
337
341
|
def build_empty_from_columns(self, schema, table, columns, config):
|
|
@@ -467,3 +471,14 @@ def test_discover_wraps_adapter_import_failure(tmp_path):
|
|
|
467
471
|
)
|
|
468
472
|
assert out.startswith("ERR")
|
|
469
473
|
assert "failed to load adapter entry point" in out
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def test_the_dependents_capability_declares_exactly_its_own_abstract_method():
|
|
477
|
+
assert DependentsIntrospection.__abstractmethods__ == frozenset({"dependents"})
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def test_the_vocabularies_hold_the_documented_values():
|
|
481
|
+
assert DROP_SEMANTICS == frozenset({"cascade", "late_binding"})
|
|
482
|
+
assert COMPLETENESS == frozenset({"exact", "best_effort"})
|
|
483
|
+
assert DEPENDENT_KINDS == frozenset({"view", "materialized_view", "table", "function", "procedure",
|
|
484
|
+
"constraint", "policy", "rule", "other"})
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""Unit tests for the validation-result contract helper."""
|
|
2
2
|
import json
|
|
3
3
|
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
4
6
|
from continuo_engine_contract import result
|
|
5
7
|
|
|
6
8
|
|
|
@@ -38,3 +40,34 @@ def test_result_block_success_defaults():
|
|
|
38
40
|
assert doc["status"] == "success"
|
|
39
41
|
assert doc["message"] == ""
|
|
40
42
|
assert doc["failures"] == 0
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_result_block_without_a_reason_keeps_its_frozen_bytes():
|
|
46
|
+
assert result.result_block("error", "boom", 1, "a.b") == (
|
|
47
|
+
result.SENTINEL_BEGIN + "\n"
|
|
48
|
+
+ '{"schema_version":1,"status":"error","message":"boom","failures":1,"unique_id":"a.b"}'
|
|
49
|
+
+ "\n" + result.SENTINEL_END
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_result_block_writes_a_reason_only_when_given():
|
|
54
|
+
assert "reason" not in _extract(result.result_block("error", "boom"))
|
|
55
|
+
doc = _extract(result.result_block("error", "boom", reason="image_contract_mismatch"))
|
|
56
|
+
assert list(doc)[-1] == "reason" and doc["reason"] == "image_contract_mismatch"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_result_block_writes_op_fields_after_the_standard_keys():
|
|
60
|
+
doc = _extract(result.result_block("success", unique_id="a.b", fields={"op": "probe_views", "views": []}))
|
|
61
|
+
assert doc == {"schema_version": 1, "status": "success", "message": "", "failures": 0,
|
|
62
|
+
"unique_id": "a.b", "op": "probe_views", "views": []}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_result_block_writes_fields_after_the_reason_in_the_order_given():
|
|
66
|
+
doc = _extract(result.result_block("error", reason="r", fields={"z": 1, "a": 2}))
|
|
67
|
+
assert list(doc)[-3:] == ["reason", "z", "a"]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@pytest.mark.parametrize("key", ["schema_version", "status", "message", "failures", "unique_id", "reason"])
|
|
71
|
+
def test_result_block_refuses_a_field_that_shadows_a_standard_key(key):
|
|
72
|
+
with pytest.raises(ValueError, match=key):
|
|
73
|
+
result.result_block("success", fields={key: "x"})
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_startup_conformance.py
RENAMED
|
@@ -48,6 +48,8 @@ def _address():
|
|
|
48
48
|
class _RetryingWarehouse:
|
|
49
49
|
"""Connects in from_env and retries a refused connection: what the suite requires."""
|
|
50
50
|
|
|
51
|
+
drop_semantics = "late_binding"
|
|
52
|
+
|
|
51
53
|
def __init__(self, sock):
|
|
52
54
|
self._sock = sock
|
|
53
55
|
|
|
@@ -88,6 +90,10 @@ class _LazyWarehouse(_RetryingWarehouse):
|
|
|
88
90
|
return cls(None)
|
|
89
91
|
|
|
90
92
|
|
|
93
|
+
class _UndeclaredDropSemanticsWarehouse(_RetryingWarehouse):
|
|
94
|
+
drop_semantics = "tombstone"
|
|
95
|
+
|
|
96
|
+
|
|
91
97
|
def _from_env_of(adapter_cls, monkeypatch):
|
|
92
98
|
def build(host, port):
|
|
93
99
|
monkeypatch.setenv("REFERENCE_HOST", host)
|
|
@@ -122,6 +128,13 @@ def test_the_suite_catches_an_adapter_that_connects_lazily_without_retrying(
|
|
|
122
128
|
)
|
|
123
129
|
|
|
124
130
|
|
|
131
|
+
def test_the_suite_catches_an_adapter_with_an_unknown_drop_semantics(warehouse_address, monkeypatch):
|
|
132
|
+
with pytest.raises(AssertionError, match="tombstone"):
|
|
133
|
+
StartupConformance().test_declares_a_drop_semantics(
|
|
134
|
+
warehouse_address, _from_env_of(_UndeclaredDropSemanticsWarehouse, monkeypatch)
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
125
138
|
# --- the LateOpeningPort double itself ---------------------------------------
|
|
126
139
|
|
|
127
140
|
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"""Cross-language contract for one validation node's structured result.
|
|
2
|
-
|
|
3
|
-
validation_runner.py prints exactly one sentinel-framed block on stdout as its LAST
|
|
4
|
-
output. The k8s-controller extracts the block from the pod log, uploads the JSON to
|
|
5
|
-
S3, and surfaces it as run_results_uri. The remediation classifier reads status +
|
|
6
|
-
message deterministically, falling back to the text log when the block is absent.
|
|
7
|
-
|
|
8
|
-
status uses dbt's RunStatus vocabulary (success | error | fail | skipped).
|
|
9
|
-
"""
|
|
10
|
-
import json
|
|
11
|
-
|
|
12
|
-
SENTINEL_BEGIN = "===CONTINUO_VALIDATION_RESULT_BEGIN==="
|
|
13
|
-
SENTINEL_END = "===CONTINUO_VALIDATION_RESULT_END==="
|
|
14
|
-
|
|
15
|
-
SCHEMA_VERSION = 1
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def result_block(status: str, message: str = "", failures: int = 0, unique_id: str = "") -> str:
|
|
19
|
-
"""Return the sentinel-framed, single-line-JSON block for one node.
|
|
20
|
-
|
|
21
|
-
The JSON is compact (no embedded newlines) so the consumer can split the
|
|
22
|
-
block out of a multi-line pod log by marker lines alone.
|
|
23
|
-
"""
|
|
24
|
-
body = json.dumps(
|
|
25
|
-
{
|
|
26
|
-
"schema_version": SCHEMA_VERSION,
|
|
27
|
-
"status": status,
|
|
28
|
-
"message": message or "",
|
|
29
|
-
"failures": int(failures or 0),
|
|
30
|
-
"unique_id": unique_id or "",
|
|
31
|
-
},
|
|
32
|
-
separators=(",", ":"),
|
|
33
|
-
)
|
|
34
|
-
return f"{SENTINEL_BEGIN}\n{body}\n{SENTINEL_END}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/keys.py
RENAMED
|
File without changes
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/sql.py
RENAMED
|
File without changes
|
|
File without changes
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/continuo_engine_contract/types.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_contract_keys.py
RENAMED
|
File without changes
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_contract_packaging.py
RENAMED
|
File without changes
|
{continuo_engine_contract-0.9.0 → continuo_engine_contract-0.11.0}/tests/test_contract_types.py
RENAMED
|
File without changes
|
|
File without changes
|