From 21f0bfd8c77429c51ba3d3f434adc931d6d2d1b5 Mon Sep 17 00:00:00 2001 From: Yury Tsarev Date: Wed, 19 Nov 2025 16:58:01 +0100 Subject: [PATCH 1/3] Working e2e tests Signed-off-by: Yury Tsarev --- apis/composition-rds-metrics.yaml | 2 +- .../operation.yaml | 1 + tests/e2etest-sqlinstance/main.k | 49 ++++++++++++++++--- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/apis/composition-rds-metrics.yaml b/apis/composition-rds-metrics.yaml index 684987a..f12015f 100644 --- a/apis/composition-rds-metrics.yaml +++ b/apis/composition-rds-metrics.yaml @@ -35,7 +35,7 @@ spec: - name: aws-creds source: Secret secretRef: - namespace: database-team + namespace: crossplane-system name: aws-creds - step: crossplane-contrib-function-auto-ready functionRef: diff --git a/operations/rds-intelligent-scaling-cron/operation.yaml b/operations/rds-intelligent-scaling-cron/operation.yaml index 59bc1a9..00b838b 100644 --- a/operations/rds-intelligent-scaling-cron/operation.yaml +++ b/operations/rds-intelligent-scaling-cron/operation.yaml @@ -29,6 +29,7 @@ spec: input: apiVersion: claude.fn.upbound.io/v1alpha1 kind: Prompt + modelName: claude-haiku-4-5@20251001 # haiku brings serious cost savings systemPrompt: | You are an intelligent RDS scaling system that analyzes SQLInstance resources and makes scaling decisions based on CloudWatch performance metrics. diff --git a/tests/e2etest-sqlinstance/main.k b/tests/e2etest-sqlinstance/main.k index c5f3eef..40f2ec1 100644 --- a/tests/e2etest-sqlinstance/main.k +++ b/tests/e2etest-sqlinstance/main.k @@ -1,52 +1,71 @@ import models.io.upbound.awsm.v1beta1 as awsv1beta1 import models.io.upbound.dev.meta.v1alpha1 as metav1alpha1 import models.io.upbound.platform.aws.v1alpha1 as platformawsv1alpha1 +import models.io.k8s.api.core.v1 as corev1 _items = [ metav1alpha1.E2ETest{ metadata.name: "sqlinstances" spec= { - crossplane.autoUpgrade.channel: "Rapid" + crossplane.autoUpgrade.channel: "None" + crossplane.version: "2.1.1-up.1" defaultConditions: ["Ready"] manifests: [ + # MariaDB instance with AI-powered scaling enabled platformawsv1alpha1.SQLInstance{ metadata = { - name = "configuration-aws-database-mariadb" + name = "configuration-aws-database-ai-e2e-mariadb" + namespace = "default" + labels = { + "scale" = "me" + } } spec = { + crossplane.compositionSelector.matchLabels = { + "type" = "rds-metrics" + } parameters = { region = "us-west-2" engine = "mariadb" engineVersion = "10.11" storageGB = 5 + instanceClass = "db.t3.micro" autoGeneratePassword = True + publiclyAccessible = False passwordSecretRef = { name = "mariadbsecret" key = "password" } networkRef = { - id = "configuration-aws-database" + id = "configuration-aws-database-ai-e2e" } } } } + # Postgres instance without AI scaling (baseline test) platformawsv1alpha1.SQLInstance{ metadata = { - name = "configuration-aws-database-postgres" + name = "configuration-aws-database-ai-e2e-postgres" + namespace = "default" } spec = { + crossplane.compositionSelector.matchLabels = { + "type" = "rds-metrics" + } parameters = { region = "us-west-2" engine = "postgres" engineVersion = "13.18" storageGB = 5 + instanceClass = "db.t3.micro" autoGeneratePassword = True + publiclyAccessible = False passwordSecretRef = { name = "psqlsecret" key = "password" } networkRef = { - id = "configuration-aws-database" + id = "configuration-aws-database-ai-e2e" } } } @@ -55,12 +74,12 @@ _items = [ apiVersion = "aws.platform.upbound.io/v1alpha1" kind = "Network" metadata = { - name = "configuration-aws-database" + name = "configuration-aws-database-ai-e2e" namespace = "default" } spec = { parameters = { - id = "configuration-aws-database" + id = "configuration-aws-database-ai-e2e" region = "us-west-2" } } @@ -70,7 +89,10 @@ _items = [ extraResources: [ # Define the provider configuration awsv1beta1.ProviderConfig{ - metadata.name = "default" + metadata = { + name = "default" + namespace = "default" + } spec = { credentials = { source = "Upbound" @@ -82,6 +104,17 @@ _items = [ } } } + # AWS credentials secret for function-rds-metrics (fake credentials for e2e test) + corev1.Secret{ + metadata = { + name = "aws-creds" + namespace = "crossplane-system" + } + type = "Opaque" + data = { + credentials = "W2RlZmF1bHRdCmF3c19hY2Nlc3Nfa2V5X2lkID0gQUtJQUlPU0ZPRE5ON0VYQU1QTEUKYXdzX3NlY3JldF9hY2Nlc3Nfa2V5ID0gd0phbHJYVXRuRkVNSS9LN01ERU5HL2JQeFJmaUNZRVhBTVBMRUtFWQ==" + } + } ] skipDelete: False timeoutSeconds: 4500 From 27a760e4a886a8da9957bc3539a9d5af64535005 Mon Sep 17 00:00:00 2001 From: Yury Tsarev Date: Thu, 20 Nov 2025 23:04:48 +0100 Subject: [PATCH 2/3] Proper switch to haiku model Signed-off-by: Yury Tsarev --- examples/providerconfig-aws-oidc.yaml | 12 ++++++++++++ ...-aws.yaml => providerconfig-aws-static.yaml} | 0 .../rds-intelligent-scaling-cron/operation.yaml | 17 +++++++---------- upbound.yaml | 2 +- 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 examples/providerconfig-aws-oidc.yaml rename examples/{providerconfig-aws.yaml => providerconfig-aws-static.yaml} (100%) diff --git a/examples/providerconfig-aws-oidc.yaml b/examples/providerconfig-aws-oidc.yaml new file mode 100644 index 0000000..18fe648 --- /dev/null +++ b/examples/providerconfig-aws-oidc.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: aws.m.upbound.io/v1beta1 +kind: ProviderConfig +metadata: + name: default + namespace: database-team +spec: + credentials: + source: Upbound + upbound: + webIdentity: + roleARN: arn:aws:iam::609897127049:role/solutions-e2e-provider-aws diff --git a/examples/providerconfig-aws.yaml b/examples/providerconfig-aws-static.yaml similarity index 100% rename from examples/providerconfig-aws.yaml rename to examples/providerconfig-aws-static.yaml diff --git a/operations/rds-intelligent-scaling-cron/operation.yaml b/operations/rds-intelligent-scaling-cron/operation.yaml index 00b838b..15e050b 100644 --- a/operations/rds-intelligent-scaling-cron/operation.yaml +++ b/operations/rds-intelligent-scaling-cron/operation.yaml @@ -29,12 +29,12 @@ spec: input: apiVersion: claude.fn.upbound.io/v1alpha1 kind: Prompt - modelName: claude-haiku-4-5@20251001 # haiku brings serious cost savings + modelName: claude-haiku-4-5 # haiku brings serious cost savings systemPrompt: | You are an intelligent RDS scaling system that analyzes SQLInstance resources and makes scaling decisions based on CloudWatch performance metrics. - Output only the JSON patch for the SQLInstance resource. Your entire response should be the JSON object, nothing else. + Return a JSON patch for the SQLInstance resource. userPrompt: | You are analyzing a SQLInstance resource for potential RDS scaling needs. @@ -60,7 +60,7 @@ spec: - Ensure minimum 5-minute cooldown between scaling events OUTPUT FORMAT: - Provide your response as a JSON resource patch. The JSON should contain ONLY the fields that need to be updated. + Return a JSON patch containing only the fields that need updating. If scaling is needed: { @@ -96,13 +96,10 @@ spec: } Rules: - - Use the exact resource name and namespace from the input - - Only include fields that need to be updated - - Use current timestamp in ISO8601 format - - Provide brief, clear reasoning in annotations - - IMPORTANT: v2 resources are namespaced, always include namespace in metadata - - Output the JSON on a single line without extra formatting - - no ```json in the output + - Use exact resource name and namespace from input + - Use current timestamp in ISO8601 format (YYYY-MM-DDTHH:MM:SSZ) + - Provide clear, concise reasoning in decision annotation + - Include namespace in metadata (v2 resources are namespaced) SQLInstance Resource: {{ .Resources }} diff --git a/upbound.yaml b/upbound.yaml index a4f23aa..744b88f 100644 --- a/upbound.yaml +++ b/upbound.yaml @@ -23,7 +23,7 @@ spec: - apiVersion: pkg.crossplane.io/v1 kind: Function package: xpkg.upbound.io/upbound/function-claude - version: v0.3.0 + version: v0.4.0 - apiVersion: pkg.crossplane.io/v1beta1 kind: Function package: xpkg.upbound.io/upbound/function-rds-metrics From 5824ac2c5fce40648954ad0306a967119ef845bb Mon Sep 17 00:00:00 2001 From: Yury Tsarev Date: Thu, 20 Nov 2025 23:46:25 +0100 Subject: [PATCH 3/3] Syncup test credentials namespace with composition Signed-off-by: Yury Tsarev --- tests/test-credentials.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-credentials.yaml b/tests/test-credentials.yaml index 4dd2e76..8ab7175 100644 --- a/tests/test-credentials.yaml +++ b/tests/test-credentials.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: aws-creds - namespace: database-team + namespace: crossplane-system type: Opaque data: credentials: W2RlZmF1bHRdCmF3c19hY2Nlc3Nfa2V5X2lkID0gQUtJQUlPU0ZPRE5ON0VYQU1QTEUKYXdzX3NlY3JldF9hY2Nlc3Nfa2V5ID0gd0phbHJYVXRuRkVNSS9LN01ERU5HL2JQeFJmaUNZRVhBTVBMRUtFWQ==