Skip to content

Commit

Permalink
Merge branch 'main' into lisguo/eventlog
Browse files Browse the repository at this point in the history
  • Loading branch information
lisguo authored Aug 1, 2024
2 parents 466422f + 30b4eb1 commit 9a92283
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 1 deletion.
9 changes: 9 additions & 0 deletions environment/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type MetaData struct {
InstancePlatform string
AgentStartCommand string
EksGpuType string
AmpWorkspaceId string
}

type MetaDataStrings struct {
Expand All @@ -67,6 +68,7 @@ type MetaDataStrings struct {
InstancePlatform string
AgentStartCommand string
EksGpuType string
AmpWorkspaceId string
}

func registerComputeType(dataString *MetaDataStrings) {
Expand Down Expand Up @@ -215,6 +217,11 @@ func fillEKSData(e *MetaData, data *MetaDataStrings) {
e.EKSClusterName = data.EKSClusterName
e.EksGpuType = data.EksGpuType
}

func registerAmpWorkspaceId(dataString *MetaDataStrings) {
flag.StringVar(&(dataString.AmpWorkspaceId), "ampWorkspaceId", "", "workspace Id for Amazon Managed Prometheus (AMP)")
}

func RegisterEnvironmentMetaDataFlags() *MetaDataStrings {
registerComputeType(registeredMetaDataStrings)
registerECSData(registeredMetaDataStrings)
Expand All @@ -230,6 +237,7 @@ func RegisterEnvironmentMetaDataFlags() *MetaDataStrings {
registerInstanceId(registeredMetaDataStrings)
registerInstancePlatform(registeredMetaDataStrings)
registerAgentStartCommand(registeredMetaDataStrings)
registerAmpWorkspaceId(registeredMetaDataStrings)

return registeredMetaDataStrings
}
Expand All @@ -255,6 +263,7 @@ func GetEnvironmentMetaData() *MetaData {
metaDataStorage.InstancePlatform = registeredMetaDataStrings.InstancePlatform
metaDataStorage.AgentStartCommand = registeredMetaDataStrings.AgentStartCommand
metaDataStorage.EksGpuType = registeredMetaDataStrings.EksGpuType
metaDataStorage.AmpWorkspaceId = registeredMetaDataStrings.AmpWorkspaceId

return metaDataStorage
}
4 changes: 4 additions & 0 deletions generator/test_case_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ var testTypeToTestConfig = map[string][]testConfig{
terraformDir: "terraform/ec2/creds",
targets: map[string]map[string]struct{}{"os": {"al2": {}}},
},
{
testDir: "./test/amp",
targets: map[string]map[string]struct{}{"os": {"al2": {}}, "arc": {"amd64": {}}},
},
},
/*
You can only place 1 mac instance on a dedicate host a single time.
Expand Down
4 changes: 4 additions & 0 deletions terraform/ec2/common/linux/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ output "proxy_instance_proxy_ip" {

output "cwa_onprem_assumed_iam_role_arm" {
value = module.common.cwa_onprem_assumed_iam_role_arm
}

output "testing_id" {
value = module.common.testing_id
}
8 changes: 7 additions & 1 deletion terraform/ec2/linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ resource "null_resource" "integration_test_setup" {
]
}

module "amp" {
count = length(regexall("/amp", var.test_dir)) > 0 ? 1 : 0
source = "terraform-aws-modules/managed-service-prometheus/aws"
workspace_alias = "cwagent-integ-test-${module.linux_common.testing_id}"
}

resource "null_resource" "integration_test_run" {
connection {
type = "ssh"
Expand All @@ -87,7 +93,7 @@ resource "null_resource" "integration_test_run" {
"cd ~/amazon-cloudwatch-agent-test",
"echo run sanity test && go test ./test/sanity -p 1 -v",
var.pre_test_setup,
"go test ${var.test_dir} -p 1 -timeout 1h -computeType=EC2 -bucket=${var.s3_bucket} -plugins='${var.plugin_tests}' -excludedTests='${var.excluded_tests}' -cwaCommitSha=${var.cwa_github_sha} -caCertPath=${var.ca_cert_path} -proxyUrl=${module.linux_common.proxy_instance_proxy_ip} -instanceId=${module.linux_common.cwagent_id} -v",
"go test ${var.test_dir} -p 1 -timeout 1h -computeType=EC2 -bucket=${var.s3_bucket} -plugins='${var.plugin_tests}' -excludedTests='${var.excluded_tests}' -cwaCommitSha=${var.cwa_github_sha} -caCertPath=${var.ca_cert_path} -proxyUrl=${module.linux_common.proxy_instance_proxy_ip} -instanceId=${module.linux_common.cwagent_id} ${length(regexall("/amp", var.test_dir)) > 0 ? "-ampWorkspaceId=${module.amp[0].workspace_id} " : ""}-v",
]
}

Expand Down
65 changes: 65 additions & 0 deletions test/amp/agent_configs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"agent": {
"metrics_collection_interval": 15,
"run_as_user": "root",
"debug": true,
"logfile": ""
},
"metrics": {
"metrics_destinations": {
"amp": {
"workspace_id": "{workspace_id}"
},
"cloudwatch": {}
},
"metrics_collected": {
"cpu": {
"resources": [
"*"
],
"measurement": [
{
"name": "cpu_usage_idle",
"rename": "CPU_USAGE_IDLE",
"unit": "unit"
},
{
"name": "cpu_usage_nice",
"unit": "unit"
},
"cpu_usage_guest",
"time_active",
"usage_active"
],
"totalcpu": false,
"metrics_collection_interval": 10,
"append_dimensions": {
"d1": "foo",
"d2": "bar"
}
},
"processes": {
"measurement": [
"blocked","running","sleeping","stopped","total","dead","idle","paging","total_threads","zombies"
],
"metrics_collection_interval": 10,
"append_dimensions": {
"d1": "foo",
"d2": "bar"
}
}
},
"append_dimensions": {
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}",
"AutoScalingGroupName": "${aws:AutoScalingGroupName}"
},
"aggregation_dimensions": [
[
"InstanceId",
"InstanceType"
]
]
}
}
Loading

0 comments on commit 9a92283

Please sign in to comment.