-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] High Cardinality: Integration testing
The implemented tests ensure that a user can change the configuration of CW agent to drop, keep, or replace certain metrics.
- Loading branch information
1 parent
341d649
commit 73f4e35
Showing
19 changed files
with
1,874 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:build !windows | ||
|
||
package apm | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"testing" | ||
|
||
"github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/aws/amazon-cloudwatch-agent-test/environment" | ||
"github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" | ||
"github.com/aws/amazon-cloudwatch-agent-test/test/status" | ||
"github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" | ||
) | ||
|
||
type APMTestSuite struct { | ||
suite.Suite | ||
test_runner.TestSuite | ||
} | ||
|
||
func (suite *APMTestSuite) SetupSuite() { | ||
fmt.Println(">>>> Starting APMTestSuite") | ||
} | ||
|
||
func (suite *APMTestSuite) TearDownSuite() { | ||
suite.Result.Print() | ||
fmt.Println(">>>> Finished APMTestSuite") | ||
} | ||
|
||
func init() { | ||
environment.RegisterEnvironmentMetaDataFlags() | ||
} | ||
|
||
var ( | ||
eksTestRunners []*test_runner.EKSTestRunner | ||
) | ||
|
||
func getEksTestRunners(env *environment.MetaData) []*test_runner.EKSTestRunner { | ||
if eksTestRunners == nil { | ||
factory := dimension.GetDimensionFactory(*env) | ||
|
||
eksTestRunners = []*test_runner.EKSTestRunner{ | ||
{ | ||
Runner: &APMRunner{test_runner.BaseTestRunner{DimensionFactory: factory}, "APM-High-Cardinality-Drop-Metrics", "HostedIn.EKS.Cluster"}, | ||
Env: *env, | ||
}, | ||
} | ||
} | ||
return eksTestRunners | ||
} | ||
|
||
func (suite *APMTestSuite) TestAllInSuite() { | ||
env := environment.GetEnvironmentMetaData() | ||
switch env.ComputeType { | ||
case computetype.EKS: | ||
log.Println("Environment compute type is EKS") | ||
for _, testRunner := range getEksTestRunners(env) { | ||
testRunner.Run(suite, env) | ||
} | ||
default: | ||
return | ||
} | ||
|
||
suite.Assert().Equal(status.SUCCESSFUL, suite.Result.GetStatus(), "APM Test Suite Failed") | ||
} | ||
|
||
func (suite *APMTestSuite) AddToSuiteResult(r status.TestGroupResult) { | ||
suite.Result.TestGroupResults = append(suite.Result.TestGroupResults, r) | ||
} | ||
|
||
func TestAPMSuite(t *testing.T) { | ||
suite.Run(t, new(APMTestSuite)) | ||
} |
69 changes: 69 additions & 0 deletions
69
test/apm/high_cardinality_drop/high_cardinality_drop_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:build !windows | ||
|
||
package apm | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/aws/amazon-cloudwatch-agent-test/test/metric" | ||
"github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" | ||
"github.com/aws/amazon-cloudwatch-agent-test/test/status" | ||
"github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" | ||
) | ||
|
||
const testRetryCount = 3 | ||
const namespace = "AWS/APM" | ||
|
||
type APMRunner struct { | ||
test_runner.BaseTestRunner | ||
testName string | ||
dimensionKey string | ||
} | ||
|
||
func (t *APMRunner) Validate() status.TestGroupResult { | ||
metricsToFetch := t.GetMeasuredMetrics() | ||
testResults := make([]status.TestResult, len(metricsToFetch)) | ||
instructions := GetInstructions() | ||
|
||
for i, metricName := range metricsToFetch { | ||
var testResult status.TestResult | ||
for j := 0; j < testRetryCount; j++ { | ||
testResult = metric.ValidateAPMMetric(t.DimensionFactory, namespace, metricName, instructions) | ||
if testResult.Status == status.SUCCESSFUL { | ||
break | ||
} | ||
time.Sleep(15 * time.Second) | ||
} | ||
testResults[i] = testResult | ||
} | ||
|
||
return status.TestGroupResult{ | ||
Name: t.GetTestName(), | ||
TestResults: testResults, | ||
} | ||
} | ||
|
||
func (t *APMRunner) GetTestName() string { | ||
return t.testName | ||
} | ||
|
||
func (t *APMRunner) GetAgentRunDuration() time.Duration { | ||
return 3 * time.Minute | ||
} | ||
|
||
func (t *APMRunner) GetMeasuredMetrics() []string { | ||
return metric.APMMetricNames | ||
} | ||
|
||
func (e *APMRunner) GetAgentConfigFileName() string { | ||
return "" | ||
} | ||
|
||
func GetInstructions() []dimension.Instruction { | ||
return metric.ServerConsumerInstructions | ||
} | ||
|
||
var _ test_runner.ITestRunner = (*APMRunner)(nil) |
Oops, something went wrong.