From 1308ba31041ba812bb87f20aa76dcf4e1ee14ea2 Mon Sep 17 00:00:00 2001 From: Mingjie Shao Date: Mon, 29 Jul 2024 17:20:01 +0100 Subject: [PATCH] feat: Adding E2E log test for RDS database interations (#104) This change introduces the expected EMF log templates and asserts them after calling `/mysql` API. --- .github/workflows/java-eks-e2e-test.yml | 1 + .../PredefinedExpectedTemplate.java | 1 + .../java/eks/rds-mysql-log.mustache | 36 +++++++++++++++++++ .../validations/java/eks/log-validation.yml | 8 ++++- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 validator/src/main/resources/expected-data-template/java/eks/rds-mysql-log.mustache diff --git a/.github/workflows/java-eks-e2e-test.yml b/.github/workflows/java-eks-e2e-test.yml index d17d7bb8a..96ee43f38 100644 --- a/.github/workflows/java-eks-e2e-test.yml +++ b/.github/workflows/java-eks-e2e-test.yml @@ -371,6 +371,7 @@ jobs: --platform-info ${{ env.CLUSTER_NAME }} --service-name sample-application-${{ env.TESTING_ID }} --remote-service-deployment-name ${{ env.REMOTE_SERVICE_DEPLOYMENT_NAME }} + --remote-resource-identifier "information_schema|${{env.RDS_MYSQL_CLUSTER_ENDPOINT}}|3306" --query-string ip=${{ env.REMOTE_SERVICE_POD_IP }}&testingId=${{ env.TESTING_ID }} --rollup' diff --git a/validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java b/validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java index 772d7c577..bc4cda75f 100644 --- a/validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java +++ b/validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java @@ -39,6 +39,7 @@ public enum PredefinedExpectedTemplate implements FileConfig { JAVA_EKS_CLIENT_CALL_METRIC("/expected-data-template/java/eks/client-call-metric.mustache"), JAVA_EKS_CLIENT_CALL_TRACE("/expected-data-template/java/eks/client-call-trace.mustache"), + JAVA_EKS_RDS_MYSQL_LOG("/expected-data-template/java/eks/rds-mysql-log.mustache"), JAVA_EKS_RDS_MYSQL_METRIC("/expected-data-template/java/eks/rds-mysql-metric.mustache"), /** Java EC2 Default Test Case Validations */ diff --git a/validator/src/main/resources/expected-data-template/java/eks/rds-mysql-log.mustache b/validator/src/main/resources/expected-data-template/java/eks/rds-mysql-log.mustache new file mode 100644 index 000000000..79d82f2a0 --- /dev/null +++ b/validator/src/main/resources/expected-data-template/java/eks/rds-mysql-log.mustache @@ -0,0 +1,36 @@ +[{ + "EC2.AutoScalingGroup": "^eks-.+", + "EC2.InstanceId": "^i-[A-Za-z0-9]{17}$", + "EKS.Cluster": "^{{platformInfo}}$", + "Environment": "^eks:{{platformInfo}}/{{appNamespace}}$", + "K8s.Namespace": "^{{appNamespace}}$", + "K8s.Node": "^i-[A-Za-z0-9]{17}$", + "K8s.Pod": "^sample-app-deployment-{{testingId}}(-[A-Za-z0-9]*)*$", + "K8s.Workload": "^sample-app-deployment-{{testingId}}$", + "PlatformType": "^AWS::EKS$", + "Service": "^{{serviceName}}$", + "Operation": "GET /mysql", + "Version": "^1$", + "Telemetry.Source": "^LocalRootSpan$", + "Host": "^ip(-[0-9]{1,3}){4}.*$" +}, +{ + "EC2.AutoScalingGroup": "^eks-.+", + "EC2.InstanceId": "^i-[A-Za-z0-9]{17}$", + "EKS.Cluster": "^{{platformInfo}}$", + "Environment": "^eks:{{platformInfo}}/{{appNamespace}}$", + "K8s.Namespace": "^{{appNamespace}}$", + "K8s.Node": "^i-[A-Za-z0-9]{17}$", + "K8s.Pod": "^sample-app-deployment-{{testingId}}(-[A-Za-z0-9]*)*$", + "K8s.Workload": "^sample-app-deployment-{{testingId}}$", + "PlatformType": "^AWS::EKS$", + "Service": "^{{serviceName}}$", + "Operation": "GET /mysql", + "Version": "^1$", + "Telemetry.Source": "^ClientSpan$", + "Host": "^ip(-[0-9]{1,3}){4}.*$", + "RemoteService": "mysql", + "RemoteOperation": "SELECT", + "RemoteResourceType": "DB::Connection", + "RemoteResourceIdentifier": "^{{remoteResourceIdentifier}}$" +}] \ No newline at end of file diff --git a/validator/src/main/resources/validations/java/eks/log-validation.yml b/validator/src/main/resources/validations/java/eks/log-validation.yml index 9b36b51f4..7373eb3f3 100644 --- a/validator/src/main/resources/validations/java/eks/log-validation.yml +++ b/validator/src/main/resources/validations/java/eks/log-validation.yml @@ -21,4 +21,10 @@ httpPath: "/client-call" httpMethod: "get" callingType: "http" - expectedLogStructureTemplate: "JAVA_EKS_CLIENT_CALL_LOG" \ No newline at end of file + expectedLogStructureTemplate: "JAVA_EKS_CLIENT_CALL_LOG" +- + validationType: "cw-log" + httpPath: "/mysql" + httpMethod: "get" + callingType: "http" + expectedLogStructureTemplate: "JAVA_EKS_RDS_MYSQL_LOG" \ No newline at end of file