Skip to content

Commit 9135001

Browse files
authored
Add deletion of OIDC providers into e2e tests (#15)
Issue #, if available: aws-controllers-k8s/community#1444 Description of changes: OIDC providers were not deleted after you run e2e tests. As a result, there was huge number of OIDC providers created that needed manual deletion. With this PR, deletion of OIDC is taken care by e2e tests By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent b8b645c commit 9135001

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/e2e/tests/test_virtualcluster_jobrun.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,9 @@ def get_assume_role_policy(self, iam_client, job_execution_role_name):
185185
role = self.iam_client.get_role(RoleName=job_execution_role_name)
186186
return role.get("Role").get("AssumeRolePolicyDocument")
187187

188-
def update_assume_role(self, iam_client):
188+
def update_assume_role(self, oidc_provider_arn, iam_client):
189189
job_execution_role_arn = get_bootstrap_resources().JobExecutionRole.arn
190190
job_execution_role_name = job_execution_role_arn.split('role/')[1]
191-
oidc_provider_arn = get_bootstrap_resources().HostCluster.export_oidc_arn
192191
oidc_provider = oidc_provider_arn.split('oidc-provider/')[1]
193192
emr_namespace = "emr-ns"
194193
base36_encoded_role_name = self.base36_encode(job_execution_role_name)
@@ -247,9 +246,10 @@ def update_assume_role(self, iam_client):
247246
return TRUST_POLICY_STATEMENT_ALREADY_EXISTS % job_execution_role_name
248247

249248
def test_create_delete_virtualcluster_jobrun(self, virtualcluster_jobrun, emrcontainers_client, iam_client):
249+
oidc_provider_arn = get_bootstrap_resources().HostCluster.export_oidc_arn
250250

251251
# Update Job Execution Role
252-
role_update = self.update_assume_role(iam_client)
252+
role_update = self.update_assume_role(oidc_provider_arn, iam_client)
253253
assert role_update
254254

255255
(vc_ref, vc_cr, jr_ref, jr_cr) = virtualcluster_jobrun
@@ -272,3 +272,10 @@ def test_create_delete_virtualcluster_jobrun(self, virtualcluster_jobrun, emrcon
272272
assert aws_res is not None
273273
except emrcontainers_client.exceptions.ResourceNotFoundException:
274274
pytest.fail(f"Could not find job run with ID '{jobrun_id}' in EMR on EKS")
275+
276+
# delete oidc provider
277+
try:
278+
aws_res = iam_client.delete_open_id_connect_provider(OpenIDConnectProviderArn=oidc_provider_arn)
279+
assert aws_res is not None
280+
except iam_client.exceptions.InvalidInputException:
281+
pytest.fail(f"Could not delete oidc identity provider")

0 commit comments

Comments
 (0)