qontract-reconcile 0.10.1rc1202__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.
Files changed (138) hide show
  1. qontract_reconcile-0.10.2.dev1.dist-info/METADATA +500 -0
  2. {qontract_reconcile-0.10.1rc1202.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/RECORD +12 -130
  3. {qontract_reconcile-0.10.1rc1202.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/WHEEL +1 -2
  4. {qontract_reconcile-0.10.1rc1202.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/entry_points.txt +1 -0
  5. reconcile/aws_account_manager/README.md +5 -0
  6. reconcile/change_owners/README.md +34 -0
  7. reconcile/glitchtip/README.md +150 -0
  8. reconcile/gql_definitions/introspection.json +51176 -0
  9. reconcile/run_integration.py +293 -0
  10. reconcile/utils/binary.py +2 -2
  11. reconcile/utils/mr/README.md +198 -0
  12. reconcile/utils/oc_map.py +2 -2
  13. tools/qontract_cli.py +0 -0
  14. qontract_reconcile-0.10.1rc1202.dist-info/METADATA +0 -64
  15. qontract_reconcile-0.10.1rc1202.dist-info/top_level.txt +0 -3
  16. reconcile/test/__init__.py +0 -0
  17. reconcile/test/conftest.py +0 -157
  18. reconcile/test/fixtures.py +0 -24
  19. reconcile/test/saas_auto_promotions_manager/__init__.py +0 -0
  20. reconcile/test/saas_auto_promotions_manager/conftest.py +0 -170
  21. reconcile/test/saas_auto_promotions_manager/merge_request_manager/__init__.py +0 -0
  22. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/__init__.py +0 -0
  23. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/conftest.py +0 -115
  24. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/data_keys.py +0 -19
  25. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_desired_state.py +0 -66
  26. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_merge_request_manager.py +0 -86
  27. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_mr_parser.py +0 -352
  28. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_reconciler.py +0 -494
  29. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/__init__.py +0 -0
  30. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/conftest.py +0 -25
  31. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_multiple_namespaces.py +0 -37
  32. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_namespace.py +0 -81
  33. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_target.py +0 -61
  34. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_json_path_selector.py +0 -74
  35. reconcile/test/saas_auto_promotions_manager/test_integration_test.py +0 -52
  36. reconcile/test/saas_auto_promotions_manager/utils/__init__.py +0 -0
  37. reconcile/test/test_acs_notifiers.py +0 -393
  38. reconcile/test/test_acs_policies.py +0 -497
  39. reconcile/test/test_acs_rbac.py +0 -865
  40. reconcile/test/test_aggregated_list.py +0 -237
  41. reconcile/test/test_amtool.py +0 -37
  42. reconcile/test/test_aws_ami_cleanup.py +0 -230
  43. reconcile/test/test_aws_ami_share.py +0 -68
  44. reconcile/test/test_aws_cloudwatch_log_retention.py +0 -434
  45. reconcile/test/test_aws_iam_keys.py +0 -70
  46. reconcile/test/test_aws_iam_password_reset.py +0 -35
  47. reconcile/test/test_aws_support_cases_sos.py +0 -23
  48. reconcile/test/test_checkpoint.py +0 -178
  49. reconcile/test/test_cli.py +0 -41
  50. reconcile/test/test_closedbox_endpoint_monitoring.py +0 -207
  51. reconcile/test/test_dashdotdb_dora.py +0 -245
  52. reconcile/test/test_database_access_manager.py +0 -660
  53. reconcile/test/test_deadmanssnitch.py +0 -290
  54. reconcile/test/test_gabi_authorized_users.py +0 -72
  55. reconcile/test/test_gcr_mirror.py +0 -14
  56. reconcile/test/test_github_org.py +0 -156
  57. reconcile/test/test_github_repo_invites.py +0 -119
  58. reconcile/test/test_gitlab_housekeeping.py +0 -333
  59. reconcile/test/test_gitlab_labeler.py +0 -126
  60. reconcile/test/test_gitlab_members.py +0 -219
  61. reconcile/test/test_gitlab_permissions.py +0 -164
  62. reconcile/test/test_instrumented_wrappers.py +0 -18
  63. reconcile/test/test_integrations_manager.py +0 -1252
  64. reconcile/test/test_jenkins_worker_fleets.py +0 -57
  65. reconcile/test/test_jira_permissions_validator.py +0 -519
  66. reconcile/test/test_jump_host.py +0 -114
  67. reconcile/test/test_ldap_users.py +0 -125
  68. reconcile/test/test_make.py +0 -28
  69. reconcile/test/test_ocm_additional_routers.py +0 -133
  70. reconcile/test/test_ocm_clusters.py +0 -798
  71. reconcile/test/test_ocm_clusters_manifest_updates.py +0 -87
  72. reconcile/test/test_ocm_machine_pools.py +0 -1103
  73. reconcile/test/test_ocm_update_recommended_version.py +0 -145
  74. reconcile/test/test_ocm_upgrade_scheduler_org_updater.py +0 -125
  75. reconcile/test/test_openshift_base.py +0 -1269
  76. reconcile/test/test_openshift_cluster_bots.py +0 -240
  77. reconcile/test/test_openshift_namespace_labels.py +0 -344
  78. reconcile/test/test_openshift_namespaces.py +0 -256
  79. reconcile/test/test_openshift_resource.py +0 -443
  80. reconcile/test/test_openshift_resources_base.py +0 -478
  81. reconcile/test/test_openshift_saas_deploy.py +0 -188
  82. reconcile/test/test_openshift_saas_deploy_change_tester.py +0 -308
  83. reconcile/test/test_openshift_saas_deploy_trigger_cleaner.py +0 -65
  84. reconcile/test/test_openshift_serviceaccount_tokens.py +0 -282
  85. reconcile/test/test_openshift_tekton_resources.py +0 -265
  86. reconcile/test/test_openshift_upgrade_watcher.py +0 -223
  87. reconcile/test/test_prometheus_rules_tester.py +0 -151
  88. reconcile/test/test_quay_membership.py +0 -86
  89. reconcile/test/test_quay_mirror.py +0 -172
  90. reconcile/test/test_quay_mirror_org.py +0 -82
  91. reconcile/test/test_quay_repos.py +0 -59
  92. reconcile/test/test_queries.py +0 -53
  93. reconcile/test/test_repo_owners.py +0 -47
  94. reconcile/test/test_requests_sender.py +0 -139
  95. reconcile/test/test_saasherder.py +0 -1611
  96. reconcile/test/test_saasherder_allowed_secret_paths.py +0 -125
  97. reconcile/test/test_secret_reader.py +0 -153
  98. reconcile/test/test_slack_base.py +0 -183
  99. reconcile/test/test_slack_usergroups.py +0 -785
  100. reconcile/test/test_sql_query.py +0 -316
  101. reconcile/test/test_status_board.py +0 -258
  102. reconcile/test/test_terraform_aws_route53.py +0 -29
  103. reconcile/test/test_terraform_cloudflare_dns.py +0 -117
  104. reconcile/test/test_terraform_cloudflare_resources.py +0 -408
  105. reconcile/test/test_terraform_cloudflare_users.py +0 -747
  106. reconcile/test/test_terraform_repo.py +0 -440
  107. reconcile/test/test_terraform_resources.py +0 -519
  108. reconcile/test/test_terraform_tgw_attachments.py +0 -1295
  109. reconcile/test/test_terraform_users.py +0 -152
  110. reconcile/test/test_terraform_vpc_peerings.py +0 -576
  111. reconcile/test/test_terraform_vpc_peerings_build_desired_state.py +0 -1434
  112. reconcile/test/test_three_way_diff_strategy.py +0 -131
  113. reconcile/test/test_utils_jinja2.py +0 -130
  114. reconcile/test/test_vault_replication.py +0 -534
  115. reconcile/test/test_vault_utils.py +0 -47
  116. reconcile/test/test_version_bump.py +0 -18
  117. reconcile/test/test_vpc_peerings_validator.py +0 -194
  118. reconcile/test/test_wrong_region.py +0 -78
  119. release/__init__.py +0 -0
  120. release/test_version.py +0 -50
  121. release/version.py +0 -104
  122. tools/cli_commands/test/__init__.py +0 -0
  123. tools/cli_commands/test/conftest.py +0 -332
  124. tools/cli_commands/test/test_aws_cost_report.py +0 -258
  125. tools/cli_commands/test/test_cost_management_api.py +0 -326
  126. tools/cli_commands/test/test_gpg_encrypt.py +0 -235
  127. tools/cli_commands/test/test_openshift_cost_optimization_report.py +0 -255
  128. tools/cli_commands/test/test_openshift_cost_report.py +0 -295
  129. tools/cli_commands/test/test_util.py +0 -70
  130. tools/test/__init__.py +0 -0
  131. tools/test/conftest.py +0 -77
  132. tools/test/test_app_interface_metrics_exporter.py +0 -48
  133. tools/test/test_erv2.py +0 -80
  134. tools/test/test_get_container_images.py +0 -230
  135. tools/test/test_qontract_cli.py +0 -197
  136. tools/test/test_saas_promotion_state.py +0 -187
  137. tools/test/test_sd_app_sre_alert_report.py +0 -74
  138. tools/test/test_sre_checkpoints.py +0 -79
@@ -1,798 +0,0 @@
1
- # ruff: noqa: SIM117
2
- import typing
3
- from unittest.mock import patch
4
-
5
- import pytest
6
- from pydantic import ValidationError
7
- from pytest_mock import MockerFixture
8
-
9
- import reconcile.ocm_clusters as occ
10
- import reconcile.utils.ocm as ocmmod
11
- from reconcile import (
12
- mr_client_gateway,
13
- queries,
14
- )
15
- from reconcile.ocm.types import (
16
- ClusterMachinePool,
17
- OCMClusterNetwork,
18
- OCMSpec,
19
- OSDClusterSpec,
20
- ROSAClusterSpec,
21
- )
22
- from reconcile.test.fixtures import Fixtures
23
- from reconcile.utils.mr.clusters_updates import CreateClustersUpdates
24
- from reconcile.utils.ocm import (
25
- OCM,
26
- SPEC_ATTR_CONSOLE_URL,
27
- SPEC_ATTR_SERVER_URL,
28
- OCMMap,
29
- ocm,
30
- products,
31
- )
32
- from reconcile.utils.ocm.products import (
33
- OCM_PRODUCT_OSD,
34
- OCM_PRODUCT_ROSA,
35
- OCMProductOsd,
36
- OCMProductPortfolio,
37
- OCMProductRosa,
38
- )
39
- from reconcile.utils.ocm_base_client import OCMBaseClient
40
-
41
- fxt = Fixtures("clusters")
42
-
43
-
44
- @pytest.fixture
45
- def ocm_osd_cluster_raw_spec():
46
- return fxt.get_anymarkup("osd_spec.json")
47
-
48
-
49
- @pytest.fixture
50
- def ocm_osd_cluster_ai_spec():
51
- return fxt.get_anymarkup("osd_spec_ai.yml")
52
-
53
-
54
- @pytest.fixture
55
- def ocm_osd_cluster_post_spec():
56
- return fxt.get_anymarkup("osd_spec_post.json")
57
-
58
-
59
- @pytest.fixture
60
- def ocm_rosa_cluster_raw_spec():
61
- return fxt.get_anymarkup("rosa_spec.json")
62
-
63
-
64
- @pytest.fixture
65
- def ocm_rosa_cluster_ai_spec():
66
- return fxt.get_anymarkup("rosa_spec_ai.yml")
67
-
68
-
69
- @pytest.fixture
70
- def ocm_rosa_cluster_post_spec():
71
- return fxt.get_anymarkup("rosa_spec_post.json")
72
-
73
-
74
- @pytest.fixture
75
- def ocm_osd_cluster_spec():
76
- n = OCMClusterNetwork(
77
- type="OpenShiftSDN",
78
- vpc="10.112.0.0/16",
79
- service="10.120.0.0/16",
80
- pod="10.128.0.0/14",
81
- )
82
- spec = OSDClusterSpec(
83
- product="osd",
84
- channel="stable",
85
- disable_user_workload_monitoring=True,
86
- external_id="the-cluster-external_id",
87
- id="the-cluster-id",
88
- multi_az=False,
89
- private=False,
90
- provision_shard_id="the-cluster-provision_shard_id",
91
- region="us-east-1",
92
- version="4.10.0",
93
- load_balancers=5,
94
- storage=1100,
95
- provider="aws",
96
- )
97
- machine_pools = [
98
- ClusterMachinePool(
99
- id="worker",
100
- instance_type="m5.xlarge",
101
- replicas=5,
102
- )
103
- ]
104
- obj = OCMSpec(
105
- spec=spec,
106
- machine_pools=machine_pools,
107
- network=n,
108
- domain="devshift.net",
109
- server_url="https://api.test-cluster.0000.p1.openshiftapps.com:6443",
110
- console_url="https://console-openshift-console.test-cluster.0000.p1.openshiftapps.com",
111
- )
112
- yield obj
113
-
114
-
115
- @pytest.fixture
116
- def osd_cluster_fxt():
117
- return {
118
- "spec": {
119
- "product": "osd",
120
- "storage": 1100,
121
- "load_balancers": 5,
122
- "id": "the-cluster-id",
123
- "external_id": "the-cluster-external_id",
124
- "provider": "aws",
125
- "region": "us-east-1",
126
- "channel": "stable",
127
- "version": "4.10.0",
128
- "initial_version": "4.9.0-candidate",
129
- "multi_az": False,
130
- "private": False,
131
- "provision_shard_id": "the-cluster-provision_shard_id",
132
- "disable_user_workload_monitoring": True,
133
- },
134
- "machinePools": [
135
- {
136
- "id": "worker",
137
- "instance_type": "m5.xlarge",
138
- "replicas": 5,
139
- }
140
- ],
141
- "network": {
142
- "type": None,
143
- "vpc": "10.112.0.0/16",
144
- "service": "10.120.0.0/16",
145
- "pod": "10.128.0.0/14",
146
- },
147
- "ocm": {
148
- "name": "non-existent-ocm",
149
- "environment": {
150
- "name": "name",
151
- "url": "https://api.non-existent-ocm.com",
152
- "accessTokenClientId": "cloud-services",
153
- "accessTokenUrl": "https://sso.blah.com/token",
154
- "accessTokenClientSecret": {
155
- "path": "a-secret-path",
156
- "field": "client_secret",
157
- "format": None,
158
- "version": None,
159
- },
160
- },
161
- "orgId": "org_id",
162
- "accessTokenClientId": "cloud-services",
163
- "accessTokenUrl": "https://sso.blah.com/token",
164
- "accessTokenClientSecret": {
165
- "path": "a-secret-path",
166
- "field": "client_secret",
167
- "format": None,
168
- "version": None,
169
- },
170
- "blockedVersions": ["^.*-fc\\..*$"],
171
- },
172
- "consoleUrl": "https://console-openshift-console.test-cluster.0000.p1.openshiftapps.com",
173
- "serverUrl": "https://api.test-cluster.0000.p1.openshiftapps.com:6443",
174
- "elbFQDN": "elb.test-cluster.0000.p1.openshiftapps.com",
175
- "path": "the-cluster-path",
176
- "name": "cluster1",
177
- "id": "anid",
178
- "managed": True,
179
- "state": "ready",
180
- }
181
-
182
-
183
- @pytest.fixture
184
- def rosa_cluster_fxt():
185
- return {
186
- "spec": {
187
- "product": "rosa",
188
- "account": {
189
- "uid": "123123123",
190
- "rosa": {
191
- "creator_role_arn": "creator_role",
192
- "sts": {
193
- "installer_role_arn": "installer_role",
194
- "support_role_arn": " support_role",
195
- "controlplane_role_arn": "controlplane_role",
196
- "worker_role_arn": "worker_role",
197
- },
198
- },
199
- },
200
- "id": "the-cluster-id",
201
- "external_id": "the-cluster-external_id",
202
- "provider": "aws",
203
- "region": "us-east-1",
204
- "channel": "stable",
205
- "version": "4.10.0",
206
- "initial_version": "4.9.0-candidate",
207
- "multi_az": False,
208
- "private": False,
209
- "provision_shard_id": "the-cluster-provision_shard_id",
210
- "disable_user_workload_monitoring": True,
211
- },
212
- "machinePools": [
213
- {
214
- "id": "worker",
215
- "instance_type": "m5.xlarge",
216
- "replicas": 5,
217
- },
218
- ],
219
- "network": {
220
- "type": None,
221
- "vpc": "10.112.0.0/16",
222
- "service": "10.120.0.0/16",
223
- "pod": "10.128.0.0/14",
224
- },
225
- "ocm": {
226
- "name": "non-existent-ocm",
227
- "environment": {
228
- "name": "name",
229
- "url": "https://api.non-existent-ocm.com",
230
- "accessTokenClientId": "cloud-services",
231
- "accessTokenUrl": "https://sso.blah.com/token",
232
- "accessTokenClientSecret": {
233
- "path": "a-secret-path",
234
- "field": "client_secret",
235
- "format": None,
236
- "version": None,
237
- },
238
- },
239
- "orgId": "org_id",
240
- "accessTokenClientId": "cloud-services",
241
- "accessTokenUrl": "https://sso.blah.com/token",
242
- "accessTokenClientSecret": {
243
- "path": "a-secret-path",
244
- "field": "client_secret",
245
- "format": None,
246
- "version": None,
247
- },
248
- "blockedVersions": ["^.*-fc\\..*$"],
249
- },
250
- "consoleUrl": "https://console-openshift-console.0000.p1.openshiftapps.com",
251
- "serverUrl": "https://api.tst-jpr-rosa.0000.p1.openshiftapps.com:6443",
252
- "elbFQDN": "elb.tst-jpr-rosa.0000.p1.openshiftapps.com",
253
- "path": "the-cluster-path",
254
- "name": "cluster1",
255
- "id": "anid",
256
- "managed": True,
257
- "state": "ready",
258
- }
259
-
260
-
261
- @pytest.fixture
262
- def rosa_hosted_cp_cluster_fxt():
263
- return {
264
- "spec": {
265
- "product": "rosa",
266
- "account": {
267
- "uid": "123123123",
268
- "rosa": {
269
- "creator_role_arn": "creator_role",
270
- "sts": {
271
- "installer_role_arn": "installer_role",
272
- "support_role_arn": " support_role",
273
- "worker_role_arn": "worker_role",
274
- },
275
- },
276
- },
277
- "id": "the-cluster-id",
278
- "external_id": "the-cluster-external_id",
279
- "provider": "aws",
280
- "region": "us-east-1",
281
- "channel": "stable",
282
- "version": "4.10.0",
283
- "initial_version": "4.9.0-candidate",
284
- "multi_az": False,
285
- "nodes": 5,
286
- "instance_type": "m5.xlarge",
287
- "private": False,
288
- "provision_shard_id": "the-cluster-provision_shard_id",
289
- "disable_user_workload_monitoring": True,
290
- "hypershift": True,
291
- },
292
- "network": {
293
- "type": None,
294
- "vpc": "10.112.0.0/16",
295
- "service": "10.120.0.0/16",
296
- "pod": "10.128.0.0/14",
297
- },
298
- "ocm": {
299
- "name": "non-existent-ocm",
300
- "orgId": "org_id",
301
- "environment": {
302
- "name": "name",
303
- "url": "https://api.non-existent-ocm.com",
304
- "accessTokenClientId": "cloud-services",
305
- "accessTokenUrl": "https://sso.blah.com/token",
306
- "accessTokenClientSecret": {
307
- "path": "a-secret-path",
308
- "field": "offline_token",
309
- "format": None,
310
- "version": None,
311
- },
312
- },
313
- "blockedVersions": ["^.*-fc\\..*$"],
314
- },
315
- "consoleUrl": "the-cluster-console_url",
316
- "serverUrl": "the-cluster-server_url",
317
- "elbFQDN": "the-cluster-elbFQDN",
318
- "path": "the-cluster-path",
319
- "name": "cluster1",
320
- "id": "anid",
321
- "managed": True,
322
- "state": "ready",
323
- }
324
-
325
-
326
- @pytest.fixture
327
- def queries_mock(osd_cluster_fxt):
328
- with patch.object(queries, "get_app_interface_settings", autospec=True) as s:
329
- with patch.object(queries, "get_clusters", autospec=True) as gc:
330
- s.return_value = {}
331
- gc.return_value = [osd_cluster_fxt]
332
- yield s, gc
333
-
334
-
335
- @pytest.fixture
336
- def ocmmap_mock(ocm_osd_cluster_spec, ocm_mock):
337
- with patch.object(OCMMap, "get", autospec=True) as get:
338
- with patch.object(OCMMap, "init_ocm_client_from_cluster", autospec=True):
339
- with patch.object(OCMMap, "cluster_specs", autospec=True) as cs:
340
- get.return_value = ocm_mock
341
- cs.return_value = ({"cluster1": ocm_osd_cluster_spec}, {})
342
- yield get, cs
343
-
344
-
345
- @pytest.fixture
346
- def ocm_mock(mocker: MockerFixture):
347
- with patch.object(OCM, "whoami", autospec=True):
348
- with patch.object(ocm, "init_ocm_base_client") as ioc:
349
- ocm_api_mock = mocker.Mock(OCMBaseClient)
350
- ioc.return_value = ocm_api_mock
351
- yield ocm_api_mock.post, ocm_api_mock.patch
352
- # todo check if we need this realy!!!
353
- # with patch.object(OCM, "get_product_impl", autospec=True) as gpi:
354
- # gpi.return_value = osd_product
355
- # yield _post, _patch
356
-
357
-
358
- @pytest.fixture
359
- def cluster_updates_mr_mock():
360
- with patch.object(mr_client_gateway, "init", autospec=True):
361
- with patch.object(CreateClustersUpdates, "submit", autospec=True) as ccu:
362
- yield ccu
363
-
364
-
365
- @pytest.fixture
366
- def get_json_mock():
367
- with patch.object(OCM, "_get_json", autospec=True) as get_json:
368
- yield get_json
369
-
370
-
371
- @pytest.fixture
372
- def osd_product() -> typing.Generator[OCMProductOsd, None, None]:
373
- with patch.object(products, "get_provisioning_shard_id") as g:
374
- g.return_value = "provision_shard_id"
375
- yield OCMProductOsd()
376
-
377
-
378
- @pytest.fixture
379
- def rosa_product() -> typing.Generator[OCMProductRosa, None, None]:
380
- with patch.object(products, "get_provisioning_shard_id") as g:
381
- g.return_value = "provision_shard_id"
382
- yield OCMProductRosa(None)
383
-
384
-
385
- @pytest.fixture
386
- def product_portfolio(
387
- osd_product: OCMProductOsd, rosa_product: OCMProductRosa
388
- ) -> OCMProductPortfolio:
389
- return OCMProductPortfolio(
390
- products={
391
- OCM_PRODUCT_OSD: osd_product,
392
- OCM_PRODUCT_ROSA: rosa_product,
393
- }
394
- )
395
-
396
-
397
- @pytest.fixture
398
- def integration(
399
- product_portfolio: OCMProductPortfolio,
400
- ) -> typing.Generator[occ.OcmClusters, None, None]:
401
- integration = occ.OcmClusters(
402
- params=occ.OcmClustersParams(
403
- job_controller_cluster="cluster",
404
- job_controller_namespace="namespace",
405
- rosa_job_image="image",
406
- rosa_job_service_account="service_account",
407
- rosa_role="role",
408
- gitlab_project_id=None,
409
- thread_pool_size=1,
410
- )
411
- )
412
- with patch.object(
413
- integration, "assemble_product_portfolio", return_value=product_portfolio
414
- ):
415
- yield integration
416
-
417
-
418
- def test_ocm_spec_population_rosa(rosa_cluster_fxt):
419
- n = OCMSpec(**rosa_cluster_fxt)
420
- assert isinstance(n.spec, ROSAClusterSpec)
421
-
422
-
423
- def test_ocm_spec_population_hcp(rosa_hosted_cp_cluster_fxt):
424
- n = OCMSpec(**rosa_hosted_cp_cluster_fxt)
425
- assert isinstance(n.spec, ROSAClusterSpec)
426
-
427
-
428
- def test_ocm_spec_population_osd(osd_cluster_fxt):
429
- n = OCMSpec(**osd_cluster_fxt)
430
- assert isinstance(n.spec, OSDClusterSpec)
431
- assert n.server_url == osd_cluster_fxt[SPEC_ATTR_SERVER_URL]
432
- assert n.console_url == osd_cluster_fxt[SPEC_ATTR_CONSOLE_URL]
433
-
434
-
435
- def test_ocm_spec_population_osd_with_extra(osd_cluster_fxt):
436
- osd_cluster_fxt["spec"]["extra_attribute"] = True
437
- with pytest.raises(ValidationError):
438
- OCMSpec(**osd_cluster_fxt)
439
-
440
-
441
- def test_get_ocm_cluster_update_spec_no_changes(
442
- osd_product: OCMProductOsd, ocm_osd_cluster_spec: OCMSpec
443
- ):
444
- current_spec = ocm_osd_cluster_spec
445
- desired_spec = ocm_osd_cluster_spec
446
- upd, err = occ.get_cluster_ocm_update_spec(
447
- osd_product, "cluster1", current_spec, desired_spec
448
- )
449
- assert (upd, err) == ({}, False)
450
-
451
-
452
- def test_get_ocm_cluster_update_spec_network_banned(
453
- osd_product: OCMProductOsd, ocm_osd_cluster_spec: OCMSpec
454
- ):
455
- current_spec = ocm_osd_cluster_spec
456
- desired_spec = current_spec.copy(deep=True)
457
- desired_spec.network.vpc = "0.0.0.0/0"
458
- _, err = occ.get_cluster_ocm_update_spec(
459
- osd_product, "cluster1", current_spec, desired_spec
460
- )
461
- assert err is True
462
-
463
-
464
- def test_get_ocm_cluster_update_spec_network_type_ignored(
465
- osd_product: OCMProductOsd, ocm_osd_cluster_spec: OCMSpec
466
- ):
467
- current_spec = ocm_osd_cluster_spec
468
- desired_spec = current_spec.copy(deep=True)
469
- desired_spec.network.type = "OVNKubernetes"
470
- upd, err = occ.get_cluster_ocm_update_spec(
471
- osd_product, "cluster1", current_spec, desired_spec
472
- )
473
- assert (upd, err) == ({}, False)
474
-
475
-
476
- @typing.no_type_check
477
- def test_get_ocm_cluster_update_spec_allowed_change(
478
- osd_product: OCMProductOsd, ocm_osd_cluster_spec: OCMSpec
479
- ):
480
- current_spec = ocm_osd_cluster_spec
481
- desired_spec = current_spec.copy(deep=True)
482
- desired_spec.spec.storage = 2000
483
- upd, err = occ.get_cluster_ocm_update_spec(
484
- osd_product, "cluster1", current_spec, desired_spec
485
- )
486
- assert (upd, err) == ({ocmmod.SPEC_ATTR_STORAGE: 2000}, False)
487
-
488
-
489
- def test_get_ocm_cluster_update_spec_not_allowed_change(
490
- osd_product: OCMProductOsd, ocm_osd_cluster_spec: OCMSpec
491
- ):
492
- current_spec = ocm_osd_cluster_spec
493
- desired_spec = current_spec.copy(deep=True)
494
- desired_spec.spec.multi_az = not desired_spec.spec.multi_az
495
- upd, err = occ.get_cluster_ocm_update_spec(
496
- osd_product, "cluster1", current_spec, desired_spec
497
- )
498
- assert (upd, err) == (
499
- {ocmmod.SPEC_ATTR_MULTI_AZ: desired_spec.spec.multi_az},
500
- True,
501
- )
502
-
503
-
504
- def test_get_ocm_cluster_update_spec_disable_uwm(
505
- osd_product: OCMProductOsd, ocm_osd_cluster_spec: OCMSpec
506
- ):
507
- current_spec = ocm_osd_cluster_spec
508
- desired_spec = current_spec.copy(deep=True)
509
- desired_spec.spec.disable_user_workload_monitoring = (
510
- not desired_spec.spec.disable_user_workload_monitoring
511
- )
512
- upd, err = occ.get_cluster_ocm_update_spec(
513
- osd_product, "cluster1", current_spec, desired_spec
514
- )
515
- assert (upd, err) == (
516
- {
517
- ocmmod.SPEC_ATTR_DISABLE_UWM: desired_spec.spec.disable_user_workload_monitoring
518
- },
519
- False,
520
- )
521
-
522
-
523
- def test_noop_dry_run(
524
- integration: occ.OcmClusters,
525
- queries_mock,
526
- ocmmap_mock,
527
- ocm_mock,
528
- cluster_updates_mr_mock,
529
- ) -> None:
530
- with pytest.raises(SystemExit):
531
- integration.run(False)
532
- # If get has not been called means no action has been performed
533
- _post, _patch = ocm_mock
534
- assert _post.call_count == 0
535
- assert _patch.call_count == 0
536
- assert cluster_updates_mr_mock.call_count == 0
537
-
538
-
539
- def test_changed_id(
540
- integration: occ.OcmClusters,
541
- get_json_mock,
542
- queries_mock,
543
- ocm_mock,
544
- ocm_osd_cluster_raw_spec,
545
- ocm_osd_cluster_ai_spec,
546
- cluster_updates_mr_mock,
547
- ) -> None:
548
- # App Interface attributes are only considered if are null or blank
549
- # Won't be better to update them if have changed?
550
- ocm_osd_cluster_ai_spec["spec"]["id"] = ""
551
- queries_mock[1].return_value = [ocm_osd_cluster_ai_spec]
552
- get_json_mock.return_value = {"items": [ocm_osd_cluster_raw_spec]}
553
-
554
- with pytest.raises(SystemExit):
555
- integration.run(dry_run=False)
556
- _post, _patch = ocm_mock
557
- assert _post.call_count == 0
558
- assert _patch.call_count == 0
559
- assert cluster_updates_mr_mock.call_count == 1
560
-
561
-
562
- def test_ocm_osd_create_cluster(
563
- integration: occ.OcmClusters,
564
- get_json_mock,
565
- queries_mock,
566
- ocm_mock,
567
- cluster_updates_mr_mock,
568
- ocm_osd_cluster_ai_spec,
569
- ocm_osd_cluster_post_spec,
570
- ):
571
- get_json_mock.return_value = {"items": []}
572
- queries_mock[1].return_value = [ocm_osd_cluster_ai_spec]
573
-
574
- with pytest.raises(SystemExit) as sys_exit:
575
- integration.run(dry_run=False)
576
-
577
- assert sys_exit.value.code == 0
578
- _post, _patch = ocm_mock
579
- _post.assert_called_once_with(
580
- "/api/clusters_mgmt/v1/clusters",
581
- ocm_osd_cluster_post_spec,
582
- {},
583
- )
584
- _patch.assert_not_called()
585
- cluster_updates_mr_mock.assert_not_called()
586
-
587
-
588
- def test_ocm_osd_create_cluster_without_machine_pools(
589
- integration: occ.OcmClusters,
590
- get_json_mock,
591
- queries_mock,
592
- ocm_mock,
593
- cluster_updates_mr_mock,
594
- ocm_osd_cluster_ai_spec,
595
- ocm_osd_cluster_post_spec,
596
- ):
597
- get_json_mock.return_value = {"items": []}
598
- bad_spec = ocm_osd_cluster_ai_spec | {"machinePools": []}
599
- queries_mock[1].return_value = [bad_spec]
600
-
601
- with pytest.raises(SystemExit) as sys_exit:
602
- integration.run(dry_run=False)
603
-
604
- assert sys_exit.value.code == 1
605
- _post, _patch = ocm_mock
606
- _post.assert_not_called()
607
- _patch.assert_not_called()
608
- cluster_updates_mr_mock.assert_not_called()
609
-
610
-
611
- def test_ocm_rosa_update_cluster(
612
- integration: occ.OcmClusters,
613
- get_json_mock,
614
- queries_mock,
615
- ocm_mock,
616
- cluster_updates_mr_mock,
617
- ocm_rosa_cluster_raw_spec,
618
- ocm_rosa_cluster_ai_spec,
619
- ):
620
- ocm_rosa_cluster_ai_spec["spec"]["channel"] = "rapid"
621
- get_json_mock.return_value = {"items": [ocm_rosa_cluster_raw_spec]}
622
- queries_mock[1].return_value = [ocm_rosa_cluster_ai_spec]
623
- with pytest.raises(SystemExit):
624
- integration.run(dry_run=False)
625
- _post, _patch = ocm_mock
626
- assert _post.call_count == 0
627
- assert _patch.call_count == 1
628
- assert cluster_updates_mr_mock.call_count == 0
629
-
630
-
631
- def test_ocm_rosa_update_cluster_dont_update_ocm_on_oidc_drift(
632
- integration: occ.OcmClusters,
633
- get_json_mock,
634
- queries_mock,
635
- ocm_mock,
636
- cluster_updates_mr_mock,
637
- ocm_rosa_cluster_raw_spec,
638
- ocm_rosa_cluster_ai_spec,
639
- ):
640
- ocm_rosa_cluster_ai_spec["spec"]["oidc_endpoint_url"] = "some-other-oidc-url"
641
- get_json_mock.return_value = {"items": [ocm_rosa_cluster_raw_spec]}
642
- queries_mock[1].return_value = [ocm_rosa_cluster_ai_spec]
643
- with pytest.raises(SystemExit):
644
- integration.run(dry_run=False)
645
- _post, _patch = ocm_mock
646
- assert _post.call_count == 0
647
- assert _patch.call_count == 0
648
- assert cluster_updates_mr_mock.call_count == 1
649
-
650
-
651
- def test_ocm_rosa_update_cluster_with_machine_pools_change(
652
- integration: occ.OcmClusters,
653
- get_json_mock,
654
- queries_mock,
655
- ocm_mock,
656
- cluster_updates_mr_mock,
657
- ocm_rosa_cluster_raw_spec,
658
- ocm_rosa_cluster_ai_spec,
659
- ):
660
- new_spec = ocm_rosa_cluster_ai_spec | {
661
- "machinePools": [
662
- {
663
- "id": "new",
664
- "instance_type": "m5.xlarge",
665
- "replicas": 1,
666
- }
667
- ]
668
- }
669
- get_json_mock.return_value = {"items": [ocm_rosa_cluster_raw_spec]}
670
- queries_mock[1].return_value = [new_spec]
671
-
672
- with pytest.raises(SystemExit):
673
- integration.run(dry_run=False)
674
-
675
- _post, _patch = ocm_mock
676
- _post.assert_not_called()
677
- _patch.assert_not_called()
678
- cluster_updates_mr_mock.assert_not_called()
679
-
680
-
681
- def test_ocm_osd_update_cluster(
682
- integration: occ.OcmClusters,
683
- get_json_mock,
684
- queries_mock,
685
- ocm_mock,
686
- cluster_updates_mr_mock,
687
- ocm_osd_cluster_raw_spec,
688
- ocm_osd_cluster_ai_spec,
689
- ):
690
- ocm_osd_cluster_ai_spec["spec"]["storage"] = 40000
691
- get_json_mock.return_value = {"items": [ocm_osd_cluster_raw_spec]}
692
- queries_mock[1].return_value = [ocm_osd_cluster_ai_spec]
693
- with pytest.raises(SystemExit):
694
- integration.run(dry_run=False)
695
- _post, _patch = ocm_mock
696
- assert _post.call_count == 0
697
- assert _patch.call_count == 1
698
- assert cluster_updates_mr_mock.call_count == 0
699
-
700
-
701
- def test_ocm_osd_update_cluster_with_machine_pools_change(
702
- integration: occ.OcmClusters,
703
- get_json_mock,
704
- queries_mock,
705
- ocm_mock,
706
- cluster_updates_mr_mock,
707
- ocm_osd_cluster_raw_spec,
708
- ocm_osd_cluster_ai_spec,
709
- ):
710
- new_spec = ocm_osd_cluster_ai_spec | {
711
- "machinePools": [
712
- {
713
- "id": "new",
714
- "instance_type": "m5.xlarge",
715
- "replicas": 1,
716
- }
717
- ]
718
- }
719
- get_json_mock.return_value = {"items": [ocm_osd_cluster_raw_spec]}
720
- queries_mock[1].return_value = [new_spec]
721
-
722
- with pytest.raises(SystemExit):
723
- integration.run(dry_run=False)
724
-
725
- _post, _patch = ocm_mock
726
- _post.assert_not_called()
727
- _patch.assert_not_called()
728
- cluster_updates_mr_mock.assert_not_called()
729
-
730
-
731
- def test_ocm_returns_a_rosa_cluster(
732
- integration: occ.OcmClusters,
733
- get_json_mock,
734
- queries_mock,
735
- ocm_mock,
736
- cluster_updates_mr_mock,
737
- ocm_osd_cluster_raw_spec,
738
- ocm_rosa_cluster_raw_spec,
739
- ocm_osd_cluster_ai_spec,
740
- ):
741
- get_json_mock.return_value = {
742
- "items": [ocm_osd_cluster_raw_spec, ocm_rosa_cluster_raw_spec]
743
- }
744
- queries_mock[1].return_value = [ocm_osd_cluster_ai_spec]
745
- with pytest.raises(SystemExit):
746
- integration.run(dry_run=False)
747
- _post, _patch = ocm_mock
748
- assert _post.call_count == 0
749
- assert _patch.call_count == 0
750
- assert cluster_updates_mr_mock.call_count == 0
751
-
752
-
753
- def test_changed_ocm_spec_disable_uwm(
754
- integration: occ.OcmClusters,
755
- get_json_mock,
756
- queries_mock,
757
- ocm_mock,
758
- ocm_osd_cluster_raw_spec,
759
- ocm_osd_cluster_ai_spec,
760
- cluster_updates_mr_mock,
761
- ):
762
- ocm_osd_cluster_ai_spec["spec"][
763
- "disable_user_workload_monitoring"
764
- ] = not ocm_osd_cluster_ai_spec["spec"]["disable_user_workload_monitoring"]
765
-
766
- get_json_mock.return_value = {"items": [ocm_osd_cluster_raw_spec]}
767
- queries_mock[1].return_value = [ocm_osd_cluster_ai_spec]
768
-
769
- with pytest.raises(SystemExit):
770
- integration.run(dry_run=False)
771
-
772
- _post, _patch = ocm_mock
773
- assert _patch.call_count == 1
774
- assert _post.call_count == 0
775
- assert cluster_updates_mr_mock.call_count == 0
776
-
777
-
778
- def test_console_url_changes_ai(
779
- integration: occ.OcmClusters,
780
- get_json_mock,
781
- queries_mock,
782
- ocm_mock,
783
- ocm_osd_cluster_raw_spec,
784
- ocm_osd_cluster_ai_spec,
785
- cluster_updates_mr_mock,
786
- ):
787
- ocm_osd_cluster_ai_spec["consoleUrl"] = "old-console-url"
788
-
789
- get_json_mock.return_value = {"items": [ocm_osd_cluster_raw_spec]}
790
- queries_mock[1].return_value = [ocm_osd_cluster_ai_spec]
791
-
792
- with pytest.raises(SystemExit):
793
- integration.run(dry_run=False)
794
-
795
- _post, _patch = ocm_mock
796
- assert _patch.call_count == 0
797
- assert _post.call_count == 0
798
- assert cluster_updates_mr_mock.call_count == 1