Skip to content

Commit

Permalink
Merge branch 'main' of github.com:aws/amazon-cloudwatch-agent-test in…
Browse files Browse the repository at this point in the history
…to apm
  • Loading branch information
nathalapooja committed Aug 8, 2023
2 parents 6916897 + 7339e9d commit 80315f5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test/metric_value_benchmark/eks_daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (e *EKSDaemonTestRunner) validateLogs(env *environment.MetaData) status.Tes

if !awsservice.MatchEMFLogWithSchema(l, rs, validateLogContents) {
log.Println("failed to match log with schema")
log.Printf("log entry %s json schema %s", l, jsonSchema)
return false
}
}
Expand Down Expand Up @@ -208,7 +209,6 @@ func (e *EKSDaemonTestRunner) GetMeasuredMetrics() []string {
"pod_memory_utilization_over_pod_limit",
"pod_network_rx_bytes",
"pod_network_tx_bytes",
"pod_number_of_container_restarts",
"service_number_of_running_pods",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestNumberMetricDimension(t *testing.T) {

// test for cloud watch metrics
dimensionFilter := buildDimensionFilterList(parameter.numberDimensionsInCW)
awsservice.ValidateMetricWithTest(t, parameter.metricName, namespace, dimensionFilter)
awsservice.ValidateMetricWithTest(t, parameter.metricName, namespace, dimensionFilter, 5, 20*time.Second)
})
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"agent": {
"metrics_collection_interval": 60,
"metrics_collection_interval": 10,
"run_as_user": "root",
"debug": true,
"logfile": ""
},
"metrics": {
"force_flush_interval": 10,
"namespace": "MetricNumberDimensionTest",
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
Expand All @@ -15,7 +16,7 @@
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60,
"metrics_collection_interval": 10,
"append_dimensions": {
"append0": "Lorem ipsum dolor sit amet consectetur adipiscing elit Vivamus non mauris malesuada mattis ex eget porttitor purus Suspendisse potenti Praesent vel sollicitudin ipsum Quisque luctus pretium lorem non faucibus Ut vel quam dui Nunc fermentum condimentum consectetur Morbi tellus mauris tristique tincidunt elit consectetur hendrerit placerat dui In nulla erat finibus eget erat a hendrerit sodales urna In sapien purus auctor sit amet congue ut congue eget nisi Vivamus sed neque ut ligula lobortis accumsan quis id metus In feugiat velit et leo mattis non fringilla dui elementum Proin a nisi ac sapien vulputate consequat Vestibulum eu tellus mi Integer consectetur efficiturappend0",
"append1": "Lorem ipsum dolor sit amet consectetur adipiscing elit Vivamus non mauris malesuada mattis ex eget porttitor purus Suspendisse potenti Praesent vel sollicitudin ipsum Quisque luctus pretium lorem non faucibus Ut vel quam dui Nunc fermentum condimentum consectetur Morbi tellus mauris tristique tincidunt elit consectetur hendrerit placerat dui In nulla erat finibus eget erat a hendrerit sodales urna In sapien purus auctor sit amet congue ut congue eget nisi Vivamus sed neque ut ligula lobortis accumsan quis id metus In feugiat velit et leo mattis non fringilla dui elementum Proin a nisi ac sapien vulputate consequat Vestibulum eu tellus mi Integer consectetur efficiturappend1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"agent": {
"metrics_collection_interval": 60,
"metrics_collection_interval": 10,
"run_as_user": "root",
"debug": true,
"logfile": ""
},
"metrics": {
"force_flush_interval": 10,
"namespace": "MetricNumberDimensionTest",
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
Expand All @@ -15,7 +16,7 @@
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60,
"metrics_collection_interval": 10,
"append_dimensions": {
"append0": "Lorem ipsum dolor sit amet consectetur adipiscing elit Vivamus non mauris malesuada mattis ex eget porttitor purus Suspendisse potenti Praesent vel sollicitudin ipsum Quisque luctus pretium lorem non faucibus Ut vel quam dui Nunc fermentum condimentum consectetur Morbi tellus mauris tristique tincidunt elit consectetur hendrerit placerat dui In nulla erat finibus eget erat a hendrerit sodales urna In sapien purus auctor sit amet congue ut congue eget nisi Vivamus sed neque ut ligula lobortis accumsan quis id metus In feugiat velit et leo mattis non fringilla dui elementum Proin a nisi ac sapien vulputate consequat Vestibulum eu tellus mi Integer consectetur efficiturappend0",
"append1": "Lorem ipsum dolor sit amet consectetur adipiscing elit Vivamus non mauris malesuada mattis ex eget porttitor purus Suspendisse potenti Praesent vel sollicitudin ipsum Quisque luctus pretium lorem non faucibus Ut vel quam dui Nunc fermentum condimentum consectetur Morbi tellus mauris tristique tincidunt elit consectetur hendrerit placerat dui In nulla erat finibus eget erat a hendrerit sodales urna In sapien purus auctor sit amet congue ut congue eget nisi Vivamus sed neque ut ligula lobortis accumsan quis id metus In feugiat velit et leo mattis non fringilla dui elementum Proin a nisi ac sapien vulputate consequat Vestibulum eu tellus mi Integer consectetur efficiturappend1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"agent": {
"metrics_collection_interval": 60,
"metrics_collection_interval": 10,
"run_as_user": "root",
"debug": true,
"logfile": ""
},
"metrics": {
"force_flush_interval": 10,
"namespace": "MetricNumberDimensionTest",
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
Expand All @@ -15,7 +16,7 @@
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60,
"metrics_collection_interval": 10,
"append_dimensions": {
"append0": "Lorem ipsum dolor sit amet consectetur adipiscing elit Vivamus non mauris malesuada mattis ex eget porttitor purus Suspendisse potenti Praesent vel sollicitudin ipsum Quisque luctus pretium lorem non faucibus Ut vel quam dui Nunc fermentum condimentum consectetur Morbi tellus mauris tristique tincidunt elit consectetur hendrerit placerat dui In nulla erat finibus eget erat a hendrerit sodales urna In sapien purus auctor sit amet congue ut congue eget nisi Vivamus sed neque ut ligula lobortis accumsan quis id metus In feugiat velit et leo mattis non fringilla dui elementum Proin a nisi ac sapien vulputate consequat Vestibulum eu tellus mi Integer consectetur efficiturappend0",
"append1": "Lorem ipsum dolor sit amet consectetur adipiscing elit Vivamus non mauris malesuada mattis ex eget porttitor purus Suspendisse potenti Praesent vel sollicitudin ipsum Quisque luctus pretium lorem non faucibus Ut vel quam dui Nunc fermentum condimentum consectetur Morbi tellus mauris tristique tincidunt elit consectetur hendrerit placerat dui In nulla erat finibus eget erat a hendrerit sodales urna In sapien purus auctor sit amet congue ut congue eget nisi Vivamus sed neque ut ligula lobortis accumsan quis id metus In feugiat velit et leo mattis non fringilla dui elementum Proin a nisi ac sapien vulputate consequat Vestibulum eu tellus mi Integer consectetur efficiturappend1",
Expand Down
14 changes: 11 additions & 3 deletions util/awsservice/cloudwatchmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ func ValidateMetric(metricName, namespace string, dimensionsFilter []types.Dimen
}

// ValidateMetrics takes the metric name, metric dimension and corresponding namespace that contains the metric
func ValidateMetricWithTest(t *testing.T, metricName, namespace string, dimensionsFilter []types.DimensionFilter) {
err := ValidateMetric(metricName, namespace, dimensionsFilter)
func ValidateMetricWithTest(t *testing.T, metricName, namespace string, dimensionsFilter []types.DimensionFilter, retries int, retryTime time.Duration) {
var err error
for i := 0; i < retries; i++ {
err = ValidateMetric(metricName, namespace, dimensionsFilter)
if err == nil {
return
}
log.Printf("could not validate metrics try : %d of %d error %v", i+1, retries, err)
time.Sleep(retryTime)
}
if err != nil {
t.Errorf(err.Error())
t.Errorf("could not validate metrics")
}
}

Expand Down

0 comments on commit 80315f5

Please sign in to comment.