uber-compose 1.0.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.
- uber_compose-1.0.0/LICENSE +201 -0
- uber_compose-1.0.0/PKG-INFO +36 -0
- uber_compose-1.0.0/README.md +3 -0
- uber_compose-1.0.0/setup.cfg +4 -0
- uber_compose-1.0.0/setup.py +43 -0
- uber_compose-1.0.0/uber_compose/__init__.py +16 -0
- uber_compose-1.0.0/uber_compose/core/__init__.py +0 -0
- uber_compose-1.0.0/uber_compose/core/constants.py +24 -0
- uber_compose-1.0.0/uber_compose/core/docker_compose.py +243 -0
- uber_compose-1.0.0/uber_compose/core/docker_compose_shell/__init__.py +0 -0
- uber_compose-1.0.0/uber_compose/core/docker_compose_shell/interface.py +389 -0
- uber_compose-1.0.0/uber_compose/core/docker_compose_shell/types.py +174 -0
- uber_compose-1.0.0/uber_compose/core/sequence_run_types.py +28 -0
- uber_compose-1.0.0/uber_compose/core/system_docker_compose.py +100 -0
- uber_compose-1.0.0/uber_compose/core/utils/__init__.py +0 -0
- uber_compose-1.0.0/uber_compose/core/utils/compose_files.py +504 -0
- uber_compose-1.0.0/uber_compose/core/utils/compose_instance_cfg.py +93 -0
- uber_compose-1.0.0/uber_compose/core/utils/env_files.py +21 -0
- uber_compose-1.0.0/uber_compose/core/utils/process_command_output.py +36 -0
- uber_compose-1.0.0/uber_compose/core/utils/shell_process.py +9 -0
- uber_compose-1.0.0/uber_compose/core/utils/state_waiting.py +70 -0
- uber_compose-1.0.0/uber_compose/env_description/__init__.py +7 -0
- uber_compose-1.0.0/uber_compose/env_description/env_tools.py +23 -0
- uber_compose-1.0.0/uber_compose/env_description/env_types.py +196 -0
- uber_compose-1.0.0/uber_compose/errors/__init__.py +0 -0
- uber_compose-1.0.0/uber_compose/errors/migrations.py +7 -0
- uber_compose-1.0.0/uber_compose/errors/up.py +7 -0
- uber_compose-1.0.0/uber_compose/helpers/__init__.py +0 -0
- uber_compose-1.0.0/uber_compose/helpers/broken_services.py +17 -0
- uber_compose-1.0.0/uber_compose/helpers/bytes_pickle.py +24 -0
- uber_compose-1.0.0/uber_compose/helpers/countdown_counter.py +10 -0
- uber_compose-1.0.0/uber_compose/helpers/exec_record.py +7 -0
- uber_compose-1.0.0/uber_compose/helpers/exec_result.py +24 -0
- uber_compose-1.0.0/uber_compose/helpers/health_policy.py +11 -0
- uber_compose-1.0.0/uber_compose/helpers/jobs_result.py +18 -0
- uber_compose-1.0.0/uber_compose/helpers/labels.py +15 -0
- uber_compose-1.0.0/uber_compose/helpers/singleton.py +8 -0
- uber_compose-1.0.0/uber_compose/helpers/state_keeper.py +25 -0
- uber_compose-1.0.0/uber_compose/output/__init__.py +0 -0
- uber_compose-1.0.0/uber_compose/output/console.py +102 -0
- uber_compose-1.0.0/uber_compose/output/styles.py +9 -0
- uber_compose-1.0.0/uber_compose/uber_compose.py +169 -0
- uber_compose-1.0.0/uber_compose/utils/__init__.py +0 -0
- uber_compose-1.0.0/uber_compose/utils/docker_compose_files_path.py +10 -0
- uber_compose-1.0.0/uber_compose/utils/docker_compose_service_deps.py +16 -0
- uber_compose-1.0.0/uber_compose/utils/search_docker_compose_files.py +16 -0
- uber_compose-1.0.0/uber_compose/utils/services_construction.py +15 -0
- uber_compose-1.0.0/uber_compose/vedro_plugin/__init__.py +9 -0
- uber_compose-1.0.0/uber_compose/vedro_plugin/helpers/__init__.py +0 -0
- uber_compose-1.0.0/uber_compose/vedro_plugin/helpers/scenario_ordering.py +17 -0
- uber_compose-1.0.0/uber_compose/vedro_plugin/helpers/scenario_tag_processing.py +21 -0
- uber_compose-1.0.0/uber_compose/vedro_plugin/helpers/test_env_vars_setter.py +17 -0
- uber_compose-1.0.0/uber_compose/vedro_plugin/plugin.py +147 -0
- uber_compose-1.0.0/uber_compose/version +1 -0
- uber_compose-1.0.0/uber_compose/version.py +6 -0
- uber_compose-1.0.0/uber_compose.egg-info/PKG-INFO +36 -0
- uber_compose-1.0.0/uber_compose.egg-info/SOURCES.txt +58 -0
- uber_compose-1.0.0/uber_compose.egg-info/dependency_links.txt +1 -0
- uber_compose-1.0.0/uber_compose.egg-info/requires.txt +4 -0
- uber_compose-1.0.0/uber_compose.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2023] [Yuriy Sagitov]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uber-compose
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: docker compose testing env orchestrator
|
|
5
|
+
Home-page: https://github.com/ko10ok/uber-compose
|
|
6
|
+
Author: Yuriy Sagitov
|
|
7
|
+
Author-email: pro100.ko10ok@gmail.com
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10.0
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: vedro<2.0,>=1.10
|
|
19
|
+
Requires-Dist: PyYAML<6.1,>=6.0.1
|
|
20
|
+
Requires-Dist: rtry<2.0,>=1.4.0
|
|
21
|
+
Requires-Dist: rich<16.0,>=11.0
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: requires-python
|
|
32
|
+
Dynamic: summary
|
|
33
|
+
|
|
34
|
+
# Uber-Compose
|
|
35
|
+
|
|
36
|
+
Lightweight docker compose extension to control environment for tests
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
|
|
3
|
+
from setuptools import find_packages
|
|
4
|
+
from setuptools import setup
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def find_required():
|
|
8
|
+
with open("requirements.txt") as f:
|
|
9
|
+
return f.read().splitlines()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_version(filename='uber_compose/version'):
|
|
13
|
+
return open(filename, "r").read().strip()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
HERE = pathlib.Path(__file__).parent
|
|
17
|
+
README = open("README.md").read()
|
|
18
|
+
setup(
|
|
19
|
+
name="uber-compose",
|
|
20
|
+
version=get_version(),
|
|
21
|
+
description="docker compose testing env orchestrator",
|
|
22
|
+
long_description=README,
|
|
23
|
+
long_description_content_type="text/markdown",
|
|
24
|
+
author="Yuriy Sagitov",
|
|
25
|
+
author_email="pro100.ko10ok@gmail.com",
|
|
26
|
+
python_requires=">=3.10.0",
|
|
27
|
+
url="https://github.com/ko10ok/uber-compose",
|
|
28
|
+
license="Apache-2.0",
|
|
29
|
+
packages=find_packages(exclude=("tests",)),
|
|
30
|
+
install_requires=find_required(),
|
|
31
|
+
entry_points={},
|
|
32
|
+
classifiers=[
|
|
33
|
+
"License :: OSI Approved :: Apache Software License",
|
|
34
|
+
"Programming Language :: Python :: 3.8",
|
|
35
|
+
"Programming Language :: Python :: 3.9",
|
|
36
|
+
"Programming Language :: Python :: 3.10",
|
|
37
|
+
"Programming Language :: Python :: 3.11",
|
|
38
|
+
"Programming Language :: Python :: 3.12",
|
|
39
|
+
],
|
|
40
|
+
package_data={
|
|
41
|
+
'uber_compose': ['version'],
|
|
42
|
+
},
|
|
43
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from uber_compose.core.sequence_run_types import ComposeConfig
|
|
2
|
+
from uber_compose.env_description.env_types import Env
|
|
3
|
+
from uber_compose.env_description.env_types import Environment
|
|
4
|
+
from uber_compose.env_description.env_types import OverridenService
|
|
5
|
+
from uber_compose.env_description.env_types import Service
|
|
6
|
+
from uber_compose.uber_compose import TheUberCompose
|
|
7
|
+
from uber_compose.vedro_plugin.plugin import DEFAULT_COMPOSE
|
|
8
|
+
from uber_compose.vedro_plugin.plugin import VedroUberCompose
|
|
9
|
+
from uber_compose.version import get_version
|
|
10
|
+
|
|
11
|
+
__version__ = get_version()
|
|
12
|
+
__all__ = (
|
|
13
|
+
'TheUberCompose',
|
|
14
|
+
'Environment', 'Service', 'Env', 'OverridenService'
|
|
15
|
+
'VedroUberCompose', 'DEFAULT_COMPOSE', 'ComposeConfig'
|
|
16
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Constants:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self.default_log_policy = os.environ.get('LOG_POLICY', 'DEFAULT')
|
|
8
|
+
|
|
9
|
+
self.project: str = os.environ.get('COMPOSE_PROJECT_NAME')
|
|
10
|
+
self.compose_project_name = os.environ.get('COMPOSE_PROJECT_NAME')
|
|
11
|
+
assert self.compose_project_name, 'COMPOSE_PROJECT_NAME environment variable is not set: - COMPOSE_PROJECT_NAME=${PWD##*/}'
|
|
12
|
+
|
|
13
|
+
self.docker_host = os.environ.get('DOCKER_HOST', 'unix:///var/run/docker.sock')
|
|
14
|
+
|
|
15
|
+
# inner directories
|
|
16
|
+
self.non_stop_containers: list[str] = os.environ.get('NON_STOP_CONTAINERS', 'e2e,dockersock').split(',')
|
|
17
|
+
self.tmp_envs_path: Path = Path(os.environ.get('TMP_ENVS_DIRECTORY', '/tmp-envs'))
|
|
18
|
+
self.in_docker_project_root_path: Path = Path(os.environ.get('PROJECT_ROOT_DIRECTORY', '/project'))
|
|
19
|
+
|
|
20
|
+
self.host_project_root_directory: Path = Path(
|
|
21
|
+
os.environ.get('HOST_PROJECT_ROOT_DIRECTORY', '__host_project_root__')
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
self.docker_compose_extra_exec_params = os.environ.get('DOCKER_COMPOSE_EXTRA_EXEC_PARAMS', '-T')
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
from asyncio import sleep
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from rich.text import Text
|
|
7
|
+
|
|
8
|
+
from uber_compose.core.constants import Constants
|
|
9
|
+
from uber_compose.core.docker_compose_shell.interface import ComposeShellInterface
|
|
10
|
+
from uber_compose.core.sequence_run_types import ComposeInstanceFiles
|
|
11
|
+
from uber_compose.core.sequence_run_types import EnvInstanceConfig
|
|
12
|
+
from uber_compose.core.utils.compose_files import get_compose_services_dependency_tree
|
|
13
|
+
from uber_compose.core.utils.compose_files import make_env_compose_instance_files
|
|
14
|
+
from uber_compose.core.utils.compose_instance_cfg import make_env_instance_config
|
|
15
|
+
from uber_compose.core.utils.state_waiting import wait_all_services_up
|
|
16
|
+
from uber_compose.env_description.env_types import Environment
|
|
17
|
+
from uber_compose.env_description.env_types import EventStage
|
|
18
|
+
from uber_compose.errors.up import ServicesUpError
|
|
19
|
+
from uber_compose.helpers.health_policy import UpHealthPolicy
|
|
20
|
+
from uber_compose.helpers.jobs_result import JobResult
|
|
21
|
+
from uber_compose.output.console import Logger
|
|
22
|
+
from uber_compose.output.styles import Style
|
|
23
|
+
|
|
24
|
+
INFLIGHT = 'inflight'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ComposeInstance:
|
|
28
|
+
def __init__(self,
|
|
29
|
+
project: str,
|
|
30
|
+
name: str, # sometimes differs from Env.name in example DEFAULT_dev for different dc set
|
|
31
|
+
new_env_id: str,
|
|
32
|
+
compose_interface: type[ComposeShellInterface], # = ComposeShellInterface
|
|
33
|
+
compose_files: str,
|
|
34
|
+
config_template: Environment | None,
|
|
35
|
+
in_docker_project_root: Path,
|
|
36
|
+
host_project_root_directory: Path,
|
|
37
|
+
except_containers: list[str],
|
|
38
|
+
tmp_envs_path: Path,
|
|
39
|
+
execution_envs: dict = None,
|
|
40
|
+
release_id: str = None,
|
|
41
|
+
logger: Logger = None,
|
|
42
|
+
health_policy: UpHealthPolicy = UpHealthPolicy(),
|
|
43
|
+
):
|
|
44
|
+
self.logger = logger
|
|
45
|
+
self.health_policy = health_policy
|
|
46
|
+
self.compose_files = compose_files
|
|
47
|
+
self.in_docker_project_root = in_docker_project_root
|
|
48
|
+
self.host_project_root_directory = host_project_root_directory
|
|
49
|
+
self.except_containers = except_containers
|
|
50
|
+
self.tmp_envs_path = tmp_envs_path
|
|
51
|
+
|
|
52
|
+
self.project = project
|
|
53
|
+
if execution_envs is None:
|
|
54
|
+
self.execution_envs = dict(os.environ)
|
|
55
|
+
|
|
56
|
+
self.new_env_id = new_env_id
|
|
57
|
+
self.name = name
|
|
58
|
+
self.config_template = config_template
|
|
59
|
+
self._env_instance_config = None
|
|
60
|
+
self.compose_interface = compose_interface
|
|
61
|
+
|
|
62
|
+
self.release_id: str = release_id
|
|
63
|
+
|
|
64
|
+
self.compose_instance_files: ComposeInstanceFiles = None
|
|
65
|
+
for file in self.compose_files.split(':'):
|
|
66
|
+
assert (file := Path(self.in_docker_project_root / file)).exists(), f'File {file} doesnt exist'
|
|
67
|
+
|
|
68
|
+
async def config(self) -> EnvInstanceConfig:
|
|
69
|
+
if self._env_instance_config is None:
|
|
70
|
+
self._env_instance_config = make_env_instance_config(
|
|
71
|
+
env_template=self.config_template,
|
|
72
|
+
env_id=self.new_env_id,
|
|
73
|
+
name=self.name,
|
|
74
|
+
)
|
|
75
|
+
return self._env_instance_config
|
|
76
|
+
|
|
77
|
+
async def generate_config_files(self) -> ComposeInstanceFiles:
|
|
78
|
+
assert self.new_env_id != INFLIGHT, 'somehow regenerated files for inflight env'
|
|
79
|
+
compose_instance_files = make_env_compose_instance_files(
|
|
80
|
+
await self.config(),
|
|
81
|
+
self.compose_files,
|
|
82
|
+
project_network_name=self.project,
|
|
83
|
+
host_project_root_directory=self.host_project_root_directory,
|
|
84
|
+
compose_files_path=self.in_docker_project_root,
|
|
85
|
+
tmp_env_path=self.tmp_envs_path,
|
|
86
|
+
release_id=self.release_id,
|
|
87
|
+
)
|
|
88
|
+
# TODO uneven compose_executor initialization!! but compose_interface compose_files-dependent
|
|
89
|
+
self.compose_executor = self.compose_interface(
|
|
90
|
+
compose_files=compose_instance_files.compose_files,
|
|
91
|
+
in_docker_project_root=self.in_docker_project_root,
|
|
92
|
+
logger=self.logger,
|
|
93
|
+
)
|
|
94
|
+
return compose_instance_files
|
|
95
|
+
|
|
96
|
+
async def run_migration(self, stages, services, env_config_instance, migrations):
|
|
97
|
+
for service in env_config_instance.env:
|
|
98
|
+
sys.stdout.flush()
|
|
99
|
+
if service not in services:
|
|
100
|
+
continue
|
|
101
|
+
|
|
102
|
+
for handler in migrations[service]:
|
|
103
|
+
if handler.stage not in stages:
|
|
104
|
+
continue
|
|
105
|
+
|
|
106
|
+
# TODO fix service map if default env
|
|
107
|
+
target_service = env_config_instance.env_services_map[handler.executor or service]
|
|
108
|
+
|
|
109
|
+
# TODO check if need to template migrations
|
|
110
|
+
# substituted_cmd = handler.cmd.format(**env_config_instance.env_services_map)
|
|
111
|
+
substituted_cmd = handler.cmd
|
|
112
|
+
migrate_result = await self.compose_executor.dc_exec_until_state(
|
|
113
|
+
target_service, substituted_cmd,
|
|
114
|
+
kill_before=False,
|
|
115
|
+
kill_after=False,
|
|
116
|
+
)
|
|
117
|
+
if not migrate_result.check_result:
|
|
118
|
+
services_status = await self.compose_executor.dc_state()
|
|
119
|
+
raise ServicesUpError(f"Can't migrate service {target_service}, with {substituted_cmd}"
|
|
120
|
+
f"\n{migrate_result.stdout=}\n{migrate_result.stderr=}"
|
|
121
|
+
# TODO fix too verbose to file output?
|
|
122
|
+
# f"\nUp logs:\n {await self.logs(self.except_containers)}"
|
|
123
|
+
f"\nServices logs:\n {await self.logs(services)}"
|
|
124
|
+
f"\nServices status:\n {services_status.as_rich_text()}") from None
|
|
125
|
+
|
|
126
|
+
async def run_services_pack(self, services: list[str], migrations):
|
|
127
|
+
|
|
128
|
+
for container in self.except_containers:
|
|
129
|
+
if container in services:
|
|
130
|
+
services.remove(container)
|
|
131
|
+
self.logger.stage_details(f'Starting services pack: {services}; except: {self.except_containers}')
|
|
132
|
+
|
|
133
|
+
status_result = await self.compose_executor.dc_state()
|
|
134
|
+
assert status_result != JobResult.BAD, f"Can't get first status for services {services}"
|
|
135
|
+
|
|
136
|
+
await self.run_migration(
|
|
137
|
+
[EventStage.BEFORE_SERVICE_START],
|
|
138
|
+
services,
|
|
139
|
+
self.compose_instance_files.env_config_instance,
|
|
140
|
+
migrations
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
up_result = await self.compose_executor.dc_up(services)
|
|
144
|
+
assert up_result == JobResult.GOOD, (f"Can't run up services {services}\nIssues on up attempt:\n "
|
|
145
|
+
f"{up_result}")
|
|
146
|
+
|
|
147
|
+
await self.run_migration(
|
|
148
|
+
[EventStage.AFTER_SERVICE_START],
|
|
149
|
+
services,
|
|
150
|
+
self.compose_instance_files.env_config_instance,
|
|
151
|
+
migrations
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# up process asynchronous
|
|
155
|
+
# check services started before migrations if health policy told to do that:
|
|
156
|
+
|
|
157
|
+
await sleep(self.health_policy.pre_check_delay_s)
|
|
158
|
+
if self.health_policy.wait_for_healthy_in_between:
|
|
159
|
+
check_up_result = await wait_all_services_up(
|
|
160
|
+
attempts=self.health_policy.service_up_check_attempts,
|
|
161
|
+
delay_s=self.health_policy.service_up_check_delay_s,
|
|
162
|
+
logger_func=self.logger.stage_details,
|
|
163
|
+
get_compose_state=self.compose_executor.dc_state,
|
|
164
|
+
)
|
|
165
|
+
if check_up_result != JobResult.GOOD:
|
|
166
|
+
services_status = await self.compose_executor.dc_state()
|
|
167
|
+
raise ServicesUpError(
|
|
168
|
+
f"Can't up services {services} for "
|
|
169
|
+
f"{self.health_policy.service_up_check_attempts * self.health_policy.service_up_check_delay_s}s"
|
|
170
|
+
# TODO fix too verbose to file output?
|
|
171
|
+
# f"\nUp logs:\n {await self.logs(self.except_containers)}"
|
|
172
|
+
# f"\nServices logs:\n {await self.logs(services)}"
|
|
173
|
+
f"\nServices status:\n {services_status.as_rich_text()}"
|
|
174
|
+
) from None
|
|
175
|
+
|
|
176
|
+
await self.run_migration(
|
|
177
|
+
[EventStage.AFTER_SERVICE_HEALTHY],
|
|
178
|
+
services,
|
|
179
|
+
self.compose_instance_files.env_config_instance,
|
|
180
|
+
migrations
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
async def run(self):
|
|
184
|
+
self.compose_instance_files = await self.generate_config_files()
|
|
185
|
+
|
|
186
|
+
services_tiers = get_compose_services_dependency_tree(self.compose_instance_files.compose_files)
|
|
187
|
+
self.logger.stage_info(
|
|
188
|
+
Text('Starting services: ', style=Style.info)
|
|
189
|
+
.append(Text(str(services_tiers), style=Style.good))
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
migrations = {}
|
|
193
|
+
for service in self.compose_instance_files.env_config_instance.env:
|
|
194
|
+
if service not in migrations:
|
|
195
|
+
migrations[service] = []
|
|
196
|
+
migrations[service] += self.compose_instance_files.env_config_instance.env[service].events_handlers
|
|
197
|
+
migrations[service] += self.compose_instance_files.inline_migrations[service]
|
|
198
|
+
|
|
199
|
+
all_services = [
|
|
200
|
+
service
|
|
201
|
+
for service_tier_pack in services_tiers
|
|
202
|
+
for service in service_tier_pack
|
|
203
|
+
]
|
|
204
|
+
|
|
205
|
+
await self.run_migration(
|
|
206
|
+
[EventStage.BEFORE_ALL],
|
|
207
|
+
all_services,
|
|
208
|
+
self.compose_instance_files.env_config_instance,
|
|
209
|
+
migrations
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
for service_tier_pack in services_tiers:
|
|
213
|
+
await self.run_services_pack(service_tier_pack, migrations)
|
|
214
|
+
|
|
215
|
+
await self.run_migration(
|
|
216
|
+
[EventStage.AFTER_ALL],
|
|
217
|
+
all_services,
|
|
218
|
+
self.compose_instance_files.env_config_instance,
|
|
219
|
+
migrations
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
if self.health_policy.wait_for_healthy_after_all:
|
|
223
|
+
check_up_result = await wait_all_services_up(
|
|
224
|
+
attempts=self.health_policy.service_up_check_attempts,
|
|
225
|
+
delay_s=self.health_policy.service_up_check_delay_s,
|
|
226
|
+
logger_func=self.logger.stage,
|
|
227
|
+
get_compose_state=self.compose_executor.dc_state,
|
|
228
|
+
)
|
|
229
|
+
if check_up_result != JobResult.GOOD:
|
|
230
|
+
services_status = await self.compose_executor.dc_state()
|
|
231
|
+
raise ServicesUpError(
|
|
232
|
+
f"Can't up services {all_services} all together for "
|
|
233
|
+
f"{self.health_policy.service_up_check_attempts * self.health_policy.service_up_check_delay_s}s"
|
|
234
|
+
# TODO fix too verbose to file output?
|
|
235
|
+
# f"\nUp logs:\n {await self.logs(self.except_containers)}"
|
|
236
|
+
# f"\nServices logs:\n {await self.logs(services)}"
|
|
237
|
+
f"\nServices status:\n {services_status.as_rich_text()}"
|
|
238
|
+
) from None
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
async def logs(self, services=None) -> str:
|
|
242
|
+
job_result, log = await self.compose_executor.dc_logs(services, logs_param='')
|
|
243
|
+
return log.decode('utf-8') if job_result == JobResult.GOOD else ''
|
|
File without changes
|