From 30f6eb1e187c8e0a4ed14afe6730ed02801e7dd8 Mon Sep 17 00:00:00 2001 From: michaelhtm <98621731+michaelhtm@users.noreply.github.com> Date: Tue, 25 Nov 2025 02:02:24 -0800 Subject: [PATCH 1/2] test adoption policy adopt with missing adoption fields --- go.mod | 2 ++ go.sum | 4 ++-- .../e2e/resources/bucket_adopt_no_fields.yaml | 7 +++++++ test/e2e/tests/test_bucket_adoption_policy.py | 20 +++++++++++++++++-- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 test/e2e/resources/bucket_adopt_no_fields.yaml diff --git a/go.mod b/go.mod index b6d005b..f8da50f 100644 --- a/go.mod +++ b/go.mod @@ -94,3 +94,5 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) + +replace github.com/aws-controllers-k8s/runtime => github.com/michaelhtm/ack-runtime v0.49.1-0.20251125200234-a9b99409495f diff --git a/go.sum b/go.sum index 1f02bd2..fcb33bb 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/aws-controllers-k8s/runtime v0.54.1 h1:0mbCJELz3t7jbG4abNecF0yeRd8YeFZQPr7nnzr8DC8= -github.com/aws-controllers-k8s/runtime v0.54.1/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc= github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY= github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go-v2 v1.34.0 h1:9iyL+cjifckRGEVpRKZP3eIxVlL06Qk1Tk13vreaVQU= @@ -117,6 +115,8 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/michaelhtm/ack-runtime v0.49.1-0.20251125200234-a9b99409495f h1:3g8FiST0S0SZTt346twBca3JjumYdMuxj16J9Y4CBpU= +github.com/michaelhtm/ack-runtime v0.49.1-0.20251125200234-a9b99409495f/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/test/e2e/resources/bucket_adopt_no_fields.yaml b/test/e2e/resources/bucket_adopt_no_fields.yaml new file mode 100644 index 0000000..40442db --- /dev/null +++ b/test/e2e/resources/bucket_adopt_no_fields.yaml @@ -0,0 +1,7 @@ +apiVersion: s3.services.k8s.aws/v1alpha1 +kind: Bucket +metadata: + name: $RANDOM_BUCKET_NAME + annotations: + services.k8s.aws/adoption-policy: $ADOPTION_POLICY + services.k8s.aws/deletion-policy: retain diff --git a/test/e2e/tests/test_bucket_adoption_policy.py b/test/e2e/tests/test_bucket_adoption_policy.py index df0e8d7..e8e749c 100644 --- a/test/e2e/tests/test_bucket_adoption_policy.py +++ b/test/e2e/tests/test_bucket_adoption_policy.py @@ -27,7 +27,7 @@ from e2e.replacement_values import REPLACEMENT_VALUES CREATE_WAIT_AFTER_SECONDS = 10 -MODIFY_WAIT_AFTER_SECONDS = 20 +MODIFY_WAIT_AFTER_SECONDS = 10 DELETE_WAIT_AFTER_SECONDS = 10 ACK_SYSTEM_TAG_PREFIX = "services.k8s.aws/" AWS_SYSTEM_TAG_PREFIX = "aws:" @@ -150,6 +150,20 @@ def test_adopt_policy( assert latest is not None versioning = latest.Versioning() assert versioning.status == status + + @pytest.mark.resource_data({'adoption-policy': AdoptionPolicy.ADOPT, 'filename': 'bucket_adopt_no_fields', 'resource-name': 'adopt'}) + def test_adopt_policy_missing_fields( + self, s3_client, bucket_adoption_policy, s3_resource + ): + (ref, cr) = bucket_adoption_policy + + k8s.wait_on_condition(ref, "ACK.Terminal", "True", wait_periods=5) + + condition = k8s.get_resource_condition(ref, "ACK.Terminal") + assert condition is not None + + expected_msg = "adoption-fields is not defined" + assert expected_msg in condition['reason'] @pytest.mark.resource_data({'adoption-policy': AdoptionPolicy.ADOPT_OR_CREATE, 'filename': 'bucket_adopt_or_create', 'resource-name': 'adopt-or-create'}) def test_adopt_or_create_policy( @@ -162,7 +176,9 @@ def test_adopt_or_create_policy( assert 'spec' in cr assert 'name' in cr['spec'] bucket_name = cr['spec']['name'] - + + # Wait for tags to appear on describe + time.sleep(MODIFY_WAIT_AFTER_SECONDS) latest = get_bucket(s3_resource, bucket_name) assert latest is not None tagging = latest.Tagging() From 8dd1e5e4c0aa009bfa0bc883450ad2ac4400d2a3 Mon Sep 17 00:00:00 2001 From: michaelhtm <98621731+michaelhtm@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:04:46 -0800 Subject: [PATCH 2/2] test with new changes --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f8da50f..3142e33 100644 --- a/go.mod +++ b/go.mod @@ -95,4 +95,4 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -replace github.com/aws-controllers-k8s/runtime => github.com/michaelhtm/ack-runtime v0.49.1-0.20251125200234-a9b99409495f +replace github.com/aws-controllers-k8s/runtime => github.com/michaelhtm/ack-runtime v0.49.1-0.20251128221640-3f1a6cfbdbb0 diff --git a/go.sum b/go.sum index fcb33bb..86c42c6 100644 --- a/go.sum +++ b/go.sum @@ -115,8 +115,8 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/michaelhtm/ack-runtime v0.49.1-0.20251125200234-a9b99409495f h1:3g8FiST0S0SZTt346twBca3JjumYdMuxj16J9Y4CBpU= -github.com/michaelhtm/ack-runtime v0.49.1-0.20251125200234-a9b99409495f/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc= +github.com/michaelhtm/ack-runtime v0.49.1-0.20251128221640-3f1a6cfbdbb0 h1:uazsV2Xsloxb7DQbMLayNFfHYAShiPIjGdD2IlmWysM= +github.com/michaelhtm/ack-runtime v0.49.1-0.20251128221640-3f1a6cfbdbb0/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=