From 661107a8327011f309b5771f141ddd6dcdccd83e Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 12:25:58 -0500 Subject: [PATCH] Add sample applicatin configuration. --- terraform/e2e/eks/$HOME/.kube/config | 51 +++++++++++++++++++ terraform/e2e/eks/main.tf | 19 ++++--- terraform/e2e/eks/variables.tf | 10 ++++ .../jmx/files/cwagent_configs/jvm_tomcat.json | 40 +++++++++++++++ .../tomcat-deployment.yaml | 0 test/e2e/jmx/validate_test.go | 14 +++++ 6 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 terraform/e2e/eks/$HOME/.kube/config create mode 100644 test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json create mode 100644 test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml create mode 100644 test/e2e/jmx/validate_test.go diff --git a/terraform/e2e/eks/$HOME/.kube/config b/terraform/e2e/eks/$HOME/.kube/config new file mode 100644 index 000000000..b1f1b877d --- /dev/null +++ b/terraform/e2e/eks/$HOME/.kube/config @@ -0,0 +1,51 @@ +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQWV5Z0F3SUJBZ0lIZVhUTi9jOWtRREFOQmdrcWhraUc5dzBCQVFzRkFEQVZNUk13RVFZRFZRUUQKRXdwcmRXSmxjbTVsZEdWek1CNFhEVEkwTVRFeE5ERTRORGswTlZvWERUTTBNVEV4TWpFNE5UUTBOVm93RlRFVApNQkVHQTFVRUF4TUthM1ZpWlhKdVpYUmxjekNDQVNJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DCmdnRUJBUFFiVmdUa20wQnF4NTA4UnhCczZETmdlQnFva1hBdW9SUnpOT2RwVlQrbGhhTW11U3RTNElFQnNBbWgKNWQyMTFrRy9RMnV3L0NJVXNTc25Kdm5PU1UxTU9mdVVpRFRublJIUGhuT3hTbklaSjNwSFlTTXJrdGljVzRHSgp6dT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3ZytQYjBnMApSeHFZczh1K2ZCZEszZHpaY1NuVE9idW9DU0pvZEI2NzVic3VWRlkvYk9HeTJHb0VsazdMbDIrTnBsVGM1UitvCm4xNlRMVGxMb1FEZE1qa0tXcDRmK09FbHlLb09vRi9Objd4OG9waDBNaEVzZXE1NzZvUjhsMExsRkF4QyticXYKMUdYWG9GR3JQY0JGMitjbk1tbkcyTU1iRVEwL0NRV0M3dkx0ZUNqYll4a0FZejZZd3JIbC9HQ3k2TENFMmhMdgpLZkkxS0JZUkkvU2wya2d2L1FFbTQrb25KM3RHcHBGNmsyU0tFMkplNzErR1pXUXphcGJGK1JZWFFuRHJuN3FzCjIybmJZSnpMblptUXRvbVFVZ0MwbitKNG95QjFtSmlMVk4vaHJBaDAvV29Wd2VoQ2xmRjNEVW1JZ1JUQ1dVM3UKZk1UYUNEaE5XemUyCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K + server: https://92BAADEAD75DB06218CE1125A95FFA4B.gr7.us-west-2.eks.amazonaws.com + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +contexts: +- context: + cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 +- context: + cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +current-context: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +kind: Config +preferences: {} +users: +- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + user: + exec: + apiVersion: client.authentication.k8s.io/v1beta1 + args: + - --region + - us-west-2 + - eks + - get-token + - --cluster-name + - cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + - --output + - json + command: aws +- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + user: + exec: + apiVersion: client.authentication.k8s.io/v1beta1 + args: + - --region + - us-west-2 + - eks + - get-token + - --cluster-name + - cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + - --output + - json + command: aws diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index bc9cc96e7..0bd9efb93 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -35,9 +35,9 @@ resource "aws_eks_node_group" "this" { subnet_ids = module.basic_components.public_subnet_ids scaling_config { - desired_size = 1 - max_size = 1 - min_size = 1 + desired_size = 2 + max_size = 2 + min_size = 2 } ami_type = "AL2_x86_64" @@ -121,14 +121,18 @@ resource "null_resource" "helm_charts" { } } -resource "null_resource" "install_helm_release" { +resource "null_resource" "install_helm_release_and_sample_app" { depends_on = [ null_resource.kubectl, - aws_eks_cluster.this + null_resource.helm_charts, + aws_eks_cluster.this, + aws_eks_node_group.this ] provisioner "local-exec" { command = <<-EOT + ${local.aws_eks} update-kubeconfig --name ${aws_eks_cluster.this.name} + helm upgrade --install amazon-cloudwatch-observability \ ${path.module}/helm-charts/charts/amazon-cloudwatch-observability \ --values ${path.module}/helm-charts/charts/amazon-cloudwatch-observability/values.yaml \ @@ -145,6 +149,9 @@ resource "null_resource" "install_helm_release" { ${var.agent-config != "" ? "--set-json agent.config='${jsonencode(jsondecode(file(var.agent-config)))}'" : ""} \ ${var.otel-config != "" ? "--set-file agent.otelConfig=${yamlencode(yamldecode(file(var.otel-config)))}" : ""} \ ${var.prometheus-config != "" ? "--set-file agent.prometheus.config=${yamlencode(yamldecode(file(var.prometheus-config)))}" : ""} + + kubectl apply -f ${var.sample-app} + kubectl wait --for=condition=available --timeout=300s deployment/${var.sample-app-name} EOT environment = { @@ -155,7 +162,7 @@ resource "null_resource" "install_helm_release" { resource "null_resource" "test" { depends_on = [ - null_resource.install_helm_release + null_resource.install_helm_release_and_sample_app ] provisioner "local-exec" { diff --git a/terraform/e2e/eks/variables.tf b/terraform/e2e/eks/variables.tf index 8c2dc04f0..f3494742e 100644 --- a/terraform/e2e/eks/variables.tf +++ b/terraform/e2e/eks/variables.tf @@ -79,4 +79,14 @@ variable "cloudwatch_agent_operator_repository_url" { variable "validate_test" { type = string default = "../../../test/e2e/jmx/validate_test.go" +} + +variable "sample-app" { + type = string + default = "../../../test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml" +} + +variable "sample-app-name" { + type = string + default = "tomcat-deployment" } \ No newline at end of file diff --git a/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json b/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json new file mode 100644 index 000000000..c0c2a10dd --- /dev/null +++ b/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json @@ -0,0 +1,40 @@ +{ + "metrics": { + "namespace": "JVM_TOMCAT_E2E", + "metrics_collected": { + "jmx": { + "jvm": { + "measurement": [ + "jvm.classes.loaded", + "jvm.gc.collections.count", + "jvm.gc.collections.elapsed", + "jvm.memory.heap.committed", + "jvm.memory.heap.init", + "jvm.memory.heap.max", + "jvm.memory.heap.used", + "jvm.memory.nonheap.committed", + "jvm.memory.nonheap.init", + "jvm.memory.nonheap.max", + "jvm.memory.nonheap.used", + "jvm.memory.pool.committed", + "jvm.memory.pool.init", + "jvm.memory.pool.max", + "jvm.memory.pool.used", + "jvm.threads.count" + ] + }, + "tomcat": { + "measurement": [ + "tomcat.sessions", + "tomcat.errors", + "tomcat.request_count", + "tomcat.max_time", + "tomcat.processing_time", + "tomcat.traffic", + "tomcat.threads" + ] + } + } + } + } +} \ No newline at end of file diff --git a/test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml b/test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/test/e2e/jmx/validate_test.go b/test/e2e/jmx/validate_test.go new file mode 100644 index 000000000..73093fee3 --- /dev/null +++ b/test/e2e/jmx/validate_test.go @@ -0,0 +1,14 @@ +package jmx + +import ( + "fmt" + "testing" +) + +func TestMetrics(t *testing.T) { + fmt.Printf("TestMetrics") +} + +func TestResources(t *testing.T) { + fmt.Printf("TestResources") +}