uber-compose 3.0.0a2__tar.gz → 3.0.0a8__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.
- uber_compose-3.0.0a8/MANIFEST.in +4 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/PKG-INFO +2 -2
- uber_compose-3.0.0a8/docs/CLI_USAGE.md +423 -0
- uber_compose-3.0.0a8/docs/E2E_CONTAINER_SETUP.md +170 -0
- uber_compose-3.0.0a8/docs/HOOKS.md +35 -0
- uber_compose-3.0.0a8/docs/LLM_RULES.md +40 -0
- uber_compose-3.0.0a8/docs/PARALLELISM.md +495 -0
- uber_compose-3.0.0a8/docs/PLAN_CONSISTENCY.md +392 -0
- uber_compose-3.0.0a8/docs/README.md +9 -0
- uber_compose-3.0.0a8/docs/RELEASE_TAGS.md +85 -0
- uber_compose-3.0.0a8/docs/UBER_COMPOSE_VEDRO_CONFIG.md +68 -0
- uber_compose-3.0.0a8/docs/X_MIGRATION.md +192 -0
- uber_compose-3.0.0a8/docs/common.puml +24 -0
- uber_compose-3.0.0a8/requirements.txt +4 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/setup.py +14 -1
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/__init__.py +3 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/constants.py +7 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/docker_compose.py +3 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/sequence_run_types.py +1 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/utils/compose_files.py +191 -31
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/utils/compose_instance_cfg.py +3 -1
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/env_description/env_tools.py +4 -2
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/env_description/env_types.py +4 -1
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/current_env.py +36 -2
- uber_compose-3.0.0a8/uber_compose/parallel_plugin/planner.py +407 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/plugin.py +2 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/worker_api.py +17 -3
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/uber_compose.py +16 -1
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/vedro_plugin/plugin.py +56 -3
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose.egg-info/PKG-INFO +2 -2
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose.egg-info/SOURCES.txt +14 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose.egg-info/requires.txt +1 -1
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/LICENSE +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/README.md +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/setup.cfg +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/docker_compose_shell/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/docker_compose_shell/interface.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/docker_compose_shell/types.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/system_docker_compose.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/utils/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/utils/env_files.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/utils/process_command_output.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/utils/shell_process.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/core/utils/state_waiting.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/env_description/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/errors/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/errors/migrations.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/errors/up.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/broken_services.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/bytes_pickle.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/countdown_counter.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/env_id.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/exec_record.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/exec_result.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/health_policy.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/hooks.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/jobs_result.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/labels.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/parameterization.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/singleton.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/state_keeper.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/helpers/workers_per_env.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/output/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/output/console.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/output/styles.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/details.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/grouper.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/grouping.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/runner.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/types.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/parallel_plugin/worker_filter.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/utils/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/utils/docker_compose_files_path.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/utils/docker_compose_service_deps.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/utils/search_docker_compose_files.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/utils/services_construction.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/vedro_plugin/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/vedro_plugin/base_structures/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/vedro_plugin/base_structures/common_json_cli.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/vedro_plugin/helpers/__init__.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/vedro_plugin/helpers/scenario_ordering.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/vedro_plugin/helpers/scenario_tag_processing.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/vedro_plugin/helpers/test_env_vars_setter.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/version +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose/version.py +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose.egg-info/dependency_links.txt +0 -0
- {uber_compose-3.0.0a2 → uber_compose-3.0.0a8}/uber_compose.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uber-compose
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.0a8
|
|
4
4
|
Summary: docker compose testing env orchestrator
|
|
5
5
|
Home-page: https://github.com/ko10ok/uber-compose
|
|
6
6
|
Author: Yuriy Sagitov
|
|
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
15
15
|
Requires-Python: >=3.10.0
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: vedro<2.0,>=1.
|
|
18
|
+
Requires-Dist: vedro<2.0,>=1.15
|
|
19
19
|
Requires-Dist: PyYAML<6.1,>=6.0.1
|
|
20
20
|
Requires-Dist: rtry<2.0,>=1.4.0
|
|
21
21
|
Requires-Dist: rich<16.0,>=11.0
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# CommonJsonCli Usage Guide
|
|
2
|
+
|
|
3
|
+
`CommonJsonCli` is a client for executing commands in Docker containers with automatic JSON log parsing and error handling.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Basic Usage](#basic-usage)
|
|
7
|
+
- [Extended Command Result](#extended-command-result)
|
|
8
|
+
- [Custom JSON Parser](#custom-json-parser)
|
|
9
|
+
- [CommandResult](#commandresult)
|
|
10
|
+
- [JsonParser Configuration](#jsonparser-configuration)
|
|
11
|
+
- [ExecLifeCyclePolicy](#execlifecyclepolicy)
|
|
12
|
+
- [Timeouts Redefinition](#timeouts-redefinition)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Basic Usage
|
|
17
|
+
|
|
18
|
+
Create a CLI client by inheriting from `CommonJsonCli`:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from uber_compose import CommonJsonCli, CommandResult
|
|
22
|
+
|
|
23
|
+
class MyCli(CommonJsonCli):
|
|
24
|
+
def __init__(self):
|
|
25
|
+
self.container = 'app_container'
|
|
26
|
+
super().__init__()
|
|
27
|
+
|
|
28
|
+
async def run_command(self) -> CommandResult:
|
|
29
|
+
return await self.exec(
|
|
30
|
+
container=self.container,
|
|
31
|
+
command='my-app --option value',
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Usage
|
|
35
|
+
cli = MyCli()
|
|
36
|
+
result = await cli.run_command()
|
|
37
|
+
|
|
38
|
+
# Access results
|
|
39
|
+
print(result.stdout) # list of parsed JSON logs or strings
|
|
40
|
+
print(result.stderr) # list of error logs
|
|
41
|
+
print(result.has_no_errors()) # True if no errors
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### With Environment Variables
|
|
45
|
+
|
|
46
|
+
By default, any executed command uses env variables set in container.
|
|
47
|
+
You can override it by adding extra environment variables via extra_env.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
async def run_with_env(self) -> CommandResult:
|
|
51
|
+
return await self.exec(
|
|
52
|
+
container='app_container',
|
|
53
|
+
command='my-app',
|
|
54
|
+
extra_env={'DEBUG': 'true', 'LOG_LEVEL': 'debug'}
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### Setup Container For All Commands
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from uber_compose import CommonJsonCli, CommandResult
|
|
64
|
+
|
|
65
|
+
class MyCli(CommonJsonCli):
|
|
66
|
+
def __init__(self):
|
|
67
|
+
super().__init__(container = 'app_container')
|
|
68
|
+
|
|
69
|
+
async def run_command(self) -> CommandResult:
|
|
70
|
+
return await self.exec(command='my-app --option value')
|
|
71
|
+
|
|
72
|
+
async def run_another_command(self) -> CommandResult:
|
|
73
|
+
return await self.exec(command='my-app-another-part --any-option value2')
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Extended Command Result
|
|
78
|
+
|
|
79
|
+
Extend `CommandResult` to add custom fields:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from dataclasses import dataclass
|
|
83
|
+
from uber_compose import CommonJsonCli, CommandResult
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class ExtendedCommandResult(CommandResult):
|
|
87
|
+
config_data: dict = None
|
|
88
|
+
metadata: str = ""
|
|
89
|
+
|
|
90
|
+
class MyCli(CommonJsonCli[ExtendedCommandResult]):
|
|
91
|
+
def __init__(self):
|
|
92
|
+
self.container = 'app_container'
|
|
93
|
+
super().__init__(result_factory=ExtendedCommandResult)
|
|
94
|
+
|
|
95
|
+
async def run_with_config(self, config: dict) -> ExtendedCommandResult:
|
|
96
|
+
return await self.exec(
|
|
97
|
+
container=self.container,
|
|
98
|
+
command='my-app',
|
|
99
|
+
command_result_extra={
|
|
100
|
+
'config_data': config,
|
|
101
|
+
'metadata': 'custom_metadata'
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Usage
|
|
106
|
+
cli = MyCli()
|
|
107
|
+
result = await cli.run_with_config({'key': 'value'})
|
|
108
|
+
|
|
109
|
+
# Access extended fields
|
|
110
|
+
print(result.config_data) # {'key': 'value'}
|
|
111
|
+
print(result.metadata) # 'custom_metadata'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Custom JSON Parser
|
|
117
|
+
|
|
118
|
+
Configure JSON parsing behavior with `JsonParser`:
|
|
119
|
+
|
|
120
|
+
### String Output (default)
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from uber_compose import CommonJsonCli, JsonParser
|
|
124
|
+
|
|
125
|
+
parser = JsonParser()
|
|
126
|
+
cli = CommonJsonCli(parse_json_logs=parser.parse_output_to_json)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Output example:
|
|
130
|
+
```python
|
|
131
|
+
result.stdout = [
|
|
132
|
+
'{"level": "info", "msg": "Started"}',
|
|
133
|
+
'{"level": "debug", "msg": "Processing"}'
|
|
134
|
+
]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Dictionary Output
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
parser = JsonParser(dict_output=True)
|
|
141
|
+
cli = CommonJsonCli(parse_json_logs=parser.parse_output_to_json)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Output example:
|
|
145
|
+
```python
|
|
146
|
+
result.stdout = [
|
|
147
|
+
{'level': 'info', 'msg': 'Started'},
|
|
148
|
+
{'level': 'debug', 'msg': 'Processing'}
|
|
149
|
+
]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Custom Error Levels
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
parser = JsonParser(
|
|
156
|
+
stderr_log_levels=['error', 'fatal', 'critical']
|
|
157
|
+
)
|
|
158
|
+
cli = CommonJsonCli(parse_json_logs=parser.parse_output_to_json)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Skip Log Lines
|
|
162
|
+
|
|
163
|
+
Skip logs by substring or regex pattern:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
parser = JsonParser(
|
|
167
|
+
skips=['debug_info', r'^\[TRACE\]'],
|
|
168
|
+
skips_warns=True # Warn when skipping
|
|
169
|
+
)
|
|
170
|
+
cli = CommonJsonCli(parse_json_logs=parser.parse_output_to_json)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Skipped logs appear in `stdout` as raw strings (or `{'raw': 'log_line'}` with `dict_output=True`).
|
|
174
|
+
|
|
175
|
+
### Full Stdout Control
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
# Default: errors appear in both stdout and stderr
|
|
179
|
+
parser = JsonParser(full_stdout=True)
|
|
180
|
+
|
|
181
|
+
# Errors only in stderr
|
|
182
|
+
parser = JsonParser(full_stdout=False)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Custom Log Level Key
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
# Default key is 'level'
|
|
189
|
+
parser = JsonParser(log_level_key='severity')
|
|
190
|
+
|
|
191
|
+
# For logs like: {"severity": "error", "msg": "Failed"}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Combined Configuration
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
parser = JsonParser(
|
|
198
|
+
log_level_key='level',
|
|
199
|
+
stderr_log_levels=['error', 'fatal', 'panic'],
|
|
200
|
+
full_stdout=True,
|
|
201
|
+
dict_output=True,
|
|
202
|
+
skips=['debug_verbose', r'^\[INTERNAL\]'],
|
|
203
|
+
skips_warns=False
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
cli = CommonJsonCli(parse_json_logs=parser.parse_output_to_json)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## CommandResult
|
|
212
|
+
|
|
213
|
+
### Fields
|
|
214
|
+
|
|
215
|
+
- **`stdout`**: `list[str | dict]` - Parsed output logs
|
|
216
|
+
- **`stderr`**: `list[str | dict]` - Error logs (based on log level)
|
|
217
|
+
- **`cmd`**: `str` - Executed command
|
|
218
|
+
- **`env`**: `dict[str, str]` - Environment variables used
|
|
219
|
+
|
|
220
|
+
### Methods
|
|
221
|
+
|
|
222
|
+
- **`has_no_errors()`**: Returns `True` if `stderr` is empty
|
|
223
|
+
|
|
224
|
+
### Example
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
result = await cli.exec(container='app', command='my-cmd')
|
|
228
|
+
|
|
229
|
+
if result.has_no_errors():
|
|
230
|
+
print("Success!")
|
|
231
|
+
for log in result.stdout:
|
|
232
|
+
print(log)
|
|
233
|
+
else:
|
|
234
|
+
print("Errors occurred:")
|
|
235
|
+
for error in result.stderr:
|
|
236
|
+
print(error)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## JsonParser Configuration
|
|
242
|
+
|
|
243
|
+
### Parameters
|
|
244
|
+
|
|
245
|
+
| Parameter | Type | Default | Description |
|
|
246
|
+
|-----------|------|---------|-------------|
|
|
247
|
+
| `log_level_key` | `str \| list[str]` | `'level'` | Key name for log level in JSON |
|
|
248
|
+
| `stderr_log_levels` | `list[str]` | `['panic', 'fatal', 'error', 'warning']` | Log levels to route to stderr |
|
|
249
|
+
| `full_stdout` | `bool` | `True` | Include errors in stdout |
|
|
250
|
+
| `dict_output` | `bool` | `False` | Output as dicts instead of strings |
|
|
251
|
+
| `skips` | `list[str]` | `[]` | Patterns to skip (substring or regex) |
|
|
252
|
+
| `skips_warns` | `bool` | `False` | Warn when skipping logs |
|
|
253
|
+
|
|
254
|
+
### Log Levels
|
|
255
|
+
|
|
256
|
+
Predefined in `LogLevels` class:
|
|
257
|
+
- `TRACE`, `DEBUG`, `INFO`, `WARNING`, `ERROR`, `FATAL`, `PANIC`
|
|
258
|
+
|
|
259
|
+
### Non-JSON Logs
|
|
260
|
+
|
|
261
|
+
Non-JSON lines are treated as errors and:
|
|
262
|
+
- Added to `stderr`
|
|
263
|
+
- Optionally added to `stdout` (if `full_stdout=True`)
|
|
264
|
+
- Formatted as raw strings or `{'raw': 'line'}` (if `dict_output=True`)
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Complete Example
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
import time
|
|
272
|
+
|
|
273
|
+
from dataclasses import dataclass
|
|
274
|
+
from uber_compose import CommonJsonCli, CommandResult, JsonParser
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@dataclass
|
|
278
|
+
class MyCommandResult(CommandResult):
|
|
279
|
+
start_time: float = 0.0
|
|
280
|
+
|
|
281
|
+
class AppCli(CommonJsonCli[MyCommandResult]):
|
|
282
|
+
def __init__(self):
|
|
283
|
+
# Configure parser
|
|
284
|
+
parser = JsonParser(
|
|
285
|
+
dict_output=True,
|
|
286
|
+
stderr_log_levels=['error', 'fatal'],
|
|
287
|
+
skips=[r'health_check']
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
super().__init__(
|
|
291
|
+
container = 'my_app',
|
|
292
|
+
parse_json_logs=parser.parse_output_to_json,
|
|
293
|
+
result_factory=MyCommandResult
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
async def process_data(self, data_path: str) -> MyCommandResult:
|
|
297
|
+
result = await self.exec(
|
|
298
|
+
command=f'process --file {data_path}',
|
|
299
|
+
extra_env={'LOG_FORMAT': 'json'},
|
|
300
|
+
command_result_extra={
|
|
301
|
+
'start_time': time.time()
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
return result
|
|
306
|
+
|
|
307
|
+
# Usage
|
|
308
|
+
cli = AppCli()
|
|
309
|
+
result = await cli.process_data('/data/input.csv')
|
|
310
|
+
|
|
311
|
+
assert result.has_no_errors()
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## ExecLifeCyclePolicy
|
|
315
|
+
|
|
316
|
+
`ExecLifeCyclePolicy` controls the execution behavior of commands to optimize performance and resource usage. It allows you to skip certain phases of the command execution lifecycle.
|
|
317
|
+
|
|
318
|
+
### Parameters
|
|
319
|
+
|
|
320
|
+
| Parameter | Type | Default | Description |
|
|
321
|
+
|-----------|------|---------|-------------|
|
|
322
|
+
| `kill_before_same_old_command_running` | `bool` | `True` | Kill the previous instance of the same command if it is still running before executing a new one |
|
|
323
|
+
| `kill_after_command_still_running` | `bool` | `True` | Kill the command if it is still running after the timeout has elapsed |
|
|
324
|
+
| `break_on_timeout` | `bool` | `True` | Stop waiting and return early if the timeout is reached |
|
|
325
|
+
|
|
326
|
+
### Basic Usage
|
|
327
|
+
|
|
328
|
+
```python
|
|
329
|
+
from uber_compose import CommonJsonCli, ExecLifeCyclePolicy
|
|
330
|
+
|
|
331
|
+
class AppCli(CommonJsonCli):
|
|
332
|
+
def __init__(self):
|
|
333
|
+
super().__init__(
|
|
334
|
+
container='app',
|
|
335
|
+
life_cycle_policy=ExecLifeCyclePolicy(
|
|
336
|
+
kill_before_same_old_command_running=True,
|
|
337
|
+
kill_after_command_still_running=True,
|
|
338
|
+
break_on_timeout=True
|
|
339
|
+
)
|
|
340
|
+
)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Override Policy Per Command
|
|
344
|
+
|
|
345
|
+
```python
|
|
346
|
+
from uber_compose import CommonJsonCli, CommandResult, ExecLifeCyclePolicy
|
|
347
|
+
|
|
348
|
+
class AppCli(CommonJsonCli):
|
|
349
|
+
def __init__(self):
|
|
350
|
+
super().__init__(container='app')
|
|
351
|
+
|
|
352
|
+
async def run_quick_command(self) -> CommandResult:
|
|
353
|
+
return await self.exec(
|
|
354
|
+
command='quick-task',
|
|
355
|
+
life_cycle_policy=ExecLifeCyclePolicy(
|
|
356
|
+
kill_before_same_old_command_running=False,
|
|
357
|
+
kill_after_command_still_running=False,
|
|
358
|
+
)
|
|
359
|
+
)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Disable Lifecycle Management
|
|
363
|
+
|
|
364
|
+
```python
|
|
365
|
+
# Disable killing old instances
|
|
366
|
+
policy = ExecLifeCyclePolicy(kill_before_same_old_command_running=False)
|
|
367
|
+
|
|
368
|
+
# Disable all lifecycle management
|
|
369
|
+
policy = ExecLifeCyclePolicy(
|
|
370
|
+
kill_before_same_old_command_running=False,
|
|
371
|
+
kill_after_command_still_running=False,
|
|
372
|
+
break_on_timeout=False
|
|
373
|
+
)
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Timeouts Redefinition
|
|
377
|
+
|
|
378
|
+
By default `CommonJsonCli` uses the following timeouts for command execution:
|
|
379
|
+
|
|
380
|
+
```python
|
|
381
|
+
from uber_compose import TimeOutCheck
|
|
382
|
+
|
|
383
|
+
timeout = TimeOutCheck(
|
|
384
|
+
attempts=10,
|
|
385
|
+
delay_s=1
|
|
386
|
+
),
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
It's possible to redefine these timeouts in the `__init__` method of your CLI class:
|
|
390
|
+
|
|
391
|
+
```python
|
|
392
|
+
from uber_compose import CommonJsonCli, CommandResult, JsonParser, TimeOutCheck
|
|
393
|
+
|
|
394
|
+
class AppCli(CommonJsonCli):
|
|
395
|
+
def __init__(self):
|
|
396
|
+
super().__init__(
|
|
397
|
+
timeout = TimeOutCheck(
|
|
398
|
+
attempts=10,
|
|
399
|
+
delay_s=1
|
|
400
|
+
),
|
|
401
|
+
)
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Or redefine only for specific command:
|
|
405
|
+
|
|
406
|
+
```python
|
|
407
|
+
import time
|
|
408
|
+
|
|
409
|
+
from uber_compose import CommonJsonCli, CommandResult, JsonParser, TimeOutCheck
|
|
410
|
+
|
|
411
|
+
class AppCli(CommonJsonCli):
|
|
412
|
+
def __init__(self):
|
|
413
|
+
super().__init__(container='app')
|
|
414
|
+
|
|
415
|
+
async def run_command_with_custom_timeout(self) -> CommandResult:
|
|
416
|
+
return await self.exec(
|
|
417
|
+
command='command',
|
|
418
|
+
timeout = TimeOutCheck(
|
|
419
|
+
attempts=50,
|
|
420
|
+
delay_s=2
|
|
421
|
+
),
|
|
422
|
+
)
|
|
423
|
+
```
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# E2E Test Container Setup
|
|
2
|
+
|
|
3
|
+
This guide explains how to configure your test container for running E2E tests with Uber-Compose.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
Your test container needs Docker Compose CLI to manage services during testing.
|
|
8
|
+
|
|
9
|
+
## 1. Add Docker Compose CLI to Test Container
|
|
10
|
+
|
|
11
|
+
Add Docker Compose CLI to your test container's **Dockerfile**:
|
|
12
|
+
|
|
13
|
+
### Alpine
|
|
14
|
+
|
|
15
|
+
```dockerfile
|
|
16
|
+
RUN apk add docker-cli docker-cli-compose
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Debian/Ubuntu
|
|
20
|
+
|
|
21
|
+
```dockerfile
|
|
22
|
+
RUN apt install docker-ce-cli docker-compose-plugin
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Legacy docker-compose Binary (if needed)
|
|
26
|
+
|
|
27
|
+
```dockerfile
|
|
28
|
+
# For AMD64
|
|
29
|
+
RUN if [[ "$TARGETPLATFORM" = "linux/amd64" ]] ; then \
|
|
30
|
+
curl -SL https://github.com/docker/compose/releases/download/v2.24.4/docker-compose-linux-x86_64 \
|
|
31
|
+
-o /usr/local/bin/docker-compose ; fi
|
|
32
|
+
|
|
33
|
+
# For ARM64
|
|
34
|
+
RUN if [[ "$TARGETPLATFORM" = "linux/arm64" ]] ; then \
|
|
35
|
+
curl -SL https://github.com/docker/compose/releases/download/v2.24.4/docker-compose-linux-aarch64 \
|
|
36
|
+
-o /usr/local/bin/docker-compose ; fi
|
|
37
|
+
|
|
38
|
+
RUN chmod +x /usr/local/bin/docker-compose
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 2. Configure Test Container
|
|
42
|
+
|
|
43
|
+
Configure your test container in `docker-compose.yml`:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
services:
|
|
47
|
+
e2e-tests:
|
|
48
|
+
volumes:
|
|
49
|
+
- .:/project
|
|
50
|
+
environment:
|
|
51
|
+
# Docker daemon connection
|
|
52
|
+
- DOCKER_HOST=tcp://test-docker-daemon:2375 # Default: dockersock:2375
|
|
53
|
+
|
|
54
|
+
# Containers that should not be stopped by Uber-Compose
|
|
55
|
+
- NON_STOP_CONTAINERS=e2e-tests # Default: e2e,dockersock
|
|
56
|
+
|
|
57
|
+
# Project root directory on host machine
|
|
58
|
+
- HOST_PROJECT_ROOT_DIRECTORY=${PWD} # For project root or test directory
|
|
59
|
+
|
|
60
|
+
# Unique project name for CI isolation
|
|
61
|
+
- COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} # Setup unique name for CI runs
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Environment Variables
|
|
65
|
+
|
|
66
|
+
| Variable | Default | Description |
|
|
67
|
+
|----------|---------|-------------|
|
|
68
|
+
| `DOCKER_HOST` | `tcp://dockersock:2375` | Docker daemon connection URL |
|
|
69
|
+
| `NON_STOP_CONTAINERS` | `e2e,dockersock` | Containers excluded from management |
|
|
70
|
+
| `HOST_PROJECT_ROOT_DIRECTORY` | - | Path to docker-compose files on host |
|
|
71
|
+
| `COMPOSE_PROJECT_NAME` | - | Unique project identifier for CI |
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Example: Complete Setup
|
|
75
|
+
|
|
76
|
+
### Dockerfile
|
|
77
|
+
|
|
78
|
+
```dockerfile
|
|
79
|
+
FROM python:3.10-alpine
|
|
80
|
+
|
|
81
|
+
# Install Docker CLI and Compose
|
|
82
|
+
RUN apk add --no-cache docker-cli docker-cli-compose
|
|
83
|
+
|
|
84
|
+
# Install test dependencies
|
|
85
|
+
COPY requirements.txt .
|
|
86
|
+
RUN pip install -r requirements.txt
|
|
87
|
+
|
|
88
|
+
WORKDIR /project
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### docker-compose.yml
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
version: "3"
|
|
95
|
+
|
|
96
|
+
services:
|
|
97
|
+
dockersock:
|
|
98
|
+
image: docker:dind
|
|
99
|
+
privileged: true
|
|
100
|
+
environment:
|
|
101
|
+
- DOCKER_TLS_CERTDIR=
|
|
102
|
+
ports:
|
|
103
|
+
- "2375:2375"
|
|
104
|
+
|
|
105
|
+
e2e-tests:
|
|
106
|
+
build: .
|
|
107
|
+
depends_on:
|
|
108
|
+
- dockersock
|
|
109
|
+
volumes:
|
|
110
|
+
- .:/project
|
|
111
|
+
environment:
|
|
112
|
+
- DOCKER_HOST=tcp://dockersock:2375
|
|
113
|
+
- NON_STOP_CONTAINERS=e2e-tests
|
|
114
|
+
- HOST_PROJECT_ROOT_DIRECTORY=${PWD}
|
|
115
|
+
- COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-uber-compose-tests}
|
|
116
|
+
command: tail -f /dev/null
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Troubleshooting
|
|
120
|
+
|
|
121
|
+
### Cannot connect to Docker daemon
|
|
122
|
+
|
|
123
|
+
Ensure `DOCKER_HOST` points to the correct Docker daemon and it's running:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
docker-compose exec e2e-tests docker ps
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Test container stopped unexpectedly
|
|
130
|
+
|
|
131
|
+
Check `NON_STOP_CONTAINERS` includes your test container:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
echo $NON_STOP_CONTAINERS
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Volume mounting issues
|
|
138
|
+
|
|
139
|
+
Verify `HOST_PROJECT_ROOT_DIRECTORY` is set correctly:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
docker-compose exec e2e-tests env | grep HOST_PROJECT_ROOT_DIRECTORY
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Advanced Configuration
|
|
146
|
+
|
|
147
|
+
Optional environment variables for fine-tuning Uber-Compose behavior.
|
|
148
|
+
|
|
149
|
+
| Variable | Default | Purpose | Use Case |
|
|
150
|
+
|----------|---------|---------|----------|
|
|
151
|
+
| `LOG_POLICY` | `DEFAULT` | Control logging verbosity | Primary control via `--uc-v` parameter at runtime. Set to `VERBOSE` for detailed logs during debugging. |
|
|
152
|
+
| `TMP_ENVS_DIRECTORY` | `/tmp/uc-envs` | Temporary environment files storage | Change if `/tmp` has limited space or specific requirements |
|
|
153
|
+
| `PROJECT_ROOT_DIRECTORY` | `/project` | Container project root path | Set when project mounted to non-standard location |
|
|
154
|
+
| `DOCKER_COMPOSE_FILES_SCAN_DEPTH` | `2` | Directory scan depth for compose files | Increase if compose files nested deeper than 2 levels |
|
|
155
|
+
| `DOCKER_COMPOSE_EXTRA_EXEC_PARAMS` | `-T` | Extra parameters for `docker-compose exec` | Modify to add flags like `--user` or remove `-T` for TTY |
|
|
156
|
+
| `CLI_COMPOSE_UTIL` | `None` | Override compose CLI path | Set when using standalone `docker-compose` binary. Primary uses `docker compose` |
|
|
157
|
+
| `EXEC_PIDS_CHECK_ATTEMPTS_COUNT` | `150` | Process completion check attempts during migrations | Increase for slow systems or long migration times |
|
|
158
|
+
| `EXEC_PIDS_CHECK_RETRY_DELAY` | `1` | Delay (seconds) between process completion checks during migrations | Increase to reduce CPU usage on slow systems |
|
|
159
|
+
| `IGNORE_PIDOF_UNEXISTANCE` | `True` | Ignore missing `pidof` utility | Set to `False` if strict process checking required |
|
|
160
|
+
|
|
161
|
+
**Example:**
|
|
162
|
+
```yaml
|
|
163
|
+
environment:
|
|
164
|
+
# Deeper directory scanning: only project root directory
|
|
165
|
+
- DOCKER_COMPOSE_FILES_SCAN_DEPTH=1
|
|
166
|
+
|
|
167
|
+
# Extended monitoring for slow systems
|
|
168
|
+
- EXEC_PIDS_CHECK_ATTEMPTS_COUNT=300
|
|
169
|
+
- EXEC_PIDS_CHECK_RETRY_DELAY=2
|
|
170
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Lifecycle Hooks
|
|
2
|
+
|
|
3
|
+
Register callbacks that run automatically after `up()` succeeds:
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from uber_compose import UberCompose, UberComposeEvent
|
|
7
|
+
|
|
8
|
+
uber_compose = UberCompose()
|
|
9
|
+
uber_compose.on(UberComposeEvent.AFTER_UP, refresh_client, client, base_url='http://s1:8080')
|
|
10
|
+
|
|
11
|
+
await uber_compose.up(compose_files='docker-compose.yaml', config_template=my_environment)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`func` may be sync or async. Extra `*args`/`**kwargs` passed to `.on()` are
|
|
15
|
+
forwarded on every call. Multiple hooks per event run in registration order.
|
|
16
|
+
|
|
17
|
+
## Events
|
|
18
|
+
|
|
19
|
+
- `AFTER_UP` — every successful `up()` (fresh start, restart, or reuse).
|
|
20
|
+
- `AFTER_UPDATED_ENV_UP` — only when this `up()` restarted an environment this
|
|
21
|
+
same instance had already brought up before (config/services changed since
|
|
22
|
+
the last `up()`). Use it to refresh clients pointing at services that may
|
|
23
|
+
have moved/restarted. Detected purely in-process (no extra docker calls);
|
|
24
|
+
resets per `UberCompose()` instance, persists for the process with
|
|
25
|
+
`TheUberCompose()`.
|
|
26
|
+
|
|
27
|
+
## With `TheUberCompose`
|
|
28
|
+
|
|
29
|
+
Hooks registered on the singleton are shared process-wide:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from uber_compose import TheUberCompose, UberComposeEvent
|
|
33
|
+
|
|
34
|
+
TheUberCompose().on(UberComposeEvent.AFTER_UPDATED_ENV_UP, refresh_all_clients)
|
|
35
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
LLM rules for this repository. If your task concerns a specific point below,
|
|
2
|
+
jump to and read that section before acting.
|
|
3
|
+
|
|
4
|
+
## Table of contents
|
|
5
|
+
|
|
6
|
+
1. [Running e2e tests](#running-e2e-tests)
|
|
7
|
+
2. [After developing a feature and its tests](#after-developing-a-feature-and-its-tests)
|
|
8
|
+
|
|
9
|
+
## Running e2e tests
|
|
10
|
+
|
|
11
|
+
Test runs in test directory.
|
|
12
|
+
|
|
13
|
+
To run tests: make e2e-run args='scenarios/'
|
|
14
|
+
|
|
15
|
+
To run tests with verbose output: make e2e-run args='scenarios/ -vvv'
|
|
16
|
+
|
|
17
|
+
To run tests with environment rebuild or to up environment (only if application code changed): make e2e-run args='scenarios/ -vvv' -B
|
|
18
|
+
|
|
19
|
+
`make e2e-run` also loads pre-saved docker images (`tests/images/*.tar.gz`) into
|
|
20
|
+
the dind daemon used by tests, via the `load-images` stage. This stage is
|
|
21
|
+
cached like `up`/`deps`/`build` (a stamp file skips re-loading on unchanged
|
|
22
|
+
runs) and is refreshed automatically by `-B`. To add an image that a test
|
|
23
|
+
needs but that may be unreliable to pull from Docker Hub in CI, save it with
|
|
24
|
+
`docker save <image> | gzip -9 > tests/images/<name>.tar.gz` and reference the
|
|
25
|
+
same image tag in the test's compose file — `--pull missing` then reuses the
|
|
26
|
+
loaded image instead of pulling it.
|
|
27
|
+
|
|
28
|
+
## After developing a feature and its tests
|
|
29
|
+
|
|
30
|
+
Before considering a feature/task done, from the repo root (not from `tests/`)
|
|
31
|
+
run, after the e2e tests pass:
|
|
32
|
+
|
|
33
|
+
1. `make venv` — creates/updates the local `.venv-lint` dev venv (isort, flake8)
|
|
34
|
+
used by the targets below. Not needed to call directly, it's a dependency
|
|
35
|
+
of `e2e-fix-imports` and `lint`, but can be run on its own too.
|
|
36
|
+
2. `make e2e-fix-imports` — auto-fixes import order (isort) in `uber_compose`
|
|
37
|
+
and `tests`.
|
|
38
|
+
3. `make lint` — re-checks import order and runs flake8; must pass with no
|
|
39
|
+
errors.
|
|
40
|
+
|