provium-cloud 0.1.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.
- provium_cloud-0.1.0/LICENSE +21 -0
- provium_cloud-0.1.0/MANIFEST.in +2 -0
- provium_cloud-0.1.0/PKG-INFO +111 -0
- provium_cloud-0.1.0/README.md +78 -0
- provium_cloud-0.1.0/infrastructure/__init__.py +1 -0
- provium_cloud-0.1.0/infrastructure/aws/Dockerfile +15 -0
- provium_cloud-0.1.0/infrastructure/aws/__init__.py +1 -0
- provium_cloud-0.1.0/infrastructure/aws/__main__.py +61 -0
- provium_cloud-0.1.0/infrastructure/aws/config.py +65 -0
- provium_cloud-0.1.0/infrastructure/aws/iam/permissions.json +394 -0
- provium_cloud-0.1.0/infrastructure/aws/iam/trust.json +12 -0
- provium_cloud-0.1.0/infrastructure/aws/image.py +107 -0
- provium_cloud-0.1.0/infrastructure/aws/lifecycle.py +301 -0
- provium_cloud-0.1.0/infrastructure/aws/requirements.txt +3 -0
- provium_cloud-0.1.0/infrastructure/aws/runtime/bootstrap.py +39 -0
- provium_cloud-0.1.0/infrastructure/aws/runtime/driver.py +36 -0
- provium_cloud-0.1.0/infrastructure/aws/runtime/live_test.py +167 -0
- provium_cloud-0.1.0/infrastructure/aws/stack.yaml +323 -0
- provium_cloud-0.1.0/infrastructure/pyrightconfig.json +6 -0
- provium_cloud-0.1.0/pyproject.toml +57 -0
- provium_cloud-0.1.0/setup.cfg +4 -0
- provium_cloud-0.1.0/src/provium_cloud/__init__.py +25 -0
- provium_cloud-0.1.0/src/provium_cloud/artifacts/__init__.py +33 -0
- provium_cloud-0.1.0/src/provium_cloud/artifacts/backends/__init__.py +1 -0
- provium_cloud-0.1.0/src/provium_cloud/artifacts/backends/file_s3.py +83 -0
- provium_cloud-0.1.0/src/provium_cloud/artifacts/interface.py +25 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/__init__.py +12 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/__init__.py +5 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/arguments.py +131 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/commands/__init__.py +1 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/commands/artifacts.py +43 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/commands/aws.py +47 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/commands/base.py +32 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/commands/execution.py +69 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/commands/invocations.py +42 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/commands/runs.py +99 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/aws/commands/validate.py +29 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/commands/__init__.py +1 -0
- provium_cloud-0.1.0/src/provium_cloud/cli/commands/cloud.py +15 -0
- provium_cloud-0.1.0/src/provium_cloud/client.py +169 -0
- provium_cloud-0.1.0/src/provium_cloud/deployment/__init__.py +19 -0
- provium_cloud-0.1.0/src/provium_cloud/deployment/config.py +98 -0
- provium_cloud-0.1.0/src/provium_cloud/deployment/loader.py +36 -0
- provium_cloud-0.1.0/src/provium_cloud/execution/__init__.py +1 -0
- provium_cloud-0.1.0/src/provium_cloud/execution/aws/__init__.py +1 -0
- provium_cloud-0.1.0/src/provium_cloud/execution/aws/batch.py +126 -0
- provium_cloud-0.1.0/src/provium_cloud/execution/controller.py +172 -0
- provium_cloud-0.1.0/src/provium_cloud/execution/interface.py +15 -0
- provium_cloud-0.1.0/src/provium_cloud/execution/worker.py +133 -0
- provium_cloud-0.1.0/src/provium_cloud/invocations/__init__.py +1 -0
- provium_cloud-0.1.0/src/provium_cloud/invocations/inputs.py +52 -0
- provium_cloud-0.1.0/src/provium_cloud/invocations/models.py +41 -0
- provium_cloud-0.1.0/src/provium_cloud/invocations/planning.py +176 -0
- provium_cloud-0.1.0/src/provium_cloud/py.typed +0 -0
- provium_cloud-0.1.0/src/provium_cloud/state/__init__.py +41 -0
- provium_cloud-0.1.0/src/provium_cloud/state/backends/__init__.py +1 -0
- provium_cloud-0.1.0/src/provium_cloud/state/backends/postgres.py +44 -0
- provium_cloud-0.1.0/src/provium_cloud/state/backends/sql.py +141 -0
- provium_cloud-0.1.0/src/provium_cloud/state/backends/sqlite.py +44 -0
- provium_cloud-0.1.0/src/provium_cloud/state/coordination.py +207 -0
- provium_cloud-0.1.0/src/provium_cloud/state/interface.py +40 -0
- provium_cloud-0.1.0/src/provium_cloud/state/jobs.py +109 -0
- provium_cloud-0.1.0/src/provium_cloud/state/models.py +108 -0
- provium_cloud-0.1.0/src/provium_cloud/state/runs.py +179 -0
- provium_cloud-0.1.0/src/provium_cloud.egg-info/PKG-INFO +111 -0
- provium_cloud-0.1.0/src/provium_cloud.egg-info/SOURCES.txt +94 -0
- provium_cloud-0.1.0/src/provium_cloud.egg-info/dependency_links.txt +1 -0
- provium_cloud-0.1.0/src/provium_cloud.egg-info/entry_points.txt +2 -0
- provium_cloud-0.1.0/src/provium_cloud.egg-info/requires.txt +22 -0
- provium_cloud-0.1.0/src/provium_cloud.egg-info/top_level.txt +1 -0
- provium_cloud-0.1.0/test/artifacts/test_store.py +69 -0
- provium_cloud-0.1.0/test/cli/test_commands.py +105 -0
- provium_cloud-0.1.0/test/cli/test_management.py +288 -0
- provium_cloud-0.1.0/test/cloud_fixtures.py +65 -0
- provium_cloud-0.1.0/test/conftest.py +51 -0
- provium_cloud-0.1.0/test/deployment/test_config.py +195 -0
- provium_cloud-0.1.0/test/deployment/test_loader.py +116 -0
- provium_cloud-0.1.0/test/execution/test_batch.py +198 -0
- provium_cloud-0.1.0/test/execution/test_runtime.py +392 -0
- provium_cloud-0.1.0/test/execution/test_services.py +70 -0
- provium_cloud-0.1.0/test/execution/test_worker.py +27 -0
- provium_cloud-0.1.0/test/infrastructure/test_configuration.py +111 -0
- provium_cloud-0.1.0/test/infrastructure/test_container.py +100 -0
- provium_cloud-0.1.0/test/infrastructure/test_documentation.py +62 -0
- provium_cloud-0.1.0/test/infrastructure/test_image.py +81 -0
- provium_cloud-0.1.0/test/infrastructure/test_lifecycle.py +359 -0
- provium_cloud-0.1.0/test/infrastructure/test_template.py +57 -0
- provium_cloud-0.1.0/test/infrastructure/test_workflow.py +168 -0
- provium_cloud-0.1.0/test/invocations/test_planning.py +121 -0
- provium_cloud-0.1.0/test/procedures.py +115 -0
- provium_cloud-0.1.0/test/state/conftest.py +17 -0
- provium_cloud-0.1.0/test/state/test_backend.py +109 -0
- provium_cloud-0.1.0/test/state/test_coordination.py +216 -0
- provium_cloud-0.1.0/test/state/test_jobs.py +90 -0
- provium_cloud-0.1.0/test/test_client.py +80 -0
- provium_cloud-0.1.0/test/test_cloud_version.py +10 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David W. Ludwig II
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: provium-cloud
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cloud execution orchestration for Provium procedures and pipelines
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/Project-Provium/provium
|
|
7
|
+
Project-URL: Documentation, https://provium.dlii.tech
|
|
8
|
+
Project-URL: Issues, https://github.com/Project-Provium/provium/issues
|
|
9
|
+
Project-URL: Repository, https://github.com/Project-Provium/provium
|
|
10
|
+
Requires-Python: >=3.12
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: provium>=0.13.0
|
|
14
|
+
Requires-Dist: provium-pipeline>=2.3.0
|
|
15
|
+
Requires-Dist: pydantic<3,>=2.10
|
|
16
|
+
Requires-Dist: PyYAML>=6
|
|
17
|
+
Provides-Extra: aws
|
|
18
|
+
Requires-Dist: boto3>=1.35; extra == "aws"
|
|
19
|
+
Provides-Extra: postgres
|
|
20
|
+
Requires-Dist: psycopg[binary]>=3.2; extra == "postgres"
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
Requires-Dist: pytest>=8.3; extra == "test"
|
|
23
|
+
Requires-Dist: pytest-cov>=6; extra == "test"
|
|
24
|
+
Requires-Dist: ruff>=0.16; extra == "test"
|
|
25
|
+
Requires-Dist: pyright>=1.1.411; extra == "test"
|
|
26
|
+
Requires-Dist: build>=1.2; extra == "test"
|
|
27
|
+
Requires-Dist: types-PyYAML>=6; extra == "test"
|
|
28
|
+
Requires-Dist: boto3>=1.35; extra == "test"
|
|
29
|
+
Requires-Dist: psycopg[binary]>=3.2; extra == "test"
|
|
30
|
+
Requires-Dist: testcontainers[localstack,postgres]<5,>=4.14; extra == "test"
|
|
31
|
+
Requires-Dist: python-dotenv<2,>=1; extra == "test"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# Provium Cloud
|
|
35
|
+
|
|
36
|
+
`provium-cloud` schedules procedure and unnamed pipeline invocations on AWS Batch.
|
|
37
|
+
It provides a Python client and native `provium cloud aws` commands, durable run
|
|
38
|
+
history and progress, shared computation deduplication, forced execution, and
|
|
39
|
+
pluggable state/artifact backends. It depends on `provium-pipeline` and has no
|
|
40
|
+
`provium-dispatch` dependency.
|
|
41
|
+
|
|
42
|
+
The runtime uses existing infrastructure. Deployment files are plain configuration;
|
|
43
|
+
they have no name or registration step. A separate repository-only AWS harness can
|
|
44
|
+
provision a disposable test environment, build/push an ECR image, test it, and tear
|
|
45
|
+
it down.
|
|
46
|
+
|
|
47
|
+
## Install and use
|
|
48
|
+
|
|
49
|
+
Python 3.12+ is required. Install from PyPI with the AWS and PostgreSQL backends:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
python -m pip install 'provium-cloud[aws,postgres]'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
For development, install the workspace packages from the repository root:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
python -m pip install -e ./packages/provium \
|
|
59
|
+
-e ./packages/provium-pipeline \
|
|
60
|
+
-e './packages/provium-cloud[aws,postgres]'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Install your procedure/artifact packages in both the submitting environment and
|
|
64
|
+
worker image. For an existing configured deployment:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
provium cloud aws plan -d deployment.yaml -f pipeline.yaml
|
|
68
|
+
provium cloud aws enqueue -d deployment.yaml -f pipeline.yaml \
|
|
69
|
+
--input document=document.pa
|
|
70
|
+
# Run in a separate process with access to the same backends:
|
|
71
|
+
provium cloud aws controller -d deployment.yaml
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Enqueueing records work; a running controller schedules it. PostgreSQL coordinates
|
|
75
|
+
distributed execution and S3 stores artifact bodies. SQLite and local files are
|
|
76
|
+
also supplied for local use. The package exports `CloudClient`, deployment models,
|
|
77
|
+
`load_deployment`, and `__version__`.
|
|
78
|
+
|
|
79
|
+
- [Cloud execution guide](https://project-provium.github.io/provium/guides/cloud/):
|
|
80
|
+
deployment/graph examples, CLI and Python usage, progress, retries, and guarantees.
|
|
81
|
+
- [API reference](https://project-provium.github.io/provium/reference/provium-cloud/):
|
|
82
|
+
client, planning, controller/worker, and custom backend contracts.
|
|
83
|
+
- [AWS testing guide](https://project-provium.github.io/provium/guides/cloud-testing/):
|
|
84
|
+
profiles, IAM setup, dotenv layers, local/CI tests, reports, and cleanup recovery.
|
|
85
|
+
|
|
86
|
+
## Development and live testing
|
|
87
|
+
|
|
88
|
+
From the repository root, `make install` installs development dependencies. Run
|
|
89
|
+
`python -m pytest packages/provium-cloud/test`; Docker is required for the PostgreSQL
|
|
90
|
+
and LocalStack integration tests. Add `-m 'not integration'` to exclude those tests.
|
|
91
|
+
These commands do not provision real AWS resources.
|
|
92
|
+
|
|
93
|
+
For paid live tests, configure root `.env` using `.env.example` and follow the AWS
|
|
94
|
+
testing guide's credential/service-role requirements:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
make cloud-live-install
|
|
98
|
+
make cloud-live-test
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Environment precedence is shell, explicit `CLOUD_ENV`/`--env-file`, `.env.local`,
|
|
102
|
+
then `.env`. This loading is specific to the test harness. Recovery uses the
|
|
103
|
+
original run's printed results directory:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
make cloud-live-cleanup CLOUD_RESULTS=/absolute/path/to/run
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The optional `.github/workflows/cloud-live.yml` uses OIDC and explicit repository
|
|
110
|
+
variable opt-in. Keep the local journal until cleanup is confirmed; a hard process
|
|
111
|
+
or runner failure can leave resources that require recovery.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Provium Cloud
|
|
2
|
+
|
|
3
|
+
`provium-cloud` schedules procedure and unnamed pipeline invocations on AWS Batch.
|
|
4
|
+
It provides a Python client and native `provium cloud aws` commands, durable run
|
|
5
|
+
history and progress, shared computation deduplication, forced execution, and
|
|
6
|
+
pluggable state/artifact backends. It depends on `provium-pipeline` and has no
|
|
7
|
+
`provium-dispatch` dependency.
|
|
8
|
+
|
|
9
|
+
The runtime uses existing infrastructure. Deployment files are plain configuration;
|
|
10
|
+
they have no name or registration step. A separate repository-only AWS harness can
|
|
11
|
+
provision a disposable test environment, build/push an ECR image, test it, and tear
|
|
12
|
+
it down.
|
|
13
|
+
|
|
14
|
+
## Install and use
|
|
15
|
+
|
|
16
|
+
Python 3.12+ is required. Install from PyPI with the AWS and PostgreSQL backends:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
python -m pip install 'provium-cloud[aws,postgres]'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For development, install the workspace packages from the repository root:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python -m pip install -e ./packages/provium \
|
|
26
|
+
-e ./packages/provium-pipeline \
|
|
27
|
+
-e './packages/provium-cloud[aws,postgres]'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Install your procedure/artifact packages in both the submitting environment and
|
|
31
|
+
worker image. For an existing configured deployment:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
provium cloud aws plan -d deployment.yaml -f pipeline.yaml
|
|
35
|
+
provium cloud aws enqueue -d deployment.yaml -f pipeline.yaml \
|
|
36
|
+
--input document=document.pa
|
|
37
|
+
# Run in a separate process with access to the same backends:
|
|
38
|
+
provium cloud aws controller -d deployment.yaml
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Enqueueing records work; a running controller schedules it. PostgreSQL coordinates
|
|
42
|
+
distributed execution and S3 stores artifact bodies. SQLite and local files are
|
|
43
|
+
also supplied for local use. The package exports `CloudClient`, deployment models,
|
|
44
|
+
`load_deployment`, and `__version__`.
|
|
45
|
+
|
|
46
|
+
- [Cloud execution guide](https://project-provium.github.io/provium/guides/cloud/):
|
|
47
|
+
deployment/graph examples, CLI and Python usage, progress, retries, and guarantees.
|
|
48
|
+
- [API reference](https://project-provium.github.io/provium/reference/provium-cloud/):
|
|
49
|
+
client, planning, controller/worker, and custom backend contracts.
|
|
50
|
+
- [AWS testing guide](https://project-provium.github.io/provium/guides/cloud-testing/):
|
|
51
|
+
profiles, IAM setup, dotenv layers, local/CI tests, reports, and cleanup recovery.
|
|
52
|
+
|
|
53
|
+
## Development and live testing
|
|
54
|
+
|
|
55
|
+
From the repository root, `make install` installs development dependencies. Run
|
|
56
|
+
`python -m pytest packages/provium-cloud/test`; Docker is required for the PostgreSQL
|
|
57
|
+
and LocalStack integration tests. Add `-m 'not integration'` to exclude those tests.
|
|
58
|
+
These commands do not provision real AWS resources.
|
|
59
|
+
|
|
60
|
+
For paid live tests, configure root `.env` using `.env.example` and follow the AWS
|
|
61
|
+
testing guide's credential/service-role requirements:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
make cloud-live-install
|
|
65
|
+
make cloud-live-test
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Environment precedence is shell, explicit `CLOUD_ENV`/`--env-file`, `.env.local`,
|
|
69
|
+
then `.env`. This loading is specific to the test harness. Recovery uses the
|
|
70
|
+
original run's printed results directory:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
make cloud-live-cleanup CLOUD_RESULTS=/absolute/path/to/run
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The optional `.github/workflows/cloud-live.yml` uses OIDC and explicit repository
|
|
77
|
+
variable opt-in. Keep the local journal until cleanup is confirmed; a hard process
|
|
78
|
+
or runner failure can leave resources that require recovery.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Repository-only infrastructure for testing; not part of provium-cloud."""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
FROM python:3.12-slim
|
|
2
|
+
WORKDIR /opt/workspace
|
|
3
|
+
COPY packages/ packages/
|
|
4
|
+
COPY examples/ examples/
|
|
5
|
+
RUN python -m pip install --no-cache-dir \
|
|
6
|
+
./packages/provium ./packages/provium-pipeline \
|
|
7
|
+
'./packages/provium-cloud[aws,postgres]' ./examples/provium-text-pipeline \
|
|
8
|
+
'pytest>=8.3,<10'
|
|
9
|
+
COPY runtime/ /opt/cloud-tests/
|
|
10
|
+
RUN useradd --create-home --uid 10001 cloudtest
|
|
11
|
+
USER cloudtest
|
|
12
|
+
WORKDIR /tmp
|
|
13
|
+
ENV PYTHONUNBUFFERED=1
|
|
14
|
+
ENTRYPOINT ["python", "/opt/cloud-tests/bootstrap.py"]
|
|
15
|
+
CMD ["provium", "--help"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Disposable AWS integration-test environment."""
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Run from the package directory: python -m infrastructure.aws run."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import signal
|
|
5
|
+
import subprocess
|
|
6
|
+
import uuid
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from types import FrameType
|
|
9
|
+
|
|
10
|
+
from .config import ROOT, Settings, load_environment
|
|
11
|
+
from .lifecycle import Environment
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def interrupted(signum: int, frame: FrameType | None) -> None:
|
|
15
|
+
# Allow the first signal to enter finally; repeated signals must not skip cleanup.
|
|
16
|
+
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
|
17
|
+
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
|
18
|
+
raise KeyboardInterrupt("Interrupted; cleaning up AWS test resources.")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def main(arguments: list[str] | None = None) -> None:
|
|
22
|
+
parser = argparse.ArgumentParser(description="Disposable provium-cloud AWS tests")
|
|
23
|
+
parser.add_argument("action", choices=("run", "cleanup"))
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"--env-file",
|
|
26
|
+
type=Path,
|
|
27
|
+
help="Override root .env and .env.local; shell environment wins",
|
|
28
|
+
)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--results", type=Path, help="Run journal and test reports directory"
|
|
31
|
+
)
|
|
32
|
+
args = parser.parse_args(arguments)
|
|
33
|
+
if args.action == "cleanup" and args.results is None:
|
|
34
|
+
parser.error("cleanup requires --results from the original run")
|
|
35
|
+
load_environment(args.env_file)
|
|
36
|
+
directory = args.results or ROOT / ".cloud-live" / uuid.uuid4().hex[:12]
|
|
37
|
+
print(f"Results and recovery journal: {directory.resolve()}", flush=True)
|
|
38
|
+
if args.action == "run":
|
|
39
|
+
settings = Settings.from_environment()
|
|
40
|
+
subprocess.run(
|
|
41
|
+
["docker", "info"], check=True, stdout=subprocess.DEVNULL, timeout=15
|
|
42
|
+
)
|
|
43
|
+
environment = Environment(settings, directory)
|
|
44
|
+
else:
|
|
45
|
+
environment = Environment.resume(directory)
|
|
46
|
+
previous = {
|
|
47
|
+
sig: signal.signal(sig, interrupted) for sig in (signal.SIGTERM, signal.SIGINT)
|
|
48
|
+
}
|
|
49
|
+
try:
|
|
50
|
+
if args.action == "run":
|
|
51
|
+
environment.run()
|
|
52
|
+
else:
|
|
53
|
+
environment.cleanup()
|
|
54
|
+
finally:
|
|
55
|
+
for sig, handler in previous.items():
|
|
56
|
+
signal.signal(sig, handler)
|
|
57
|
+
print("AWS test resources deleted.", flush=True)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
main()
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Local and CI configuration for disposable AWS tests."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import re
|
|
5
|
+
from collections.abc import Mapping
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from dotenv import dotenv_values
|
|
10
|
+
|
|
11
|
+
ROOT = Path(__file__).resolve().parents[4]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def load_environment(path: Path | None = None) -> None:
|
|
15
|
+
"""Load root .env, .env.local, then an explicit file; the shell wins."""
|
|
16
|
+
if path is not None and not path.is_file():
|
|
17
|
+
raise FileNotFoundError(path)
|
|
18
|
+
files = [ROOT / ".env", ROOT / ".env.local"]
|
|
19
|
+
if path is not None:
|
|
20
|
+
files.append(path)
|
|
21
|
+
values: dict[str, str] = {}
|
|
22
|
+
for file in files:
|
|
23
|
+
if file.exists():
|
|
24
|
+
with file.open(encoding="utf-8") as stream:
|
|
25
|
+
values.update(
|
|
26
|
+
{
|
|
27
|
+
key: value
|
|
28
|
+
for key, value in dotenv_values(
|
|
29
|
+
stream=stream, interpolate=False
|
|
30
|
+
).items()
|
|
31
|
+
if value is not None
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
for key, value in values.items():
|
|
35
|
+
os.environ.setdefault(key, value)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True)
|
|
39
|
+
class Settings:
|
|
40
|
+
region: str
|
|
41
|
+
account_id: str
|
|
42
|
+
role_arn: str
|
|
43
|
+
stack_prefix: str = "provium-cloud-test"
|
|
44
|
+
test_timeout: int = 1800
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def from_environment(cls, env: Mapping[str, str] = os.environ) -> "Settings":
|
|
48
|
+
region = env.get("AWS_REGION") or env.get("AWS_DEFAULT_REGION", "")
|
|
49
|
+
account = env.get("PROVIUM_CLOUD_TEST_ACCOUNT_ID", "")
|
|
50
|
+
role = env.get("CLOUDFORMATION_ROLE_ARN", "")
|
|
51
|
+
prefix = env.get("PROVIUM_CLOUD_TEST_STACK_PREFIX", "provium-cloud-test")
|
|
52
|
+
timeout = int(env.get("PROVIUM_CLOUD_TEST_TIMEOUT", "1800"))
|
|
53
|
+
if not re.fullmatch(r"[a-z]{2}-[a-z]+-\d", region):
|
|
54
|
+
raise ValueError("Set AWS_REGION or AWS_DEFAULT_REGION (commercial AWS).")
|
|
55
|
+
if not re.fullmatch(r"\d{12}", account):
|
|
56
|
+
raise ValueError(
|
|
57
|
+
"Set PROVIUM_CLOUD_TEST_ACCOUNT_ID to the test account ID."
|
|
58
|
+
)
|
|
59
|
+
if not re.fullmatch(rf"arn:aws:iam::{account}:role/[\w+=,.@/-]+", role):
|
|
60
|
+
raise ValueError("CLOUDFORMATION_ROLE_ARN must belong to the test account.")
|
|
61
|
+
if not re.fullmatch(r"[a-zA-Z][a-zA-Z0-9-]{0,47}", prefix):
|
|
62
|
+
raise ValueError("Stack prefix must be 1–48 letters, numbers, or hyphens.")
|
|
63
|
+
if not 60 <= timeout <= 3600:
|
|
64
|
+
raise ValueError("Test timeout must be between 60 and 3600 seconds.")
|
|
65
|
+
return cls(region, account, role, prefix, timeout)
|