Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions environment/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type MetaData struct {
SampleApp string
AccountId string
EKSInstallationType eksinstallationtype.EKSInstallationType
EnableTargetAllocator bool
}

type MetaDataStrings struct {
Expand Down Expand Up @@ -110,6 +111,7 @@ type MetaDataStrings struct {
SampleApp string
AccountId string
EKSInstallationType string
EnableTargetAllocator bool
}

func registerComputeType(dataString *MetaDataStrings) {
Expand Down Expand Up @@ -161,6 +163,8 @@ func registerEKSE2ETestData(dataString *MetaDataStrings) {
flag.StringVar(&(dataString.OtelConfig), "otel_config", "", "OpenTelemetry configuration file path")
flag.StringVar(&(dataString.SampleApp), "sample_app", "", "Sample application manifest file path")
flag.StringVar(&(dataString.EKSInstallationType), "eks_installation_type", "HELM_CHART", "Installation type (HELM_CHART or EKS_ADDON)")
flag.BoolVar(&(dataString.EnableTargetAllocator), "enable_target_allocator", false, "Whether to enable target allocator (true/false")

}

func registerPluginTestsToExecute(dataString *MetaDataStrings) {
Expand Down Expand Up @@ -370,6 +374,7 @@ func GetEnvironmentMetaData() *MetaData {
metaDataStorage.OtelConfig = registeredMetaDataStrings.OtelConfig
metaDataStorage.SampleApp = registeredMetaDataStrings.SampleApp
metaDataStorage.AccountId = registeredMetaDataStrings.AccountId
metaDataStorage.EnableTargetAllocator = registeredMetaDataStrings.EnableTargetAllocator
fillEKSInstallationType(metaDataStorage, registeredMetaDataStrings)

return metaDataStorage
Expand Down
5 changes: 5 additions & 0 deletions generator/resources/eks_e2e_prometheus_test_matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{
"nodes": 2
}
]
15 changes: 14 additions & 1 deletion terraform/eks/e2e/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ resource "aws_eks_addon" "this" {
configuration_values = file("${var.test_dir}/${var.agent_config}")
}

# # Conditional resource for Target Allocator
# resource "aws_eks_addon" "this" {
# count = var.eks_installation_type == "EKS_ADDON" ? 1 : 0
#
# depends_on = [
# aws_eks_cluster.this,
# aws_eks_node_group.this
# ]
# addon_name = var.addon_name
# cluster_name = aws_eks_cluster.this.name
# configuration_values = file("${var.test_dir}/${var.agent_config}")
# }

resource "null_resource" "validator" {
depends_on = [
aws_eks_cluster.this,
Expand Down Expand Up @@ -197,7 +210,7 @@ resource "null_resource" "validator" {
-agent_config="${var.test_dir}/${var.agent_config}" \
${var.otel_config != "" ? "-otel_config=\"${var.test_dir}/${var.otel_config}\"" : ""} \
${var.prometheus_config != "" ? "-prometheus_config=\"${var.test_dir}/${var.prometheus_config}\"" : ""} \
-sample_app="${var.test_dir}/${var.sample_app}" \
${var.sample_app != "" ? "-sample_app=\"${var.test_dir}/${var.sample_app}\"" : ""} \
-eks_installation_type=${var.eks_installation_type}
EOT
}
Expand Down
9 changes: 7 additions & 2 deletions test/e2e/envutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func applyHelmResources(k8ctl *utils.K8CtlManager, helmManager *utils.HelmManage
"manager.image.repository": utils.NewHelmValue(env.CloudwatchAgentOperatorRepository),
"manager.image.tag": utils.NewHelmValue(env.CloudwatchAgentOperatorTag),
"manager.image.repositoryDomainMap.public": utils.NewHelmValue(env.CloudwatchAgentOperatorRepositoryURL),
"agent.prometheus.targetAllocator.enabled": utils.NewHelmValue("true"),
"agent.mode": utils.NewHelmValue("statefulset"),
}

if env.AgentConfig != "" {
Expand All @@ -91,7 +93,7 @@ func applyHelmResources(k8ctl *utils.K8CtlManager, helmManager *utils.HelmManage

func applyAddonResources(k8ctl *utils.K8CtlManager, env *environment.MetaData) error {
if err := k8ctl.UpdateKubeConfig(env.EKSClusterName); err != nil {
return err
return fmt.Errorf("failed to update kube config: %v", err)
}

if err := updateAddonImages(k8ctl, env); err != nil {
Expand All @@ -114,13 +116,16 @@ func applyCommonResources(k8ctl *utils.K8CtlManager, env *environment.MetaData)
return err
}

fmt.Printf("Waiting for ApplyResource for SampleApp...%v\n", env.SampleApp)
if err := k8ctl.ApplyResource(env.SampleApp); err != nil {
return err
}

deploymentName := strings.TrimSuffix(filepath.Base(env.SampleApp), ".yaml")

fmt.Printf("deploymentName: %v\n", deploymentName)
fmt.Println("Waiting for Sample Application to initialize...")
return k8ctl.ConditionalWait("--for=condition=available", 300*time.Second,
return k8ctl.ConditionalWait("--for=condition=available", 4*time.Minute,
fmt.Sprintf("deployment/%s", deploymentName), "test")
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/jmx/jmx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func testMetrics(t *testing.T) {
func testAgentResources(t *testing.T, clientset *kubernetes.Clientset) {
t.Run("verify_agent_resources", func(t *testing.T) {
time.Sleep(e2e.WaitForResourceCreation)
e2e.VerifyAgentResources(t, clientset, "jmx")
e2e.VerifyAgentResourcesDaemonSet(t, clientset, "jmx")
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"logs": {
"metrics_collected": {
"prometheus": {
"log_group_name": "prometheus_test",
"emf_processor": {
"metric_namespace": "PrometheusTest",
"metric_declaration": [
{
"source_labels": [
"label1"
],
"label_matcher": "^value1$",
"dimensions": [
[
"datapoint_id"
],
[
"datapoint_id",
"foo_0"
]
],
"metric_selectors": [
"^test_*"
]
}
]
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"agent": {
"mode": "statefulset",
"targetAllocator": {
"enabled": true
},
"config": {
"logs": {
"metrics_collected": {
"prometheus": {
"log_group_name": "prometheus_test",
"emf_processor": {
"metric_namespace": "PrometheusTest",
"metric_declaration": [
{
"source_labels": [
"label1"
],
"label_matcher": "^value1$",
"dimensions": [
[
"datapoint_id"
],
[
"datapoint_id",
"foo_0"
]
],
"metric_selectors": [
"^test_*"
]
}
]
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
global:
scrape_interval: 5s
scrape_timeout: 5s
scrape_configs:
- job_name: 'cloudwatch-agent'
scrape_interval: 10s
static_configs:
- targets: [ '0.0.0.0:8888' ]
62 changes: 62 additions & 0 deletions test/e2e/prometheus/resources/sample_apps/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: v1
kind: Namespace
metadata:
name: test
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: test
data:
prometheus.yaml: |
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090'] # Changed to localhost
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus
namespace: test
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus:latest
args:
- "--config.file=/etc/prometheus/prometheus.yaml" # Add this
ports:
- containerPort: 9090
volumeMounts:
- name: config-volume
mountPath: /etc/prometheus/
volumes:
- name: config-volume
configMap:
name: prometheus-config
---
apiVersion: v1
kind: Service # Add a service for Prometheus
metadata:
name: prometheus
namespace: test
spec:
selector:
app: prometheus
ports:
- port: 9090
targetPort: 9090
type: ClusterIP
Loading
Loading