qontract-reconcile 0.10.1rc1201__py3-none-any.whl → 0.10.2.dev1__py3-none-any.whl
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.
- qontract_reconcile-0.10.2.dev1.dist-info/METADATA +500 -0
- {qontract_reconcile-0.10.1rc1201.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/RECORD +14 -132
- {qontract_reconcile-0.10.1rc1201.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/WHEEL +1 -2
- {qontract_reconcile-0.10.1rc1201.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/entry_points.txt +1 -0
- reconcile/aws_account_manager/README.md +5 -0
- reconcile/change_owners/README.md +34 -0
- reconcile/external_resources/manager.py +12 -1
- reconcile/external_resources/model.py +11 -0
- reconcile/glitchtip/README.md +150 -0
- reconcile/gql_definitions/introspection.json +51176 -0
- reconcile/run_integration.py +293 -0
- reconcile/utils/binary.py +2 -2
- reconcile/utils/mr/README.md +198 -0
- reconcile/utils/oc_map.py +2 -2
- tools/qontract_cli.py +0 -0
- qontract_reconcile-0.10.1rc1201.dist-info/METADATA +0 -64
- qontract_reconcile-0.10.1rc1201.dist-info/top_level.txt +0 -3
- reconcile/test/__init__.py +0 -0
- reconcile/test/conftest.py +0 -157
- reconcile/test/fixtures.py +0 -24
- reconcile/test/saas_auto_promotions_manager/__init__.py +0 -0
- reconcile/test/saas_auto_promotions_manager/conftest.py +0 -170
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/__init__.py +0 -0
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/__init__.py +0 -0
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/conftest.py +0 -115
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/data_keys.py +0 -19
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_desired_state.py +0 -66
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_merge_request_manager.py +0 -86
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_mr_parser.py +0 -352
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_reconciler.py +0 -494
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/__init__.py +0 -0
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/conftest.py +0 -25
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_multiple_namespaces.py +0 -37
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_namespace.py +0 -81
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_target.py +0 -61
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_json_path_selector.py +0 -74
- reconcile/test/saas_auto_promotions_manager/test_integration_test.py +0 -52
- reconcile/test/saas_auto_promotions_manager/utils/__init__.py +0 -0
- reconcile/test/test_acs_notifiers.py +0 -393
- reconcile/test/test_acs_policies.py +0 -497
- reconcile/test/test_acs_rbac.py +0 -865
- reconcile/test/test_aggregated_list.py +0 -237
- reconcile/test/test_amtool.py +0 -37
- reconcile/test/test_aws_ami_cleanup.py +0 -230
- reconcile/test/test_aws_ami_share.py +0 -68
- reconcile/test/test_aws_cloudwatch_log_retention.py +0 -434
- reconcile/test/test_aws_iam_keys.py +0 -70
- reconcile/test/test_aws_iam_password_reset.py +0 -35
- reconcile/test/test_aws_support_cases_sos.py +0 -23
- reconcile/test/test_checkpoint.py +0 -178
- reconcile/test/test_cli.py +0 -41
- reconcile/test/test_closedbox_endpoint_monitoring.py +0 -207
- reconcile/test/test_dashdotdb_dora.py +0 -245
- reconcile/test/test_database_access_manager.py +0 -660
- reconcile/test/test_deadmanssnitch.py +0 -290
- reconcile/test/test_gabi_authorized_users.py +0 -72
- reconcile/test/test_gcr_mirror.py +0 -14
- reconcile/test/test_github_org.py +0 -156
- reconcile/test/test_github_repo_invites.py +0 -119
- reconcile/test/test_gitlab_housekeeping.py +0 -333
- reconcile/test/test_gitlab_labeler.py +0 -126
- reconcile/test/test_gitlab_members.py +0 -219
- reconcile/test/test_gitlab_permissions.py +0 -164
- reconcile/test/test_instrumented_wrappers.py +0 -18
- reconcile/test/test_integrations_manager.py +0 -1252
- reconcile/test/test_jenkins_worker_fleets.py +0 -57
- reconcile/test/test_jira_permissions_validator.py +0 -519
- reconcile/test/test_jump_host.py +0 -114
- reconcile/test/test_ldap_users.py +0 -125
- reconcile/test/test_make.py +0 -28
- reconcile/test/test_ocm_additional_routers.py +0 -133
- reconcile/test/test_ocm_clusters.py +0 -798
- reconcile/test/test_ocm_clusters_manifest_updates.py +0 -87
- reconcile/test/test_ocm_machine_pools.py +0 -1103
- reconcile/test/test_ocm_update_recommended_version.py +0 -145
- reconcile/test/test_ocm_upgrade_scheduler_org_updater.py +0 -125
- reconcile/test/test_openshift_base.py +0 -1269
- reconcile/test/test_openshift_cluster_bots.py +0 -240
- reconcile/test/test_openshift_namespace_labels.py +0 -344
- reconcile/test/test_openshift_namespaces.py +0 -256
- reconcile/test/test_openshift_resource.py +0 -443
- reconcile/test/test_openshift_resources_base.py +0 -478
- reconcile/test/test_openshift_saas_deploy.py +0 -188
- reconcile/test/test_openshift_saas_deploy_change_tester.py +0 -308
- reconcile/test/test_openshift_saas_deploy_trigger_cleaner.py +0 -65
- reconcile/test/test_openshift_serviceaccount_tokens.py +0 -282
- reconcile/test/test_openshift_tekton_resources.py +0 -265
- reconcile/test/test_openshift_upgrade_watcher.py +0 -223
- reconcile/test/test_prometheus_rules_tester.py +0 -151
- reconcile/test/test_quay_membership.py +0 -86
- reconcile/test/test_quay_mirror.py +0 -172
- reconcile/test/test_quay_mirror_org.py +0 -82
- reconcile/test/test_quay_repos.py +0 -59
- reconcile/test/test_queries.py +0 -53
- reconcile/test/test_repo_owners.py +0 -47
- reconcile/test/test_requests_sender.py +0 -139
- reconcile/test/test_saasherder.py +0 -1611
- reconcile/test/test_saasherder_allowed_secret_paths.py +0 -125
- reconcile/test/test_secret_reader.py +0 -153
- reconcile/test/test_slack_base.py +0 -183
- reconcile/test/test_slack_usergroups.py +0 -785
- reconcile/test/test_sql_query.py +0 -316
- reconcile/test/test_status_board.py +0 -258
- reconcile/test/test_terraform_aws_route53.py +0 -29
- reconcile/test/test_terraform_cloudflare_dns.py +0 -117
- reconcile/test/test_terraform_cloudflare_resources.py +0 -408
- reconcile/test/test_terraform_cloudflare_users.py +0 -747
- reconcile/test/test_terraform_repo.py +0 -440
- reconcile/test/test_terraform_resources.py +0 -519
- reconcile/test/test_terraform_tgw_attachments.py +0 -1295
- reconcile/test/test_terraform_users.py +0 -152
- reconcile/test/test_terraform_vpc_peerings.py +0 -576
- reconcile/test/test_terraform_vpc_peerings_build_desired_state.py +0 -1434
- reconcile/test/test_three_way_diff_strategy.py +0 -131
- reconcile/test/test_utils_jinja2.py +0 -130
- reconcile/test/test_vault_replication.py +0 -534
- reconcile/test/test_vault_utils.py +0 -47
- reconcile/test/test_version_bump.py +0 -18
- reconcile/test/test_vpc_peerings_validator.py +0 -194
- reconcile/test/test_wrong_region.py +0 -78
- release/__init__.py +0 -0
- release/test_version.py +0 -50
- release/version.py +0 -104
- tools/cli_commands/test/__init__.py +0 -0
- tools/cli_commands/test/conftest.py +0 -332
- tools/cli_commands/test/test_aws_cost_report.py +0 -258
- tools/cli_commands/test/test_cost_management_api.py +0 -326
- tools/cli_commands/test/test_gpg_encrypt.py +0 -235
- tools/cli_commands/test/test_openshift_cost_optimization_report.py +0 -255
- tools/cli_commands/test/test_openshift_cost_report.py +0 -295
- tools/cli_commands/test/test_util.py +0 -70
- tools/test/__init__.py +0 -0
- tools/test/conftest.py +0 -77
- tools/test/test_app_interface_metrics_exporter.py +0 -48
- tools/test/test_erv2.py +0 -80
- tools/test/test_get_container_images.py +0 -230
- tools/test/test_qontract_cli.py +0 -197
- tools/test/test_saas_promotion_state.py +0 -187
- tools/test/test_sd_app_sre_alert_report.py +0 -74
- tools/test/test_sre_checkpoints.py +0 -79
@@ -1,494 +0,0 @@
|
|
1
|
-
from collections.abc import Sequence
|
2
|
-
from unittest.mock import create_autospec
|
3
|
-
|
4
|
-
import pytest
|
5
|
-
from gitlab.v4.objects import ProjectMergeRequest
|
6
|
-
|
7
|
-
from reconcile.saas_auto_promotions_manager.merge_request_manager.batcher import (
|
8
|
-
Addition,
|
9
|
-
Batcher,
|
10
|
-
Deletion,
|
11
|
-
Diff,
|
12
|
-
Promotion,
|
13
|
-
Reason,
|
14
|
-
)
|
15
|
-
from reconcile.saas_auto_promotions_manager.merge_request_manager.open_merge_requests import (
|
16
|
-
OpenBatcherMergeRequest,
|
17
|
-
)
|
18
|
-
|
19
|
-
|
20
|
-
def _aggregate_hashes(items: Sequence[Addition | Deletion]) -> set[str]:
|
21
|
-
hashes: set[str] = set()
|
22
|
-
for item in items:
|
23
|
-
if isinstance(item, Addition):
|
24
|
-
hashes.update(item.content_hashes)
|
25
|
-
else:
|
26
|
-
hashes.update(item.mr.content_hashes)
|
27
|
-
return hashes
|
28
|
-
|
29
|
-
|
30
|
-
def _aggregate_channels(items: Sequence[Addition | Deletion]) -> set[str]:
|
31
|
-
channels: set[str] = set()
|
32
|
-
for item in items:
|
33
|
-
if isinstance(item, Addition):
|
34
|
-
channels.update(item.channels)
|
35
|
-
else:
|
36
|
-
channels.update(item.mr.channels)
|
37
|
-
return channels
|
38
|
-
|
39
|
-
|
40
|
-
@pytest.mark.parametrize(
|
41
|
-
"desired_promotions, open_mrs, expected_diff",
|
42
|
-
[
|
43
|
-
# No open MRs. Aggregate desired promotions into single batched Promotion
|
44
|
-
(
|
45
|
-
[
|
46
|
-
Promotion(
|
47
|
-
channels={"chan1"},
|
48
|
-
content_hashes={"hash1"},
|
49
|
-
),
|
50
|
-
Promotion(
|
51
|
-
channels={"chan2", "chan3"},
|
52
|
-
content_hashes={"hash2", "hash3"},
|
53
|
-
),
|
54
|
-
],
|
55
|
-
[],
|
56
|
-
Diff(
|
57
|
-
deletions=[],
|
58
|
-
additions=[
|
59
|
-
Addition(
|
60
|
-
channels={"chan1", "chan2", "chan3"},
|
61
|
-
content_hashes={"hash1", "hash2", "hash3"},
|
62
|
-
batchable=True,
|
63
|
-
),
|
64
|
-
],
|
65
|
-
),
|
66
|
-
),
|
67
|
-
# No desired promotions. We expect that every MR gets closed,
|
68
|
-
# no matter its current state.
|
69
|
-
(
|
70
|
-
[],
|
71
|
-
[
|
72
|
-
OpenBatcherMergeRequest(
|
73
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
74
|
-
channels={"chan1", "chan2"},
|
75
|
-
content_hashes={"hash1", "hash2"},
|
76
|
-
failed_mr_check=True,
|
77
|
-
is_batchable=True,
|
78
|
-
),
|
79
|
-
OpenBatcherMergeRequest(
|
80
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
81
|
-
channels={"chan3"},
|
82
|
-
content_hashes={"hash3"},
|
83
|
-
failed_mr_check=False,
|
84
|
-
is_batchable=True,
|
85
|
-
),
|
86
|
-
OpenBatcherMergeRequest(
|
87
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
88
|
-
channels={"chan4"},
|
89
|
-
content_hashes={"hash4"},
|
90
|
-
failed_mr_check=False,
|
91
|
-
is_batchable=False,
|
92
|
-
),
|
93
|
-
OpenBatcherMergeRequest(
|
94
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
95
|
-
channels={"chan5"},
|
96
|
-
content_hashes={"hash5"},
|
97
|
-
failed_mr_check=True,
|
98
|
-
is_batchable=False,
|
99
|
-
),
|
100
|
-
],
|
101
|
-
Diff(
|
102
|
-
deletions=[
|
103
|
-
Deletion(
|
104
|
-
mr=OpenBatcherMergeRequest(
|
105
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
106
|
-
channels={"chan1", "chan2"},
|
107
|
-
content_hashes={"hash1", "hash2"},
|
108
|
-
failed_mr_check=True,
|
109
|
-
is_batchable=True,
|
110
|
-
),
|
111
|
-
reason=Reason.MISSING_UNBATCHING,
|
112
|
-
),
|
113
|
-
Deletion(
|
114
|
-
mr=OpenBatcherMergeRequest(
|
115
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
116
|
-
channels={"chan3"},
|
117
|
-
content_hashes={"hash3"},
|
118
|
-
failed_mr_check=False,
|
119
|
-
is_batchable=True,
|
120
|
-
),
|
121
|
-
reason=Reason.OUTDATED_CONTENT,
|
122
|
-
),
|
123
|
-
Deletion(
|
124
|
-
mr=OpenBatcherMergeRequest(
|
125
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
126
|
-
channels={"chan4"},
|
127
|
-
content_hashes={"hash4"},
|
128
|
-
failed_mr_check=False,
|
129
|
-
is_batchable=False,
|
130
|
-
),
|
131
|
-
reason=Reason.OUTDATED_CONTENT,
|
132
|
-
),
|
133
|
-
Deletion(
|
134
|
-
mr=OpenBatcherMergeRequest(
|
135
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
136
|
-
channels={"chan5"},
|
137
|
-
content_hashes={"hash5"},
|
138
|
-
failed_mr_check=True,
|
139
|
-
is_batchable=False,
|
140
|
-
),
|
141
|
-
reason=Reason.OUTDATED_CONTENT,
|
142
|
-
),
|
143
|
-
],
|
144
|
-
additions=[],
|
145
|
-
),
|
146
|
-
),
|
147
|
-
# We have a single failed, but still marked as batchable MR.
|
148
|
-
# The hashes in the failed MR are still desired state.
|
149
|
-
# We expect this MR to be closed. Further, a new MR should be
|
150
|
-
# opened that is marked as unbatchable. Each hash should have
|
151
|
-
# its own separated MR.
|
152
|
-
(
|
153
|
-
[
|
154
|
-
Promotion(
|
155
|
-
channels={"chan1"},
|
156
|
-
content_hashes={"hash1"},
|
157
|
-
),
|
158
|
-
Promotion(
|
159
|
-
channels={"chan2"},
|
160
|
-
content_hashes={"hash2"},
|
161
|
-
),
|
162
|
-
],
|
163
|
-
[
|
164
|
-
OpenBatcherMergeRequest(
|
165
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
166
|
-
channels={"chan1", "chan2"},
|
167
|
-
content_hashes={"hash1", "hash2"},
|
168
|
-
failed_mr_check=True,
|
169
|
-
is_batchable=True,
|
170
|
-
),
|
171
|
-
],
|
172
|
-
Diff(
|
173
|
-
deletions=[
|
174
|
-
Deletion(
|
175
|
-
mr=OpenBatcherMergeRequest(
|
176
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
177
|
-
channels={"chan1", "chan2"},
|
178
|
-
content_hashes={"hash1", "hash2"},
|
179
|
-
failed_mr_check=True,
|
180
|
-
is_batchable=True,
|
181
|
-
),
|
182
|
-
reason=Reason.MISSING_UNBATCHING,
|
183
|
-
)
|
184
|
-
],
|
185
|
-
additions=[
|
186
|
-
Addition(
|
187
|
-
channels={"chan1"},
|
188
|
-
content_hashes={"hash1"},
|
189
|
-
batchable=False,
|
190
|
-
),
|
191
|
-
Addition(
|
192
|
-
channels={"chan2"},
|
193
|
-
content_hashes={"hash2"},
|
194
|
-
batchable=False,
|
195
|
-
),
|
196
|
-
],
|
197
|
-
),
|
198
|
-
),
|
199
|
-
# We have an open valid batched MR. All desired promotions
|
200
|
-
# are already addressed by that MR -> there is nothing to do.
|
201
|
-
(
|
202
|
-
[
|
203
|
-
Promotion(
|
204
|
-
channels={"chan1"},
|
205
|
-
content_hashes={"hash1"},
|
206
|
-
),
|
207
|
-
Promotion(
|
208
|
-
channels={"chan2"},
|
209
|
-
content_hashes={"hash2"},
|
210
|
-
),
|
211
|
-
],
|
212
|
-
[
|
213
|
-
OpenBatcherMergeRequest(
|
214
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
215
|
-
channels={"chan1", "chan2"},
|
216
|
-
content_hashes={"hash1", "hash2"},
|
217
|
-
failed_mr_check=False,
|
218
|
-
is_batchable=True,
|
219
|
-
),
|
220
|
-
],
|
221
|
-
Diff(
|
222
|
-
deletions=[],
|
223
|
-
additions=[],
|
224
|
-
),
|
225
|
-
),
|
226
|
-
# We have an open valid batched MR. However, there is a promotion
|
227
|
-
# that is not addressed by the open MR.
|
228
|
-
# We expect that the MR gets closed and a new
|
229
|
-
# batched MR gets created which addresses all desired promotions.
|
230
|
-
(
|
231
|
-
[
|
232
|
-
Promotion(
|
233
|
-
channels={"chan1"},
|
234
|
-
content_hashes={"hash1"},
|
235
|
-
),
|
236
|
-
Promotion(
|
237
|
-
channels={"chan2"},
|
238
|
-
content_hashes={"hash2"},
|
239
|
-
),
|
240
|
-
Promotion(
|
241
|
-
channels={"chan3", "chan4"},
|
242
|
-
content_hashes={"hash3", "hash4"},
|
243
|
-
),
|
244
|
-
],
|
245
|
-
[
|
246
|
-
OpenBatcherMergeRequest(
|
247
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
248
|
-
channels={"chan1", "chan2"},
|
249
|
-
content_hashes={"hash1", "hash2"},
|
250
|
-
failed_mr_check=False,
|
251
|
-
is_batchable=True,
|
252
|
-
),
|
253
|
-
],
|
254
|
-
Diff(
|
255
|
-
deletions=[
|
256
|
-
Deletion(
|
257
|
-
mr=OpenBatcherMergeRequest(
|
258
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
259
|
-
channels={"chan1", "chan2"},
|
260
|
-
content_hashes={"hash1", "hash2"},
|
261
|
-
failed_mr_check=False,
|
262
|
-
is_batchable=True,
|
263
|
-
),
|
264
|
-
reason=Reason.NEW_BATCH,
|
265
|
-
)
|
266
|
-
],
|
267
|
-
additions=[
|
268
|
-
Addition(
|
269
|
-
content_hashes={"hash1", "hash2", "hash3", "hash4"},
|
270
|
-
channels={"chan1", "chan2", "chan3", "chan4"},
|
271
|
-
batchable=True,
|
272
|
-
)
|
273
|
-
],
|
274
|
-
),
|
275
|
-
),
|
276
|
-
# We want to promote 12 content hashes.
|
277
|
-
# We surpass the current batch limit of 5.
|
278
|
-
# We expect a total of 3 batch MRs to be created.
|
279
|
-
# The existing open batch MR should be closed.
|
280
|
-
(
|
281
|
-
[
|
282
|
-
Promotion(
|
283
|
-
channels={"chan1", "chan2", "chan3"},
|
284
|
-
content_hashes={"hash1", "hash2", "hash3"},
|
285
|
-
),
|
286
|
-
Promotion(
|
287
|
-
channels={"chan4", "chan5", "chan6"},
|
288
|
-
content_hashes={"hash4", "hash5", "hash6"},
|
289
|
-
),
|
290
|
-
Promotion(
|
291
|
-
channels={"chan7", "chan8", "chan9"},
|
292
|
-
content_hashes={"hash7", "hash8", "hash9"},
|
293
|
-
),
|
294
|
-
Promotion(
|
295
|
-
channels={"chan10", "chan11", "chan12"},
|
296
|
-
content_hashes={"hash10", "hash11", "hash12"},
|
297
|
-
),
|
298
|
-
Promotion(
|
299
|
-
channels={"chan13", "chan14"},
|
300
|
-
content_hashes={"hash13", "hash14"},
|
301
|
-
),
|
302
|
-
],
|
303
|
-
[
|
304
|
-
OpenBatcherMergeRequest(
|
305
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
306
|
-
channels={"chan1", "chan2"},
|
307
|
-
content_hashes={"hash1", "hash2"},
|
308
|
-
failed_mr_check=False,
|
309
|
-
is_batchable=True,
|
310
|
-
),
|
311
|
-
],
|
312
|
-
Diff(
|
313
|
-
deletions=[
|
314
|
-
Deletion(
|
315
|
-
mr=OpenBatcherMergeRequest(
|
316
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
317
|
-
channels={"chan1", "chan2"},
|
318
|
-
content_hashes={"hash1", "hash2"},
|
319
|
-
failed_mr_check=False,
|
320
|
-
is_batchable=True,
|
321
|
-
),
|
322
|
-
reason=Reason.NEW_BATCH,
|
323
|
-
)
|
324
|
-
],
|
325
|
-
additions=[
|
326
|
-
Addition(
|
327
|
-
# Note, that we expect more than 5 hashes here. The reason is that the
|
328
|
-
# aggregated promotions consist of 3 hashes, i.e., 3+3 = 6
|
329
|
-
# This is expected and fine.
|
330
|
-
content_hashes={
|
331
|
-
"hash1",
|
332
|
-
"hash2",
|
333
|
-
"hash3",
|
334
|
-
"hash4",
|
335
|
-
"hash5",
|
336
|
-
"hash6",
|
337
|
-
},
|
338
|
-
channels={"chan1", "chan2", "chan3", "chan4", "chan5", "chan6"},
|
339
|
-
batchable=True,
|
340
|
-
),
|
341
|
-
Addition(
|
342
|
-
content_hashes={
|
343
|
-
"hash7",
|
344
|
-
"hash8",
|
345
|
-
"hash9",
|
346
|
-
"hash10",
|
347
|
-
"hash11",
|
348
|
-
"hash12",
|
349
|
-
},
|
350
|
-
channels={
|
351
|
-
"chan7",
|
352
|
-
"chan8",
|
353
|
-
"chan9",
|
354
|
-
"chan10",
|
355
|
-
"chan11",
|
356
|
-
"chan12",
|
357
|
-
},
|
358
|
-
batchable=True,
|
359
|
-
),
|
360
|
-
Addition(
|
361
|
-
content_hashes={"hash13", "hash14"},
|
362
|
-
channels={"chan13", "chan14"},
|
363
|
-
batchable=True,
|
364
|
-
),
|
365
|
-
],
|
366
|
-
),
|
367
|
-
),
|
368
|
-
# We have an unbatchable open MR.
|
369
|
-
# We do not want any change on the existing unbatchable MR,
|
370
|
-
# but at the same time expect a new MR to be opened for the new promotion.
|
371
|
-
(
|
372
|
-
[
|
373
|
-
Promotion(
|
374
|
-
channels={"chan1"},
|
375
|
-
content_hashes={"hash1"},
|
376
|
-
),
|
377
|
-
Promotion(
|
378
|
-
channels={"chan2"},
|
379
|
-
content_hashes={"hash2"},
|
380
|
-
),
|
381
|
-
],
|
382
|
-
[
|
383
|
-
OpenBatcherMergeRequest(
|
384
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
385
|
-
channels={"chan1"},
|
386
|
-
content_hashes={"hash1"},
|
387
|
-
failed_mr_check=False,
|
388
|
-
is_batchable=False,
|
389
|
-
),
|
390
|
-
],
|
391
|
-
Diff(
|
392
|
-
deletions=[],
|
393
|
-
additions=[
|
394
|
-
Addition(
|
395
|
-
content_hashes={
|
396
|
-
"hash2",
|
397
|
-
},
|
398
|
-
channels={"chan2"},
|
399
|
-
batchable=True,
|
400
|
-
),
|
401
|
-
],
|
402
|
-
),
|
403
|
-
),
|
404
|
-
# We have multiple unbatchable open MRs.
|
405
|
-
# We do not want any change on the existing unbatchable MRs,
|
406
|
-
# but at the same time expect a new MR to be opened for the new promotions.
|
407
|
-
(
|
408
|
-
[
|
409
|
-
Promotion(
|
410
|
-
channels={"chan1"},
|
411
|
-
content_hashes={"hash1"},
|
412
|
-
),
|
413
|
-
Promotion(
|
414
|
-
channels={"chan2"},
|
415
|
-
content_hashes={"hash2"},
|
416
|
-
),
|
417
|
-
Promotion(
|
418
|
-
channels={"chan3"},
|
419
|
-
content_hashes={"hash3"},
|
420
|
-
),
|
421
|
-
Promotion(
|
422
|
-
channels={"chan4"},
|
423
|
-
content_hashes={"hash4"},
|
424
|
-
),
|
425
|
-
],
|
426
|
-
[
|
427
|
-
OpenBatcherMergeRequest(
|
428
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
429
|
-
channels={"chan1"},
|
430
|
-
content_hashes={"hash1"},
|
431
|
-
failed_mr_check=False,
|
432
|
-
is_batchable=False,
|
433
|
-
),
|
434
|
-
OpenBatcherMergeRequest(
|
435
|
-
raw=create_autospec(spec=ProjectMergeRequest),
|
436
|
-
channels={"chan2"},
|
437
|
-
content_hashes={"hash2"},
|
438
|
-
failed_mr_check=False,
|
439
|
-
is_batchable=False,
|
440
|
-
),
|
441
|
-
],
|
442
|
-
Diff(
|
443
|
-
deletions=[],
|
444
|
-
additions=[
|
445
|
-
Addition(
|
446
|
-
content_hashes={
|
447
|
-
"hash3",
|
448
|
-
"hash4",
|
449
|
-
},
|
450
|
-
channels={"chan3", "chan4"},
|
451
|
-
batchable=True,
|
452
|
-
),
|
453
|
-
],
|
454
|
-
),
|
455
|
-
),
|
456
|
-
],
|
457
|
-
)
|
458
|
-
def test_reconcile(
|
459
|
-
desired_promotions: list[Promotion],
|
460
|
-
open_mrs: list[OpenBatcherMergeRequest],
|
461
|
-
expected_diff: Diff,
|
462
|
-
) -> None:
|
463
|
-
reconciler = Batcher()
|
464
|
-
diff = reconciler.reconcile(
|
465
|
-
desired_promotions=desired_promotions, open_mrs=open_mrs, batch_limit=5
|
466
|
-
)
|
467
|
-
|
468
|
-
# We do not care about the order. As the batcher is working on sets, this
|
469
|
-
# is not deterministic
|
470
|
-
assert len(diff.additions) == len(expected_diff.additions)
|
471
|
-
assert _aggregate_hashes(diff.additions) == _aggregate_hashes(
|
472
|
-
expected_diff.additions
|
473
|
-
)
|
474
|
-
assert _aggregate_channels(diff.additions) == _aggregate_channels(
|
475
|
-
expected_diff.additions
|
476
|
-
)
|
477
|
-
|
478
|
-
# Deletions are actually processed in a deterministic way.
|
479
|
-
assert len(diff.deletions) == len(expected_diff.deletions)
|
480
|
-
for i in range(len(diff.deletions)):
|
481
|
-
assert diff.deletions[i].mr.channels == expected_diff.deletions[i].mr.channels
|
482
|
-
assert (
|
483
|
-
diff.deletions[i].mr.content_hashes
|
484
|
-
== expected_diff.deletions[i].mr.content_hashes
|
485
|
-
)
|
486
|
-
assert (
|
487
|
-
diff.deletions[i].mr.failed_mr_check
|
488
|
-
== expected_diff.deletions[i].mr.failed_mr_check
|
489
|
-
)
|
490
|
-
assert (
|
491
|
-
diff.deletions[i].mr.is_batchable
|
492
|
-
== expected_diff.deletions[i].mr.is_batchable
|
493
|
-
)
|
494
|
-
assert diff.deletions[i].reason == expected_diff.deletions[i].reason
|
File without changes
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from collections.abc import (
|
3
|
-
Callable,
|
4
|
-
)
|
5
|
-
|
6
|
-
import pytest
|
7
|
-
|
8
|
-
|
9
|
-
@pytest.fixture
|
10
|
-
def file_contents() -> Callable[[str], tuple[str, str]]:
|
11
|
-
def contents(case: str) -> tuple[str, str]:
|
12
|
-
path = os.path.join(
|
13
|
-
os.path.dirname(__file__),
|
14
|
-
"files",
|
15
|
-
)
|
16
|
-
|
17
|
-
with open(f"{path}/{case}.yml", encoding="locale") as f:
|
18
|
-
a = f.read().strip()
|
19
|
-
|
20
|
-
with open(f"{path}/{case}.result.yml", encoding="locale") as f:
|
21
|
-
b = f.read().strip()
|
22
|
-
|
23
|
-
return (a, b)
|
24
|
-
|
25
|
-
return contents
|
@@ -1,37 +0,0 @@
|
|
1
|
-
from collections.abc import (
|
2
|
-
Callable,
|
3
|
-
Mapping,
|
4
|
-
)
|
5
|
-
|
6
|
-
from reconcile.saas_auto_promotions_manager.merge_request_manager.renderer import (
|
7
|
-
Renderer,
|
8
|
-
)
|
9
|
-
from reconcile.saas_auto_promotions_manager.subscriber import (
|
10
|
-
ConfigHash,
|
11
|
-
Subscriber,
|
12
|
-
)
|
13
|
-
|
14
|
-
|
15
|
-
def test_content_multiple_namespaces(
|
16
|
-
file_contents: Callable[[str], tuple[str, str]],
|
17
|
-
subscriber_builder: Callable[[Mapping], Subscriber],
|
18
|
-
):
|
19
|
-
subscriber = subscriber_builder({
|
20
|
-
"NAMESPACE": {"path": "/some/namespace.yml"},
|
21
|
-
"DESIRED_REF": "new_sha",
|
22
|
-
"DESIRED_TARGET_HASHES": [
|
23
|
-
ConfigHash(
|
24
|
-
channel="channel-a",
|
25
|
-
target_config_hash="new_hash",
|
26
|
-
parent_saas="parent_saas",
|
27
|
-
)
|
28
|
-
],
|
29
|
-
"CHANNELS": {"channel-a": {}},
|
30
|
-
})
|
31
|
-
saas_content, expected = file_contents("multiple_namespaces")
|
32
|
-
renderer = Renderer()
|
33
|
-
result = renderer.render_merge_request_content(
|
34
|
-
subscriber=subscriber,
|
35
|
-
current_content=saas_content,
|
36
|
-
)
|
37
|
-
assert result.strip() == expected.strip()
|
@@ -1,81 +0,0 @@
|
|
1
|
-
from collections.abc import (
|
2
|
-
Callable,
|
3
|
-
Mapping,
|
4
|
-
)
|
5
|
-
|
6
|
-
from reconcile.saas_auto_promotions_manager.merge_request_manager.renderer import (
|
7
|
-
Renderer,
|
8
|
-
)
|
9
|
-
from reconcile.saas_auto_promotions_manager.subscriber import (
|
10
|
-
ConfigHash,
|
11
|
-
Subscriber,
|
12
|
-
)
|
13
|
-
|
14
|
-
|
15
|
-
def test_content_single_namespace(
|
16
|
-
file_contents: Callable[[str], tuple[str, str]],
|
17
|
-
subscriber_builder: Callable[[Mapping], Subscriber],
|
18
|
-
):
|
19
|
-
subscriber = subscriber_builder({
|
20
|
-
"NAMESPACE": {"path": "/some/namespace.yml"},
|
21
|
-
"DESIRED_REF": "new_sha",
|
22
|
-
"DESIRED_TARGET_HASHES": [
|
23
|
-
ConfigHash(
|
24
|
-
channel="channel-a",
|
25
|
-
target_config_hash="current_hash",
|
26
|
-
parent_saas="parent_saas",
|
27
|
-
)
|
28
|
-
],
|
29
|
-
"CHANNELS": {"channel-a": {}},
|
30
|
-
})
|
31
|
-
saas_content, expected = file_contents("single_namespace")
|
32
|
-
renderer = Renderer()
|
33
|
-
result = renderer.render_merge_request_content(
|
34
|
-
subscriber=subscriber,
|
35
|
-
current_content=saas_content,
|
36
|
-
)
|
37
|
-
assert result.strip() == expected.strip()
|
38
|
-
|
39
|
-
|
40
|
-
def test_content_single_namespace_no_previous_hash(
|
41
|
-
file_contents: Callable[[str], tuple[str, str]],
|
42
|
-
subscriber_builder: Callable[[Mapping], Subscriber],
|
43
|
-
):
|
44
|
-
subscriber = subscriber_builder({
|
45
|
-
"NAMESPACE": {"path": "/some/namespace.yml"},
|
46
|
-
"DESIRED_REF": "new_sha",
|
47
|
-
"DESIRED_TARGET_HASHES": [
|
48
|
-
ConfigHash(
|
49
|
-
channel="channel-a",
|
50
|
-
target_config_hash="new_hash",
|
51
|
-
parent_saas="parent_saas",
|
52
|
-
)
|
53
|
-
],
|
54
|
-
"CHANNELS": {"channel-a": {}},
|
55
|
-
})
|
56
|
-
saas_content, expected = file_contents("single_namespace_no_hash")
|
57
|
-
renderer = Renderer()
|
58
|
-
result = renderer.render_merge_request_content(
|
59
|
-
subscriber=subscriber,
|
60
|
-
current_content=saas_content,
|
61
|
-
)
|
62
|
-
assert result.strip() == expected.strip()
|
63
|
-
|
64
|
-
|
65
|
-
def test_content_single_namespace_no_desired_hash(
|
66
|
-
file_contents: Callable[[str], tuple[str, str]],
|
67
|
-
subscriber_builder: Callable[[Mapping], Subscriber],
|
68
|
-
):
|
69
|
-
subscriber = subscriber_builder({
|
70
|
-
"NAMESPACE": {"path": "/some/namespace.yml"},
|
71
|
-
"DESIRED_REF": "new_sha",
|
72
|
-
"DESIRED_TARGET_HASHES": [],
|
73
|
-
"CHANNELS": {"channel-a": {}},
|
74
|
-
})
|
75
|
-
saas_content, expected = file_contents("single_namespace_ignore_hash")
|
76
|
-
renderer = Renderer()
|
77
|
-
result = renderer.render_merge_request_content(
|
78
|
-
subscriber=subscriber,
|
79
|
-
current_content=saas_content,
|
80
|
-
)
|
81
|
-
assert result.strip() == expected.strip()
|
@@ -1,61 +0,0 @@
|
|
1
|
-
from collections.abc import (
|
2
|
-
Callable,
|
3
|
-
Mapping,
|
4
|
-
)
|
5
|
-
|
6
|
-
from reconcile.saas_auto_promotions_manager.merge_request_manager.renderer import (
|
7
|
-
Renderer,
|
8
|
-
)
|
9
|
-
from reconcile.saas_auto_promotions_manager.subscriber import (
|
10
|
-
ConfigHash,
|
11
|
-
Subscriber,
|
12
|
-
)
|
13
|
-
|
14
|
-
|
15
|
-
def test_content_single_target(
|
16
|
-
file_contents: Callable[[str], tuple[str, str]],
|
17
|
-
subscriber_builder: Callable[[Mapping], Subscriber],
|
18
|
-
):
|
19
|
-
subscriber = subscriber_builder({
|
20
|
-
"NAMESPACE": {"path": "/some/namespace.yml"},
|
21
|
-
"DESIRED_REF": "new_sha",
|
22
|
-
"DESIRED_TARGET_HASHES": [
|
23
|
-
ConfigHash(
|
24
|
-
channel="channel-a",
|
25
|
-
target_config_hash="new_hash",
|
26
|
-
parent_saas="parent_saas",
|
27
|
-
)
|
28
|
-
],
|
29
|
-
})
|
30
|
-
saas_content, expected = file_contents("single_target")
|
31
|
-
renderer = Renderer()
|
32
|
-
result = renderer.render_merge_request_content(
|
33
|
-
subscriber=subscriber,
|
34
|
-
current_content=saas_content,
|
35
|
-
)
|
36
|
-
assert result.strip() == expected.strip()
|
37
|
-
|
38
|
-
|
39
|
-
def test_must_not_line_wrap(
|
40
|
-
file_contents: Callable[[str], tuple[str, str]],
|
41
|
-
subscriber_builder: Callable[[Mapping], Subscriber],
|
42
|
-
):
|
43
|
-
namespace_name = "/services/sosososolong/namespaces/loooooooooooooooooooooooooooooooooooooooooooooooooooooooooong.yml"
|
44
|
-
subscriber = subscriber_builder({
|
45
|
-
"NAMESPACE": {"path": namespace_name},
|
46
|
-
"DESIRED_REF": "new_sha",
|
47
|
-
"DESIRED_TARGET_HASHES": [
|
48
|
-
ConfigHash(
|
49
|
-
channel="channel-a",
|
50
|
-
target_config_hash="new_hash",
|
51
|
-
parent_saas="parent_saas",
|
52
|
-
)
|
53
|
-
],
|
54
|
-
})
|
55
|
-
saas_content, expected = file_contents("single_target_long_name")
|
56
|
-
renderer = Renderer()
|
57
|
-
result = renderer.render_merge_request_content(
|
58
|
-
subscriber=subscriber,
|
59
|
-
current_content=saas_content,
|
60
|
-
)
|
61
|
-
assert result.strip() == expected.strip()
|