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.
- qontract_reconcile-0.10.2.dev1.dist-info/METADATA +500 -0
- {qontract_reconcile-0.10.1rc1202.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/RECORD +12 -130
- {qontract_reconcile-0.10.1rc1202.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/WHEEL +1 -2
- {qontract_reconcile-0.10.1rc1202.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/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.1rc1202.dist-info/METADATA +0 -64
- qontract_reconcile-0.10.1rc1202.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,1295 +0,0 @@
|
|
1
|
-
from collections.abc import (
|
2
|
-
Callable,
|
3
|
-
Iterable,
|
4
|
-
Mapping,
|
5
|
-
)
|
6
|
-
from unittest.mock import create_autospec
|
7
|
-
|
8
|
-
import pytest
|
9
|
-
from pytest_mock import MockerFixture
|
10
|
-
|
11
|
-
import reconcile.terraform_tgw_attachments as integ
|
12
|
-
from reconcile.gql_definitions.common.app_interface_vault_settings import (
|
13
|
-
AppInterfaceSettingsV1,
|
14
|
-
)
|
15
|
-
from reconcile.gql_definitions.common.clusters_with_peering import (
|
16
|
-
ClusterPeeringConnectionAccountTGWV1,
|
17
|
-
ClusterPeeringConnectionAccountTGWV1_AWSAccountV1,
|
18
|
-
ClusterPeeringConnectionAccountV1,
|
19
|
-
ClusterPeeringConnectionAccountVPCMeshV1,
|
20
|
-
ClusterPeeringConnectionClusterRequesterV1,
|
21
|
-
ClusterPeeringConnectionV1,
|
22
|
-
ClusterPeeringV1,
|
23
|
-
ClusterV1,
|
24
|
-
)
|
25
|
-
from reconcile.gql_definitions.terraform_tgw_attachments.aws_accounts import (
|
26
|
-
AWSAccountV1,
|
27
|
-
)
|
28
|
-
from reconcile.terraform_tgw_attachments import Accepter, DesiredStateItem, Requester
|
29
|
-
from reconcile.utils.gql import GqlApi
|
30
|
-
from reconcile.utils.runtime.integration import ShardedRunProposal
|
31
|
-
from reconcile.utils.secret_reader import SecretReaderBase
|
32
|
-
|
33
|
-
QONTRACT_INTEGRATION = "terraform_tgw_attachments"
|
34
|
-
|
35
|
-
|
36
|
-
@pytest.fixture
|
37
|
-
def account_builder(
|
38
|
-
gql_class_factory: Callable[..., AWSAccountV1],
|
39
|
-
) -> Callable[..., AWSAccountV1]:
|
40
|
-
def builder(
|
41
|
-
name: str,
|
42
|
-
uid: str,
|
43
|
-
terraform_username: str,
|
44
|
-
) -> AWSAccountV1:
|
45
|
-
return gql_class_factory(
|
46
|
-
AWSAccountV1,
|
47
|
-
{
|
48
|
-
"name": name,
|
49
|
-
"uid": uid,
|
50
|
-
"terraformUsername": terraform_username,
|
51
|
-
"accountOwners": [],
|
52
|
-
"automationToken": {},
|
53
|
-
"premiumSupport": False,
|
54
|
-
},
|
55
|
-
)
|
56
|
-
|
57
|
-
return builder
|
58
|
-
|
59
|
-
|
60
|
-
@pytest.fixture
|
61
|
-
def connection_account_builder(
|
62
|
-
gql_class_factory: Callable[..., ClusterPeeringConnectionAccountTGWV1_AWSAccountV1],
|
63
|
-
) -> Callable[..., ClusterPeeringConnectionAccountTGWV1_AWSAccountV1]:
|
64
|
-
def builder(
|
65
|
-
name: str,
|
66
|
-
uid: str,
|
67
|
-
terraform_username: str,
|
68
|
-
) -> ClusterPeeringConnectionAccountTGWV1_AWSAccountV1:
|
69
|
-
return gql_class_factory(
|
70
|
-
ClusterPeeringConnectionAccountTGWV1_AWSAccountV1,
|
71
|
-
{
|
72
|
-
"name": name,
|
73
|
-
"uid": uid,
|
74
|
-
"terraformUsername": terraform_username,
|
75
|
-
"automationToken": {},
|
76
|
-
},
|
77
|
-
)
|
78
|
-
|
79
|
-
return builder
|
80
|
-
|
81
|
-
|
82
|
-
@pytest.fixture
|
83
|
-
def tgw_account(account_builder: Callable[..., AWSAccountV1]) -> AWSAccountV1:
|
84
|
-
return account_builder(
|
85
|
-
name="tgw_account",
|
86
|
-
uid="tgw-account-uid",
|
87
|
-
terraform_username="tgw-account-terraform-username",
|
88
|
-
)
|
89
|
-
|
90
|
-
|
91
|
-
@pytest.fixture
|
92
|
-
def tgw_connection_account(
|
93
|
-
connection_account_builder: Callable[
|
94
|
-
..., ClusterPeeringConnectionAccountTGWV1_AWSAccountV1
|
95
|
-
],
|
96
|
-
tgw_account: AWSAccountV1,
|
97
|
-
) -> ClusterPeeringConnectionAccountTGWV1_AWSAccountV1:
|
98
|
-
return connection_account_builder(
|
99
|
-
name=tgw_account.name,
|
100
|
-
uid=tgw_account.uid,
|
101
|
-
terraform_username=tgw_account.terraform_username,
|
102
|
-
)
|
103
|
-
|
104
|
-
|
105
|
-
@pytest.fixture
|
106
|
-
def vpc_account(account_builder: Callable[..., AWSAccountV1]) -> AWSAccountV1:
|
107
|
-
return account_builder(
|
108
|
-
name="vpc_account",
|
109
|
-
uid="vpc-account-uid",
|
110
|
-
terraform_username="vpc-account-terraform-username",
|
111
|
-
)
|
112
|
-
|
113
|
-
|
114
|
-
@pytest.fixture
|
115
|
-
def vpc_connection_account(
|
116
|
-
connection_account_builder: Callable[
|
117
|
-
..., ClusterPeeringConnectionAccountTGWV1_AWSAccountV1
|
118
|
-
],
|
119
|
-
vpc_account: AWSAccountV1,
|
120
|
-
) -> ClusterPeeringConnectionAccountTGWV1_AWSAccountV1:
|
121
|
-
return connection_account_builder(
|
122
|
-
name=vpc_account.name,
|
123
|
-
uid=vpc_account.uid,
|
124
|
-
terraform_username=vpc_account.terraform_username,
|
125
|
-
)
|
126
|
-
|
127
|
-
|
128
|
-
@pytest.fixture
|
129
|
-
def additional_tgw_account(
|
130
|
-
account_builder: Callable[..., AWSAccountV1],
|
131
|
-
) -> AWSAccountV1:
|
132
|
-
return account_builder(
|
133
|
-
name="additional_tgw_account",
|
134
|
-
uid="additional_tgw-account-uid",
|
135
|
-
terraform_username="additional_tgw-account-terraform-username",
|
136
|
-
)
|
137
|
-
|
138
|
-
|
139
|
-
@pytest.fixture
|
140
|
-
def additional_tgw_connection_account(
|
141
|
-
connection_account_builder: Callable[
|
142
|
-
..., ClusterPeeringConnectionAccountTGWV1_AWSAccountV1
|
143
|
-
],
|
144
|
-
additional_tgw_account: AWSAccountV1,
|
145
|
-
) -> ClusterPeeringConnectionAccountTGWV1_AWSAccountV1:
|
146
|
-
return connection_account_builder(
|
147
|
-
name=additional_tgw_account.name,
|
148
|
-
uid=additional_tgw_account.uid,
|
149
|
-
terraform_username=additional_tgw_account.terraform_username,
|
150
|
-
)
|
151
|
-
|
152
|
-
|
153
|
-
@pytest.fixture
|
154
|
-
def peering_connection_builder(
|
155
|
-
gql_class_factory: Callable[..., ClusterPeeringConnectionAccountTGWV1],
|
156
|
-
) -> Callable[..., ClusterPeeringConnectionAccountTGWV1]:
|
157
|
-
def builder(
|
158
|
-
name: str,
|
159
|
-
provider: str,
|
160
|
-
manage_routes: bool = False,
|
161
|
-
account: ClusterPeeringConnectionAccountTGWV1_AWSAccountV1 | None = None,
|
162
|
-
assume_role: str | None = None,
|
163
|
-
cidr_block: str | None = None,
|
164
|
-
cidr_blocks: list[str] | None = None,
|
165
|
-
delete: bool | None = None,
|
166
|
-
) -> ClusterPeeringConnectionAccountTGWV1:
|
167
|
-
return gql_class_factory(
|
168
|
-
ClusterPeeringConnectionAccountTGWV1,
|
169
|
-
{
|
170
|
-
"name": name,
|
171
|
-
"provider": provider,
|
172
|
-
"manageRoutes": manage_routes,
|
173
|
-
"account": account.dict(by_alias=True) if account is not None else None,
|
174
|
-
"assumeRole": assume_role,
|
175
|
-
"cidrBlock": cidr_block,
|
176
|
-
"cidrBlocks": cidr_blocks,
|
177
|
-
"delete": delete,
|
178
|
-
},
|
179
|
-
)
|
180
|
-
|
181
|
-
return builder
|
182
|
-
|
183
|
-
|
184
|
-
@pytest.fixture
|
185
|
-
def account_tgw_connection(
|
186
|
-
peering_connection_builder: Callable[..., ClusterPeeringConnectionAccountTGWV1],
|
187
|
-
tgw_connection_account: ClusterPeeringConnectionAccountTGWV1_AWSAccountV1,
|
188
|
-
) -> ClusterPeeringConnectionAccountTGWV1:
|
189
|
-
return peering_connection_builder(
|
190
|
-
name="account_tgw_connection",
|
191
|
-
provider="account-tgw",
|
192
|
-
manage_routes=True,
|
193
|
-
account=tgw_connection_account,
|
194
|
-
assume_role=None,
|
195
|
-
cidr_block="172.16.0.0/16",
|
196
|
-
cidr_blocks=["10.240.0.0/12"],
|
197
|
-
delete=False,
|
198
|
-
)
|
199
|
-
|
200
|
-
|
201
|
-
@pytest.fixture
|
202
|
-
def additional_account_tgw_connection(
|
203
|
-
peering_connection_builder: Callable[..., ClusterPeeringConnectionAccountTGWV1],
|
204
|
-
additional_tgw_connection_account: ClusterPeeringConnectionAccountTGWV1_AWSAccountV1,
|
205
|
-
) -> ClusterPeeringConnectionAccountTGWV1:
|
206
|
-
return peering_connection_builder(
|
207
|
-
name="additional_account_tgw_connection",
|
208
|
-
provider="account-tgw",
|
209
|
-
manage_routes=True,
|
210
|
-
account=additional_tgw_connection_account,
|
211
|
-
assume_role=None,
|
212
|
-
cidr_block="172.16.0.0/16",
|
213
|
-
delete=False,
|
214
|
-
)
|
215
|
-
|
216
|
-
|
217
|
-
@pytest.fixture
|
218
|
-
def account_vpc_connection(
|
219
|
-
peering_connection_builder: Callable[..., ClusterPeeringConnectionAccountTGWV1],
|
220
|
-
vpc_connection_account: ClusterPeeringConnectionAccountTGWV1_AWSAccountV1,
|
221
|
-
) -> ClusterPeeringConnectionAccountTGWV1:
|
222
|
-
return peering_connection_builder(
|
223
|
-
name="account_vpc_connection",
|
224
|
-
provider="account-vpc",
|
225
|
-
account=vpc_connection_account,
|
226
|
-
)
|
227
|
-
|
228
|
-
|
229
|
-
@pytest.fixture
|
230
|
-
def cluster_builder(
|
231
|
-
gql_class_factory: Callable[..., ClusterV1],
|
232
|
-
) -> Callable[..., ClusterV1]:
|
233
|
-
def builder(
|
234
|
-
name: str,
|
235
|
-
ocm: dict,
|
236
|
-
region: str,
|
237
|
-
vpc_cidr: str,
|
238
|
-
peering: ClusterPeeringV1,
|
239
|
-
) -> ClusterV1:
|
240
|
-
return gql_class_factory(
|
241
|
-
ClusterV1,
|
242
|
-
{
|
243
|
-
"name": name,
|
244
|
-
"ocm": ocm,
|
245
|
-
"spec": {
|
246
|
-
"region": region,
|
247
|
-
},
|
248
|
-
"network": {"vpc": vpc_cidr},
|
249
|
-
"peering": peering,
|
250
|
-
},
|
251
|
-
)
|
252
|
-
|
253
|
-
return builder
|
254
|
-
|
255
|
-
|
256
|
-
@pytest.fixture
|
257
|
-
def peering_builder(
|
258
|
-
gql_class_factory: Callable[..., ClusterPeeringV1],
|
259
|
-
) -> Callable[..., ClusterPeeringV1]:
|
260
|
-
def builder(
|
261
|
-
connections: list[
|
262
|
-
ClusterPeeringConnectionAccountTGWV1
|
263
|
-
| ClusterPeeringConnectionAccountV1
|
264
|
-
| ClusterPeeringConnectionAccountVPCMeshV1
|
265
|
-
| ClusterPeeringConnectionClusterRequesterV1
|
266
|
-
| ClusterPeeringConnectionV1
|
267
|
-
],
|
268
|
-
) -> ClusterPeeringV1:
|
269
|
-
return gql_class_factory(
|
270
|
-
ClusterPeeringV1,
|
271
|
-
{
|
272
|
-
"connections": connections,
|
273
|
-
},
|
274
|
-
)
|
275
|
-
|
276
|
-
return builder
|
277
|
-
|
278
|
-
|
279
|
-
@pytest.fixture
|
280
|
-
def cluster_with_tgw_connection(
|
281
|
-
cluster_builder: Callable[..., ClusterV1],
|
282
|
-
peering_builder: Callable[..., ClusterPeeringV1],
|
283
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
284
|
-
) -> ClusterV1:
|
285
|
-
return cluster_builder(
|
286
|
-
name="cluster_with_tgw_connection",
|
287
|
-
ocm={
|
288
|
-
"name": "cluster_with_tgw_connection-ocm",
|
289
|
-
"environment": {"accessTokenClientSecret": {}},
|
290
|
-
},
|
291
|
-
region="us-east-1",
|
292
|
-
vpc_cidr="10.0.0.0/16",
|
293
|
-
peering=peering_builder([
|
294
|
-
account_tgw_connection,
|
295
|
-
]),
|
296
|
-
)
|
297
|
-
|
298
|
-
|
299
|
-
@pytest.fixture
|
300
|
-
def cluster_with_2_tgw_connections(
|
301
|
-
cluster_builder: Callable[..., ClusterV1],
|
302
|
-
peering_builder: Callable[..., ClusterPeeringV1],
|
303
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
304
|
-
additional_account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
305
|
-
) -> ClusterV1:
|
306
|
-
return cluster_builder(
|
307
|
-
name="cluster_with_2_tgw_connections",
|
308
|
-
ocm={
|
309
|
-
"name": "cluster_with_2_tgw_connections-ocm",
|
310
|
-
"environment": {"accessTokenClientSecret": {}},
|
311
|
-
},
|
312
|
-
region="us-east-1",
|
313
|
-
vpc_cidr="10.0.0.0/16",
|
314
|
-
peering=peering_builder([
|
315
|
-
account_tgw_connection,
|
316
|
-
additional_account_tgw_connection,
|
317
|
-
]),
|
318
|
-
)
|
319
|
-
|
320
|
-
|
321
|
-
@pytest.fixture
|
322
|
-
def additional_cluster_with_tgw_connection(
|
323
|
-
cluster_builder: Callable[..., ClusterV1],
|
324
|
-
peering_builder: Callable[..., ClusterPeeringV1],
|
325
|
-
additional_account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
326
|
-
) -> ClusterV1:
|
327
|
-
return cluster_builder(
|
328
|
-
name="additional_cluster_with_tgw_connection",
|
329
|
-
ocm={
|
330
|
-
"name": "additional_cluster_with_tgw_connection-ocm",
|
331
|
-
"environment": {"accessTokenClientSecret": {}},
|
332
|
-
},
|
333
|
-
region="us-east-1",
|
334
|
-
vpc_cidr="10.0.0.0/16",
|
335
|
-
peering=peering_builder([
|
336
|
-
additional_account_tgw_connection,
|
337
|
-
]),
|
338
|
-
)
|
339
|
-
|
340
|
-
|
341
|
-
@pytest.fixture
|
342
|
-
def cluster_with_duplicate_tgw_connections(
|
343
|
-
cluster_builder: Callable[..., ClusterV1],
|
344
|
-
peering_builder: Callable[..., ClusterPeeringV1],
|
345
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
346
|
-
) -> ClusterV1:
|
347
|
-
return cluster_builder(
|
348
|
-
name="cluster_with_duplicate_tgw_connections",
|
349
|
-
ocm={
|
350
|
-
"name": "cluster_with_duplicate_tgw_connections-ocm",
|
351
|
-
"environment": {"accessTokenClientSecret": {}},
|
352
|
-
},
|
353
|
-
region="us-east-1",
|
354
|
-
vpc_cidr="10.0.0.0/16",
|
355
|
-
peering=peering_builder([
|
356
|
-
account_tgw_connection,
|
357
|
-
account_tgw_connection,
|
358
|
-
]),
|
359
|
-
)
|
360
|
-
|
361
|
-
|
362
|
-
@pytest.fixture
|
363
|
-
def cluster_with_vpc_connection(
|
364
|
-
cluster_builder: Callable[..., ClusterV1],
|
365
|
-
peering_builder: Callable[..., ClusterPeeringV1],
|
366
|
-
account_vpc_connection: ClusterPeeringConnectionAccountTGWV1,
|
367
|
-
) -> ClusterV1:
|
368
|
-
return cluster_builder(
|
369
|
-
name="cluster_with_vpc_connection",
|
370
|
-
ocm={
|
371
|
-
"name": "cluster_with_vpc_connection-ocm",
|
372
|
-
"environment": {"accessTokenClientSecret": {}},
|
373
|
-
},
|
374
|
-
region="us-east-1",
|
375
|
-
vpc_cidr="10.0.0.1/16",
|
376
|
-
peering=peering_builder([
|
377
|
-
account_vpc_connection,
|
378
|
-
]),
|
379
|
-
)
|
380
|
-
|
381
|
-
|
382
|
-
@pytest.fixture
|
383
|
-
def cluster_with_mixed_connections(
|
384
|
-
cluster_builder: Callable[..., ClusterV1],
|
385
|
-
peering_builder: Callable[..., ClusterPeeringV1],
|
386
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
387
|
-
account_vpc_connection: ClusterPeeringConnectionAccountTGWV1,
|
388
|
-
) -> ClusterV1:
|
389
|
-
return cluster_builder(
|
390
|
-
name="cluster_with_mixed_connections",
|
391
|
-
ocm={
|
392
|
-
"name": "cluster_with_mixed_connections-ocm",
|
393
|
-
"environment": {"accessTokenClientSecret": {}},
|
394
|
-
},
|
395
|
-
region="us-east-1",
|
396
|
-
vpc_cidr="10.0.0.2/16",
|
397
|
-
peering=peering_builder([
|
398
|
-
account_tgw_connection,
|
399
|
-
account_vpc_connection,
|
400
|
-
]),
|
401
|
-
)
|
402
|
-
|
403
|
-
|
404
|
-
@pytest.fixture
|
405
|
-
def tgw() -> dict:
|
406
|
-
return {
|
407
|
-
"tgw_id": "tgw-1",
|
408
|
-
"tgw_arn": "tgw-arn-1",
|
409
|
-
"region": "us-west-1",
|
410
|
-
"routes": [],
|
411
|
-
"rules": [],
|
412
|
-
"hostedzones": None,
|
413
|
-
}
|
414
|
-
|
415
|
-
|
416
|
-
@pytest.fixture
|
417
|
-
def vpc_details() -> dict:
|
418
|
-
return {
|
419
|
-
"vpc_id": "vpc-id-1",
|
420
|
-
"route_table_ids": ["rtb-1"],
|
421
|
-
"subnets_id_az": [{"az": "us-east-1a", "id": "subnet-1"}],
|
422
|
-
}
|
423
|
-
|
424
|
-
|
425
|
-
@pytest.fixture
|
426
|
-
def assume_role() -> str:
|
427
|
-
return "some-role"
|
428
|
-
|
429
|
-
|
430
|
-
@pytest.fixture
|
431
|
-
def app_interface_vault_settings(
|
432
|
-
gql_class_factory: Callable[..., AppInterfaceSettingsV1],
|
433
|
-
) -> AppInterfaceSettingsV1:
|
434
|
-
return gql_class_factory(
|
435
|
-
AppInterfaceSettingsV1,
|
436
|
-
{"vault": True},
|
437
|
-
)
|
438
|
-
|
439
|
-
|
440
|
-
def build_expected_tgw_account(
|
441
|
-
connection: ClusterPeeringConnectionAccountTGWV1,
|
442
|
-
tgw: Mapping,
|
443
|
-
) -> dict:
|
444
|
-
return {
|
445
|
-
"name": connection.account.name,
|
446
|
-
"uid": connection.account.uid,
|
447
|
-
"assume_role": None,
|
448
|
-
"assume_region": tgw["region"],
|
449
|
-
"assume_cidr": connection.cidr_block,
|
450
|
-
}
|
451
|
-
|
452
|
-
|
453
|
-
def build_expected_cluster_account(
|
454
|
-
cluster: ClusterV1,
|
455
|
-
connection: ClusterPeeringConnectionAccountTGWV1,
|
456
|
-
assume_role: str,
|
457
|
-
) -> dict:
|
458
|
-
return {
|
459
|
-
"name": connection.account.name,
|
460
|
-
"uid": connection.account.uid,
|
461
|
-
"assume_role": assume_role,
|
462
|
-
"assume_region": cluster.spec.region if cluster.spec is not None else "",
|
463
|
-
"assume_cidr": cluster.network.vpc if cluster.network is not None else "",
|
464
|
-
}
|
465
|
-
|
466
|
-
|
467
|
-
def build_expected_desired_state_item(
|
468
|
-
cluster: ClusterV1,
|
469
|
-
connection: ClusterPeeringConnectionAccountTGWV1,
|
470
|
-
tgw: Mapping,
|
471
|
-
vpc_details: Mapping,
|
472
|
-
expected_tgw_account: Mapping,
|
473
|
-
expected_cluster_account: Mapping,
|
474
|
-
) -> DesiredStateItem:
|
475
|
-
return DesiredStateItem(
|
476
|
-
connection_provider="account-tgw",
|
477
|
-
connection_name=f"{connection.name}_{expected_tgw_account['name']}-{tgw['tgw_id']}",
|
478
|
-
infra_acount_name=expected_tgw_account["name"],
|
479
|
-
requester=Requester(
|
480
|
-
tgw_id=tgw["tgw_id"],
|
481
|
-
tgw_arn=tgw["tgw_arn"],
|
482
|
-
region=tgw["region"],
|
483
|
-
routes=tgw["routes"],
|
484
|
-
rules=tgw["rules"],
|
485
|
-
hostedzones=tgw["hostedzones"],
|
486
|
-
cidr_block=connection.cidr_block,
|
487
|
-
cidr_blocks=connection.cidr_blocks or [],
|
488
|
-
account=expected_tgw_account,
|
489
|
-
),
|
490
|
-
accepter=Accepter(
|
491
|
-
vpc_id=vpc_details["vpc_id"],
|
492
|
-
region=cluster.spec.region if cluster.spec is not None else "",
|
493
|
-
cidr_block=cluster.network.vpc if cluster.network is not None else "",
|
494
|
-
route_table_ids=vpc_details["route_table_ids"],
|
495
|
-
subnets_id_az=vpc_details["subnets_id_az"],
|
496
|
-
account=expected_cluster_account,
|
497
|
-
),
|
498
|
-
deleted=connection.delete,
|
499
|
-
)
|
500
|
-
|
501
|
-
|
502
|
-
def _setup_mocks(
|
503
|
-
mocker: MockerFixture,
|
504
|
-
vault_settings: AppInterfaceSettingsV1,
|
505
|
-
clusters: Iterable[ClusterV1] | None = None,
|
506
|
-
accounts: Iterable[AWSAccountV1] | None = None,
|
507
|
-
vpc_details: Mapping | None = None,
|
508
|
-
tgws: Iterable | None = None,
|
509
|
-
assume_role: str | None = None,
|
510
|
-
feature_toggle_state: bool = True,
|
511
|
-
) -> dict:
|
512
|
-
mocked_gql_api = create_autospec(GqlApi)
|
513
|
-
mocker.patch(
|
514
|
-
"reconcile.terraform_tgw_attachments.gql"
|
515
|
-
).get_api.return_value = mocked_gql_api
|
516
|
-
mocked_get_clusters_with_peering = mocker.patch(
|
517
|
-
"reconcile.terraform_tgw_attachments.get_clusters_with_peering"
|
518
|
-
)
|
519
|
-
mocked_get_clusters_with_peering.return_value = clusters or []
|
520
|
-
|
521
|
-
mocked_get_app_interface_vault_settings = mocker.patch(
|
522
|
-
"reconcile.terraform_tgw_attachments.get_app_interface_vault_settings"
|
523
|
-
)
|
524
|
-
mocked_get_app_interface_vault_settings.return_value = vault_settings
|
525
|
-
|
526
|
-
mocked_get_aws_accounts = mocker.patch(
|
527
|
-
"reconcile.terraform_tgw_attachments.get_aws_accounts"
|
528
|
-
)
|
529
|
-
mocked_get_aws_accounts.return_value = accounts or []
|
530
|
-
|
531
|
-
mocked_secret_reader = create_autospec(SecretReaderBase)
|
532
|
-
mocker.patch(
|
533
|
-
"reconcile.terraform_tgw_attachments.create_secret_reader"
|
534
|
-
).return_value = mocked_secret_reader
|
535
|
-
|
536
|
-
mocked_aws_api = mocker.patch(
|
537
|
-
"reconcile.terraform_tgw_attachments.AWSApi", autospec=True
|
538
|
-
)
|
539
|
-
aws_api = mocked_aws_api.return_value
|
540
|
-
vpc = (
|
541
|
-
(
|
542
|
-
vpc_details["vpc_id"],
|
543
|
-
vpc_details["route_table_ids"],
|
544
|
-
vpc_details["subnets_id_az"],
|
545
|
-
None,
|
546
|
-
)
|
547
|
-
if vpc_details is not None
|
548
|
-
else (None, None, None, None)
|
549
|
-
)
|
550
|
-
aws_api.get_cluster_vpc_details.return_value = vpc
|
551
|
-
aws_api.get_tgws_details.return_value = tgws or []
|
552
|
-
mocked_ocm = mocker.patch(
|
553
|
-
"reconcile.terraform_tgw_attachments.OCMMap", autospec=True
|
554
|
-
)
|
555
|
-
mocked_ocm.return_value.get.return_value.get_aws_infrastructure_access_terraform_assume_role.return_value = assume_role
|
556
|
-
mocked_ts = mocker.patch(
|
557
|
-
"reconcile.terraform_tgw_attachments.Terrascript", autospec=True
|
558
|
-
).return_value
|
559
|
-
mocked_ts.dump.return_value = []
|
560
|
-
|
561
|
-
mocked_tf = mocker.patch(
|
562
|
-
"reconcile.terraform_tgw_attachments.Terraform", autospec=True
|
563
|
-
).return_value
|
564
|
-
mocked_tf.plan.return_value = (False, False)
|
565
|
-
mocked_tf.apply.return_value = False
|
566
|
-
mocked_tf.apply_count = 0
|
567
|
-
get_feature_toggle_state = mocker.patch(
|
568
|
-
"reconcile.terraform_tgw_attachments.get_feature_toggle_state",
|
569
|
-
return_value=feature_toggle_state,
|
570
|
-
)
|
571
|
-
mock_extended_early_exit_run = mocker.patch(
|
572
|
-
"reconcile.terraform_tgw_attachments.extended_early_exit_run"
|
573
|
-
)
|
574
|
-
mocked_logging = mocker.patch("reconcile.terraform_tgw_attachments.logging")
|
575
|
-
|
576
|
-
return {
|
577
|
-
"tf": mocked_tf,
|
578
|
-
"ts": mocked_ts,
|
579
|
-
"get_app_interface_vault_settings": mocked_get_app_interface_vault_settings,
|
580
|
-
"get_aws_accounts": mocked_get_aws_accounts,
|
581
|
-
"get_clusters_with_peering": mocked_get_clusters_with_peering,
|
582
|
-
"secret_reader": mocked_secret_reader,
|
583
|
-
"ocm": mocked_ocm,
|
584
|
-
"aws_api": mocked_aws_api,
|
585
|
-
"gql_api": mocked_gql_api,
|
586
|
-
"logging": mocked_logging,
|
587
|
-
"extended_early_exit_run": mock_extended_early_exit_run,
|
588
|
-
"get_feature_toggle_state": get_feature_toggle_state,
|
589
|
-
}
|
590
|
-
|
591
|
-
|
592
|
-
def test_with_extended_early_exit_enabled(
|
593
|
-
mocker: MockerFixture,
|
594
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
595
|
-
cluster_with_tgw_connection: ClusterV1,
|
596
|
-
tgw_account: AWSAccountV1,
|
597
|
-
tgw: Mapping,
|
598
|
-
vpc_details: Mapping,
|
599
|
-
assume_role: str,
|
600
|
-
) -> None:
|
601
|
-
mocks = _setup_mocks(
|
602
|
-
mocker,
|
603
|
-
vault_settings=app_interface_vault_settings,
|
604
|
-
clusters=[cluster_with_tgw_connection],
|
605
|
-
accounts=[tgw_account],
|
606
|
-
vpc_details=vpc_details,
|
607
|
-
tgws=[tgw],
|
608
|
-
assume_role=assume_role,
|
609
|
-
)
|
610
|
-
expected_params = integ.RunnerParams(
|
611
|
-
terraform_client=mocks["tf"],
|
612
|
-
terrascript_client=mocks["ts"],
|
613
|
-
dry_run=False,
|
614
|
-
enable_deletion=False,
|
615
|
-
)
|
616
|
-
|
617
|
-
integ.run(
|
618
|
-
False,
|
619
|
-
enable_deletion=False,
|
620
|
-
enable_extended_early_exit=True,
|
621
|
-
extended_early_exit_cache_ttl_seconds=40,
|
622
|
-
log_cached_log_output=True,
|
623
|
-
)
|
624
|
-
|
625
|
-
mocks["extended_early_exit_run"].assert_called_once_with(
|
626
|
-
integration=integ.QONTRACT_INTEGRATION,
|
627
|
-
integration_version=integ.QONTRACT_INTEGRATION_VERSION,
|
628
|
-
dry_run=False,
|
629
|
-
shard="",
|
630
|
-
cache_source=integ.CacheSource(
|
631
|
-
terraform_configurations=mocks["ts"].terraform_configurations.return_value
|
632
|
-
),
|
633
|
-
ttl_seconds=40,
|
634
|
-
logger=mocks["logging"].getLogger.return_value,
|
635
|
-
runner=integ.runner,
|
636
|
-
runner_params=expected_params,
|
637
|
-
secret_reader=mocks["secret_reader"],
|
638
|
-
log_cached_log_output=True,
|
639
|
-
)
|
640
|
-
|
641
|
-
|
642
|
-
def test_with_extended_early_exit_disabled(
|
643
|
-
mocker: MockerFixture,
|
644
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
645
|
-
cluster_with_tgw_connection: ClusterV1,
|
646
|
-
tgw_account: AWSAccountV1,
|
647
|
-
tgw: Mapping,
|
648
|
-
vpc_details: Mapping,
|
649
|
-
assume_role: str,
|
650
|
-
) -> None:
|
651
|
-
mocks = _setup_mocks(
|
652
|
-
mocker,
|
653
|
-
vault_settings=app_interface_vault_settings,
|
654
|
-
clusters=[cluster_with_tgw_connection],
|
655
|
-
accounts=[tgw_account],
|
656
|
-
vpc_details=vpc_details,
|
657
|
-
tgws=[tgw],
|
658
|
-
assume_role=assume_role,
|
659
|
-
)
|
660
|
-
integ.run(
|
661
|
-
False,
|
662
|
-
enable_deletion=False,
|
663
|
-
enable_extended_early_exit=False,
|
664
|
-
)
|
665
|
-
mocks["extended_early_exit_run"].assert_not_called()
|
666
|
-
mocks["get_app_interface_vault_settings"].assert_called_once_with()
|
667
|
-
mocks["get_clusters_with_peering"].assert_called_once_with(mocks["gql_api"])
|
668
|
-
mocks["get_aws_accounts"].assert_called_once_with(mocks["gql_api"])
|
669
|
-
mocks["tf"].plan.assert_called_once_with(False)
|
670
|
-
mocks["tf"].apply.assert_called_once()
|
671
|
-
|
672
|
-
|
673
|
-
def test_with_feature_flag_disabled(
|
674
|
-
mocker: MockerFixture,
|
675
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
676
|
-
cluster_with_tgw_connection: ClusterV1,
|
677
|
-
tgw_account: AWSAccountV1,
|
678
|
-
tgw: Mapping,
|
679
|
-
vpc_details: Mapping,
|
680
|
-
assume_role: str,
|
681
|
-
) -> None:
|
682
|
-
mocks = _setup_mocks(
|
683
|
-
mocker,
|
684
|
-
vault_settings=app_interface_vault_settings,
|
685
|
-
clusters=[cluster_with_tgw_connection],
|
686
|
-
accounts=[tgw_account],
|
687
|
-
vpc_details=vpc_details,
|
688
|
-
tgws=[tgw],
|
689
|
-
assume_role=assume_role,
|
690
|
-
feature_toggle_state=False,
|
691
|
-
)
|
692
|
-
integ.run(
|
693
|
-
False,
|
694
|
-
enable_deletion=False,
|
695
|
-
enable_extended_early_exit=True,
|
696
|
-
extended_early_exit_cache_ttl_seconds=40,
|
697
|
-
log_cached_log_output=True,
|
698
|
-
)
|
699
|
-
mocks["extended_early_exit_run"].assert_not_called()
|
700
|
-
mocks["get_app_interface_vault_settings"].assert_called_once_with()
|
701
|
-
mocks["get_clusters_with_peering"].assert_called_once_with(mocks["gql_api"])
|
702
|
-
mocks["get_aws_accounts"].assert_called_once_with(mocks["gql_api"])
|
703
|
-
mocks["tf"].plan.assert_called_once_with(False)
|
704
|
-
mocks["tf"].apply.assert_called_once()
|
705
|
-
|
706
|
-
|
707
|
-
def test_empty_run(
|
708
|
-
mocker: MockerFixture,
|
709
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
710
|
-
) -> None:
|
711
|
-
mocks = _setup_mocks(
|
712
|
-
mocker,
|
713
|
-
vault_settings=app_interface_vault_settings,
|
714
|
-
)
|
715
|
-
|
716
|
-
integ.run(False, enable_deletion=False)
|
717
|
-
|
718
|
-
mocks["logging"].warning.assert_called_once_with(
|
719
|
-
"No participating AWS accounts found, consider disabling this integration, account name: None"
|
720
|
-
)
|
721
|
-
mocks["get_clusters_with_peering"].assert_called_once_with(mocks["gql_api"])
|
722
|
-
mocks["get_aws_accounts"].assert_called_once_with(mocks["gql_api"])
|
723
|
-
mocks["get_app_interface_vault_settings"].assert_not_called()
|
724
|
-
mocks["tf"].plan.assert_not_called()
|
725
|
-
mocks["tf"].apply.assert_not_called()
|
726
|
-
|
727
|
-
|
728
|
-
def test_dry_run(
|
729
|
-
mocker: MockerFixture,
|
730
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
731
|
-
cluster_with_tgw_connection: ClusterV1,
|
732
|
-
tgw_account: AWSAccountV1,
|
733
|
-
tgw: Mapping,
|
734
|
-
vpc_details: Mapping,
|
735
|
-
assume_role: str,
|
736
|
-
) -> None:
|
737
|
-
mocks = _setup_mocks(
|
738
|
-
mocker,
|
739
|
-
vault_settings=app_interface_vault_settings,
|
740
|
-
clusters=[cluster_with_tgw_connection],
|
741
|
-
accounts=[tgw_account],
|
742
|
-
vpc_details=vpc_details,
|
743
|
-
tgws=[tgw],
|
744
|
-
assume_role=assume_role,
|
745
|
-
)
|
746
|
-
|
747
|
-
integ.run(True, enable_deletion=False)
|
748
|
-
|
749
|
-
mocks["get_app_interface_vault_settings"].assert_called_once_with()
|
750
|
-
mocks["get_clusters_with_peering"].assert_called_once_with(mocks["gql_api"])
|
751
|
-
mocks["get_aws_accounts"].assert_called_once_with(mocks["gql_api"])
|
752
|
-
mocks["tf"].plan.assert_called_once_with(False)
|
753
|
-
mocks["tf"].apply.assert_not_called()
|
754
|
-
|
755
|
-
|
756
|
-
def test_non_dry_run(
|
757
|
-
mocker: MockerFixture,
|
758
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
759
|
-
cluster_with_tgw_connection: ClusterV1,
|
760
|
-
tgw_account: AWSAccountV1,
|
761
|
-
tgw: Mapping,
|
762
|
-
vpc_details: Mapping,
|
763
|
-
assume_role: str,
|
764
|
-
) -> None:
|
765
|
-
mocks = _setup_mocks(
|
766
|
-
mocker,
|
767
|
-
vault_settings=app_interface_vault_settings,
|
768
|
-
clusters=[cluster_with_tgw_connection],
|
769
|
-
accounts=[tgw_account],
|
770
|
-
vpc_details=vpc_details,
|
771
|
-
tgws=[tgw],
|
772
|
-
assume_role=assume_role,
|
773
|
-
)
|
774
|
-
|
775
|
-
integ.run(False, enable_deletion=False)
|
776
|
-
|
777
|
-
mocks["get_app_interface_vault_settings"].assert_called_once_with()
|
778
|
-
mocks["get_clusters_with_peering"].assert_called_once_with(mocks["gql_api"])
|
779
|
-
mocks["get_aws_accounts"].assert_called_once_with(mocks["gql_api"])
|
780
|
-
mocks["tf"].plan.assert_called_once_with(False)
|
781
|
-
mocks["tf"].apply.assert_called_once()
|
782
|
-
|
783
|
-
|
784
|
-
def test_run_when_cluster_with_tgw_connection(
|
785
|
-
mocker: MockerFixture,
|
786
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
787
|
-
cluster_with_tgw_connection: ClusterV1,
|
788
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
789
|
-
tgw_account: AWSAccountV1,
|
790
|
-
tgw: Mapping,
|
791
|
-
vpc_details: Mapping,
|
792
|
-
assume_role: str,
|
793
|
-
) -> None:
|
794
|
-
mocks = _setup_mocks(
|
795
|
-
mocker,
|
796
|
-
vault_settings=app_interface_vault_settings,
|
797
|
-
clusters=[cluster_with_tgw_connection],
|
798
|
-
accounts=[tgw_account],
|
799
|
-
vpc_details=vpc_details,
|
800
|
-
tgws=[tgw],
|
801
|
-
assume_role=assume_role,
|
802
|
-
)
|
803
|
-
|
804
|
-
integ.run(True)
|
805
|
-
|
806
|
-
expected_tgw_account = build_expected_tgw_account(
|
807
|
-
connection=account_tgw_connection,
|
808
|
-
tgw=tgw,
|
809
|
-
)
|
810
|
-
expected_cluster_account = build_expected_cluster_account(
|
811
|
-
cluster=cluster_with_tgw_connection,
|
812
|
-
connection=account_tgw_connection,
|
813
|
-
assume_role=assume_role,
|
814
|
-
)
|
815
|
-
expected_desired_state_item = build_expected_desired_state_item(
|
816
|
-
cluster=cluster_with_tgw_connection,
|
817
|
-
connection=account_tgw_connection,
|
818
|
-
tgw=tgw,
|
819
|
-
vpc_details=vpc_details,
|
820
|
-
expected_tgw_account=expected_tgw_account,
|
821
|
-
expected_cluster_account=expected_cluster_account,
|
822
|
-
)
|
823
|
-
|
824
|
-
mocks["aws_api"].assert_called_once_with(
|
825
|
-
1,
|
826
|
-
[tgw_account.dict(by_alias=True)],
|
827
|
-
secret_reader=mocks["secret_reader"],
|
828
|
-
init_users=False,
|
829
|
-
)
|
830
|
-
mocks["ocm"].assert_called_once_with(
|
831
|
-
clusters=[cluster_with_tgw_connection.dict(by_alias=True)],
|
832
|
-
integration=QONTRACT_INTEGRATION,
|
833
|
-
settings=app_interface_vault_settings.dict(by_alias=True),
|
834
|
-
)
|
835
|
-
mocks["ts"].populate_additional_providers.assert_called_once_with(
|
836
|
-
tgw_account.name, [expected_cluster_account]
|
837
|
-
)
|
838
|
-
mocks["ts"].populate_tgw_attachments.assert_called_once_with([
|
839
|
-
expected_desired_state_item
|
840
|
-
])
|
841
|
-
|
842
|
-
|
843
|
-
def test_run_when_cluster_with_mixed_connections(
|
844
|
-
mocker: MockerFixture,
|
845
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
846
|
-
cluster_with_mixed_connections: ClusterV1,
|
847
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
848
|
-
tgw_account: AWSAccountV1,
|
849
|
-
vpc_account: AWSAccountV1,
|
850
|
-
tgw: Mapping,
|
851
|
-
vpc_details: Mapping,
|
852
|
-
assume_role: str,
|
853
|
-
) -> None:
|
854
|
-
mocks = _setup_mocks(
|
855
|
-
mocker,
|
856
|
-
vault_settings=app_interface_vault_settings,
|
857
|
-
clusters=[cluster_with_mixed_connections],
|
858
|
-
accounts=[tgw_account, vpc_account],
|
859
|
-
vpc_details=vpc_details,
|
860
|
-
tgws=[tgw],
|
861
|
-
assume_role=assume_role,
|
862
|
-
)
|
863
|
-
|
864
|
-
integ.run(True)
|
865
|
-
|
866
|
-
expected_tgw_account = build_expected_tgw_account(
|
867
|
-
connection=account_tgw_connection,
|
868
|
-
tgw=tgw,
|
869
|
-
)
|
870
|
-
expected_cluster_account = build_expected_cluster_account(
|
871
|
-
cluster=cluster_with_mixed_connections,
|
872
|
-
connection=account_tgw_connection,
|
873
|
-
assume_role=assume_role,
|
874
|
-
)
|
875
|
-
expected_desired_state_item = build_expected_desired_state_item(
|
876
|
-
cluster=cluster_with_mixed_connections,
|
877
|
-
connection=account_tgw_connection,
|
878
|
-
tgw=tgw,
|
879
|
-
vpc_details=vpc_details,
|
880
|
-
expected_tgw_account=expected_tgw_account,
|
881
|
-
expected_cluster_account=expected_cluster_account,
|
882
|
-
)
|
883
|
-
|
884
|
-
mocks["aws_api"].assert_called_once_with(
|
885
|
-
1,
|
886
|
-
[tgw_account.dict(by_alias=True), vpc_account.dict(by_alias=True)],
|
887
|
-
secret_reader=mocks["secret_reader"],
|
888
|
-
init_users=False,
|
889
|
-
)
|
890
|
-
mocks["ocm"].assert_called_once_with(
|
891
|
-
clusters=[cluster_with_mixed_connections.dict(by_alias=True)],
|
892
|
-
integration=QONTRACT_INTEGRATION,
|
893
|
-
settings=app_interface_vault_settings.dict(by_alias=True),
|
894
|
-
)
|
895
|
-
mocks["ts"].populate_additional_providers.assert_called_once_with(
|
896
|
-
tgw_account.name, [expected_cluster_account]
|
897
|
-
)
|
898
|
-
mocks["ts"].populate_tgw_attachments.assert_called_once_with([
|
899
|
-
expected_desired_state_item
|
900
|
-
])
|
901
|
-
|
902
|
-
|
903
|
-
def test_run_when_cluster_with_vpc_connection_only(
|
904
|
-
mocker: MockerFixture,
|
905
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
906
|
-
cluster_with_vpc_connection: ClusterV1,
|
907
|
-
vpc_account: AWSAccountV1,
|
908
|
-
) -> None:
|
909
|
-
mocks = _setup_mocks(
|
910
|
-
mocker,
|
911
|
-
vault_settings=app_interface_vault_settings,
|
912
|
-
clusters=[cluster_with_vpc_connection],
|
913
|
-
accounts=[vpc_account],
|
914
|
-
)
|
915
|
-
|
916
|
-
integ.run(True)
|
917
|
-
|
918
|
-
mocks["aws_api"].assert_not_called()
|
919
|
-
mocks["ocm"].assert_not_called()
|
920
|
-
mocks["ts"].populate_additional_providers.assert_not_called()
|
921
|
-
mocks["ts"].populate_tgw_attachments.assert_not_called()
|
922
|
-
mocks["tf"].plan.assert_not_called()
|
923
|
-
mocks["tf"].apply.assert_not_called()
|
924
|
-
|
925
|
-
|
926
|
-
def test_run_with_multiple_clusters(
|
927
|
-
mocker: MockerFixture,
|
928
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
929
|
-
cluster_with_tgw_connection: ClusterV1,
|
930
|
-
cluster_with_vpc_connection: ClusterV1,
|
931
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
932
|
-
account_vpc_connection: ClusterPeeringConnectionAccountTGWV1,
|
933
|
-
tgw_account: AWSAccountV1,
|
934
|
-
vpc_account: AWSAccountV1,
|
935
|
-
tgw: Mapping,
|
936
|
-
vpc_details: Mapping,
|
937
|
-
assume_role: str,
|
938
|
-
) -> None:
|
939
|
-
mocks = _setup_mocks(
|
940
|
-
mocker,
|
941
|
-
vault_settings=app_interface_vault_settings,
|
942
|
-
clusters=[cluster_with_tgw_connection, cluster_with_vpc_connection],
|
943
|
-
accounts=[tgw_account, vpc_account],
|
944
|
-
vpc_details=vpc_details,
|
945
|
-
tgws=[tgw],
|
946
|
-
assume_role=assume_role,
|
947
|
-
)
|
948
|
-
|
949
|
-
integ.run(True)
|
950
|
-
|
951
|
-
expected_tgw_account = build_expected_tgw_account(
|
952
|
-
connection=account_tgw_connection,
|
953
|
-
tgw=tgw,
|
954
|
-
)
|
955
|
-
expected_cluster_account = build_expected_cluster_account(
|
956
|
-
cluster=cluster_with_tgw_connection,
|
957
|
-
connection=account_tgw_connection,
|
958
|
-
assume_role=assume_role,
|
959
|
-
)
|
960
|
-
expected_desired_state_item = build_expected_desired_state_item(
|
961
|
-
cluster=cluster_with_tgw_connection,
|
962
|
-
connection=account_tgw_connection,
|
963
|
-
tgw=tgw,
|
964
|
-
vpc_details=vpc_details,
|
965
|
-
expected_tgw_account=expected_tgw_account,
|
966
|
-
expected_cluster_account=expected_cluster_account,
|
967
|
-
)
|
968
|
-
|
969
|
-
mocks["aws_api"].assert_called_once_with(
|
970
|
-
1,
|
971
|
-
[tgw_account.dict(by_alias=True), vpc_account.dict(by_alias=True)],
|
972
|
-
secret_reader=mocks["secret_reader"],
|
973
|
-
init_users=False,
|
974
|
-
)
|
975
|
-
mocks["ocm"].assert_called_once_with(
|
976
|
-
clusters=[cluster_with_tgw_connection.dict(by_alias=True)],
|
977
|
-
integration=QONTRACT_INTEGRATION,
|
978
|
-
settings=app_interface_vault_settings.dict(by_alias=True),
|
979
|
-
)
|
980
|
-
mocks["ts"].populate_additional_providers.assert_called_once_with(
|
981
|
-
tgw_account.name, [expected_cluster_account]
|
982
|
-
)
|
983
|
-
mocks["ts"].populate_tgw_attachments.assert_called_once_with([
|
984
|
-
expected_desired_state_item
|
985
|
-
])
|
986
|
-
|
987
|
-
|
988
|
-
def test_run_with_account_name_for_multiple_clusters(
|
989
|
-
mocker: MockerFixture,
|
990
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
991
|
-
cluster_with_tgw_connection: ClusterV1,
|
992
|
-
additional_cluster_with_tgw_connection: ClusterV1,
|
993
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
994
|
-
tgw_account: AWSAccountV1,
|
995
|
-
tgw: Mapping,
|
996
|
-
vpc_details: Mapping,
|
997
|
-
assume_role: str,
|
998
|
-
) -> None:
|
999
|
-
mocks = _setup_mocks(
|
1000
|
-
mocker,
|
1001
|
-
vault_settings=app_interface_vault_settings,
|
1002
|
-
clusters=[cluster_with_tgw_connection, additional_cluster_with_tgw_connection],
|
1003
|
-
accounts=[tgw_account],
|
1004
|
-
vpc_details=vpc_details,
|
1005
|
-
tgws=[tgw],
|
1006
|
-
assume_role=assume_role,
|
1007
|
-
)
|
1008
|
-
|
1009
|
-
integ.run(True, account_name=tgw_account.name)
|
1010
|
-
|
1011
|
-
expected_tgw_account = build_expected_tgw_account(
|
1012
|
-
connection=account_tgw_connection,
|
1013
|
-
tgw=tgw,
|
1014
|
-
)
|
1015
|
-
expected_cluster_account = build_expected_cluster_account(
|
1016
|
-
cluster=cluster_with_tgw_connection,
|
1017
|
-
connection=account_tgw_connection,
|
1018
|
-
assume_role=assume_role,
|
1019
|
-
)
|
1020
|
-
expected_desired_state_item = build_expected_desired_state_item(
|
1021
|
-
cluster=cluster_with_tgw_connection,
|
1022
|
-
connection=account_tgw_connection,
|
1023
|
-
tgw=tgw,
|
1024
|
-
vpc_details=vpc_details,
|
1025
|
-
expected_tgw_account=expected_tgw_account,
|
1026
|
-
expected_cluster_account=expected_cluster_account,
|
1027
|
-
)
|
1028
|
-
|
1029
|
-
mocks["get_aws_accounts"].assert_called_once_with(mocks["gql_api"])
|
1030
|
-
mocks["aws_api"].assert_called_once_with(
|
1031
|
-
1,
|
1032
|
-
[tgw_account.dict(by_alias=True)],
|
1033
|
-
secret_reader=mocks["secret_reader"],
|
1034
|
-
init_users=False,
|
1035
|
-
)
|
1036
|
-
mocks["ocm"].assert_called_once_with(
|
1037
|
-
clusters=[cluster_with_tgw_connection.dict(by_alias=True)],
|
1038
|
-
integration=QONTRACT_INTEGRATION,
|
1039
|
-
settings=app_interface_vault_settings.dict(by_alias=True),
|
1040
|
-
)
|
1041
|
-
mocks["ts"].populate_additional_providers.assert_called_once_with(
|
1042
|
-
tgw_account.name, [expected_cluster_account]
|
1043
|
-
)
|
1044
|
-
mocks["ts"].populate_tgw_attachments.assert_called_once_with([
|
1045
|
-
expected_desired_state_item
|
1046
|
-
])
|
1047
|
-
|
1048
|
-
|
1049
|
-
def test_run_with_account_name_for_multiple_connections(
|
1050
|
-
mocker: MockerFixture,
|
1051
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
1052
|
-
cluster_with_2_tgw_connections: ClusterV1,
|
1053
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
1054
|
-
tgw_account: AWSAccountV1,
|
1055
|
-
tgw: Mapping,
|
1056
|
-
vpc_details: Mapping,
|
1057
|
-
assume_role: str,
|
1058
|
-
) -> None:
|
1059
|
-
mocks = _setup_mocks(
|
1060
|
-
mocker,
|
1061
|
-
vault_settings=app_interface_vault_settings,
|
1062
|
-
clusters=[cluster_with_2_tgw_connections],
|
1063
|
-
accounts=[tgw_account],
|
1064
|
-
vpc_details=vpc_details,
|
1065
|
-
tgws=[tgw],
|
1066
|
-
assume_role=assume_role,
|
1067
|
-
)
|
1068
|
-
|
1069
|
-
integ.run(True, account_name=tgw_account.name)
|
1070
|
-
|
1071
|
-
expected_tgw_account = build_expected_tgw_account(
|
1072
|
-
connection=account_tgw_connection,
|
1073
|
-
tgw=tgw,
|
1074
|
-
)
|
1075
|
-
expected_cluster_account = build_expected_cluster_account(
|
1076
|
-
cluster=cluster_with_2_tgw_connections,
|
1077
|
-
connection=account_tgw_connection,
|
1078
|
-
assume_role=assume_role,
|
1079
|
-
)
|
1080
|
-
expected_desired_state_item = build_expected_desired_state_item(
|
1081
|
-
cluster=cluster_with_2_tgw_connections,
|
1082
|
-
connection=account_tgw_connection,
|
1083
|
-
tgw=tgw,
|
1084
|
-
vpc_details=vpc_details,
|
1085
|
-
expected_tgw_account=expected_tgw_account,
|
1086
|
-
expected_cluster_account=expected_cluster_account,
|
1087
|
-
)
|
1088
|
-
|
1089
|
-
mocks["get_aws_accounts"].assert_called_once_with(mocks["gql_api"])
|
1090
|
-
mocks["aws_api"].assert_called_once_with(
|
1091
|
-
1,
|
1092
|
-
[tgw_account.dict(by_alias=True)],
|
1093
|
-
secret_reader=mocks["secret_reader"],
|
1094
|
-
init_users=False,
|
1095
|
-
)
|
1096
|
-
mocks["ocm"].assert_called_once_with(
|
1097
|
-
clusters=[cluster_with_2_tgw_connections.dict(by_alias=True)],
|
1098
|
-
integration=QONTRACT_INTEGRATION,
|
1099
|
-
settings=app_interface_vault_settings.dict(by_alias=True),
|
1100
|
-
)
|
1101
|
-
mocks["ts"].populate_additional_providers.assert_called_once_with(
|
1102
|
-
tgw_account.name, [expected_cluster_account]
|
1103
|
-
)
|
1104
|
-
mocks["ts"].populate_tgw_attachments.assert_called_once_with([
|
1105
|
-
expected_desired_state_item
|
1106
|
-
])
|
1107
|
-
|
1108
|
-
|
1109
|
-
def test_duplicate_tgw_connection_names(
|
1110
|
-
mocker: MockerFixture,
|
1111
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
1112
|
-
cluster_with_duplicate_tgw_connections: ClusterV1,
|
1113
|
-
tgw_account: AWSAccountV1,
|
1114
|
-
tgw: AWSAccountV1,
|
1115
|
-
vpc_details: Mapping,
|
1116
|
-
assume_role: str,
|
1117
|
-
) -> None:
|
1118
|
-
_setup_mocks(
|
1119
|
-
mocker,
|
1120
|
-
vault_settings=app_interface_vault_settings,
|
1121
|
-
clusters=[cluster_with_duplicate_tgw_connections],
|
1122
|
-
accounts=[tgw_account],
|
1123
|
-
vpc_details=vpc_details,
|
1124
|
-
tgws=[tgw],
|
1125
|
-
assume_role=assume_role,
|
1126
|
-
)
|
1127
|
-
|
1128
|
-
with pytest.raises(integ.ValidationError) as e:
|
1129
|
-
integ.run(True)
|
1130
|
-
|
1131
|
-
assert str(e.value) == "duplicate tgw connection names found"
|
1132
|
-
|
1133
|
-
|
1134
|
-
def test_missing_vpc_id(
|
1135
|
-
mocker: MockerFixture,
|
1136
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
1137
|
-
cluster_with_tgw_connection: ClusterV1,
|
1138
|
-
tgw_account: AWSAccountV1,
|
1139
|
-
tgw: Mapping,
|
1140
|
-
vpc_details: Mapping,
|
1141
|
-
assume_role: str,
|
1142
|
-
) -> None:
|
1143
|
-
_setup_mocks(
|
1144
|
-
mocker,
|
1145
|
-
vault_settings=app_interface_vault_settings,
|
1146
|
-
clusters=[cluster_with_tgw_connection],
|
1147
|
-
accounts=[tgw_account],
|
1148
|
-
vpc_details=None,
|
1149
|
-
tgws=[tgw],
|
1150
|
-
assume_role=assume_role,
|
1151
|
-
)
|
1152
|
-
|
1153
|
-
with pytest.raises(RuntimeError) as e:
|
1154
|
-
integ.run(True)
|
1155
|
-
|
1156
|
-
assert str(e.value) == "Could not find VPC ID for cluster"
|
1157
|
-
|
1158
|
-
|
1159
|
-
def test_error_in_tf_plan(
|
1160
|
-
mocker: MockerFixture,
|
1161
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
1162
|
-
cluster_with_tgw_connection: ClusterV1,
|
1163
|
-
tgw_account: AWSAccountV1,
|
1164
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
1165
|
-
tgw: Mapping,
|
1166
|
-
vpc_details: Mapping,
|
1167
|
-
assume_role: str,
|
1168
|
-
) -> None:
|
1169
|
-
mocks = _setup_mocks(
|
1170
|
-
mocker,
|
1171
|
-
vault_settings=app_interface_vault_settings,
|
1172
|
-
clusters=[cluster_with_tgw_connection],
|
1173
|
-
accounts=[tgw_account],
|
1174
|
-
vpc_details=vpc_details,
|
1175
|
-
tgws=[tgw],
|
1176
|
-
assume_role=assume_role,
|
1177
|
-
)
|
1178
|
-
mocks["tf"].plan.return_value = (False, True)
|
1179
|
-
|
1180
|
-
with pytest.raises(RuntimeError) as e:
|
1181
|
-
integ.run(True)
|
1182
|
-
|
1183
|
-
assert str(e.value) == "Error running terraform plan"
|
1184
|
-
|
1185
|
-
|
1186
|
-
def test_disabled_deletions_detected_in_tf_plan(
|
1187
|
-
mocker: MockerFixture,
|
1188
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
1189
|
-
cluster_with_tgw_connection: ClusterV1,
|
1190
|
-
tgw_account: AWSAccountV1,
|
1191
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
1192
|
-
tgw: Mapping,
|
1193
|
-
vpc_details: Mapping,
|
1194
|
-
assume_role: str,
|
1195
|
-
) -> None:
|
1196
|
-
mocks = _setup_mocks(
|
1197
|
-
mocker,
|
1198
|
-
vault_settings=app_interface_vault_settings,
|
1199
|
-
clusters=[cluster_with_tgw_connection],
|
1200
|
-
accounts=[tgw_account],
|
1201
|
-
vpc_details=vpc_details,
|
1202
|
-
tgws=[tgw],
|
1203
|
-
assume_role=assume_role,
|
1204
|
-
)
|
1205
|
-
mocks["tf"].plan.return_value = (True, False)
|
1206
|
-
|
1207
|
-
with pytest.raises(RuntimeError) as e:
|
1208
|
-
integ.run(True)
|
1209
|
-
|
1210
|
-
assert str(e.value) == "Disabled deletions detected running terraform plan"
|
1211
|
-
|
1212
|
-
|
1213
|
-
def test_error_in_terraform_apply(
|
1214
|
-
mocker: MockerFixture,
|
1215
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
1216
|
-
cluster_with_tgw_connection: ClusterV1,
|
1217
|
-
account_tgw_connection: ClusterPeeringConnectionAccountTGWV1,
|
1218
|
-
tgw_account: AWSAccountV1,
|
1219
|
-
tgw: Mapping,
|
1220
|
-
vpc_details: Mapping,
|
1221
|
-
assume_role: str,
|
1222
|
-
) -> None:
|
1223
|
-
mocks = _setup_mocks(
|
1224
|
-
mocker,
|
1225
|
-
vault_settings=app_interface_vault_settings,
|
1226
|
-
clusters=[cluster_with_tgw_connection],
|
1227
|
-
accounts=[tgw_account],
|
1228
|
-
vpc_details=vpc_details,
|
1229
|
-
tgws=[tgw],
|
1230
|
-
assume_role=assume_role,
|
1231
|
-
)
|
1232
|
-
mocks["tf"].apply.return_value = True
|
1233
|
-
|
1234
|
-
with pytest.raises(RuntimeError) as e:
|
1235
|
-
integ.run(False)
|
1236
|
-
|
1237
|
-
assert str(e.value) == "Error running terraform apply"
|
1238
|
-
|
1239
|
-
|
1240
|
-
def test_early_exit_desired_state(
|
1241
|
-
mocker: MockerFixture,
|
1242
|
-
app_interface_vault_settings: AppInterfaceSettingsV1,
|
1243
|
-
cluster_with_tgw_connection: ClusterV1,
|
1244
|
-
cluster_with_vpc_connection: ClusterV1,
|
1245
|
-
tgw_account: AWSAccountV1,
|
1246
|
-
vpc_account: AWSAccountV1,
|
1247
|
-
) -> None:
|
1248
|
-
_setup_mocks(
|
1249
|
-
mocker,
|
1250
|
-
vault_settings=app_interface_vault_settings,
|
1251
|
-
clusters=[cluster_with_tgw_connection, cluster_with_vpc_connection],
|
1252
|
-
accounts=[tgw_account, vpc_account],
|
1253
|
-
)
|
1254
|
-
|
1255
|
-
desired_state = integ.early_exit_desired_state()
|
1256
|
-
|
1257
|
-
expected_early_exit_desired_state = {
|
1258
|
-
"clusters": [cluster_with_tgw_connection.dict(by_alias=True)],
|
1259
|
-
"accounts": [tgw_account.dict(by_alias=True), vpc_account.dict(by_alias=True)],
|
1260
|
-
}
|
1261
|
-
|
1262
|
-
assert desired_state == expected_early_exit_desired_state
|
1263
|
-
|
1264
|
-
|
1265
|
-
def test_desired_state_shard_config() -> None:
|
1266
|
-
proposal_with_1_shard = ShardedRunProposal(
|
1267
|
-
proposed_shards={
|
1268
|
-
"account1",
|
1269
|
-
}
|
1270
|
-
)
|
1271
|
-
proposal_with_2_shards = ShardedRunProposal(
|
1272
|
-
proposed_shards={
|
1273
|
-
"account1",
|
1274
|
-
"account2",
|
1275
|
-
}
|
1276
|
-
)
|
1277
|
-
proposal_with_3_shards = ShardedRunProposal(
|
1278
|
-
proposed_shards={
|
1279
|
-
"account1",
|
1280
|
-
"account2",
|
1281
|
-
"account3",
|
1282
|
-
}
|
1283
|
-
)
|
1284
|
-
|
1285
|
-
config = integ.desired_state_shard_config()
|
1286
|
-
|
1287
|
-
assert config.shard_arg_name == "account_name"
|
1288
|
-
assert config.shard_path_selectors == {
|
1289
|
-
"accounts[*].name",
|
1290
|
-
"clusters[*].peering.connections[*].account.name",
|
1291
|
-
}
|
1292
|
-
assert config.shard_arg_is_collection is False
|
1293
|
-
assert config.sharded_run_review(proposal_with_1_shard) is True
|
1294
|
-
assert config.sharded_run_review(proposal_with_2_shards) is True
|
1295
|
-
assert config.sharded_run_review(proposal_with_3_shards) is False
|