forked from aws/amazon-cloudwatch-agent-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
App Signals: High Cardinality User Configuration Testing
- Loading branch information
1 parent
b5fe490
commit 5aff0ec
Showing
17 changed files
with
1,885 additions
and
0 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
93 changes: 93 additions & 0 deletions
93
test/app_signals/high_cardinality_drop/app_signals_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,93 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:build !windows | ||
|
||
package app_signals | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/aws/amazon-cloudwatch-agent-test/environment" | ||
"github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" | ||
"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 ( | ||
AppSignalsServerConsumerTestName = "AppSignals-Server-Consumer" | ||
AppSignalsClientProducerTestName = "AppSignals-Client-Producer" | ||
AppSignalsTracesTestName = "AppSignals-Traces" | ||
) | ||
|
||
type AppSignalsTestSuite struct { | ||
suite.Suite | ||
test_runner.TestSuite | ||
} | ||
|
||
func (suite *AppSignalsTestSuite) SetupSuite() { | ||
fmt.Println(">>>> Starting AppSignalsTestSuite") | ||
} | ||
|
||
func (suite *AppSignalsTestSuite) TearDownSuite() { | ||
suite.Result.Print() | ||
fmt.Println(">>>> Finished AppSignalsTestSuite") | ||
} | ||
|
||
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: &AppSignalsMetricsRunner{test_runner.BaseTestRunner{DimensionFactory: factory}, AppSignalsServerConsumerTestName, "HostedIn.EKS.Cluster"}, | ||
Env: *env, | ||
}, | ||
{ | ||
Runner: &AppSignalsMetricsRunner{test_runner.BaseTestRunner{DimensionFactory: factory}, AppSignalsClientProducerTestName, "HostedIn.EKS.Cluster"}, | ||
Env: *env, | ||
}, | ||
{ | ||
Runner: &AppSignalsTracesRunner{test_runner.BaseTestRunner{DimensionFactory: factory}, AppSignalsTracesTestName, env.EKSClusterName}, | ||
Env: *env, | ||
}, | ||
} | ||
} | ||
return eksTestRunners | ||
} | ||
|
||
func (suite *AppSignalsTestSuite) 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(), "AppSignals Test Suite Failed") | ||
} | ||
|
||
func (suite *AppSignalsTestSuite) AddToSuiteResult(r status.TestGroupResult) { | ||
suite.Result.TestGroupResults = append(suite.Result.TestGroupResults, r) | ||
} | ||
|
||
func TestAppSignalsSuite(t *testing.T) { | ||
suite.Run(t, new(AppSignalsTestSuite)) | ||
} |
69 changes: 69 additions & 0 deletions
69
test/app_signals/high_cardinality_drop/high_cardinality_drop_metrics_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 app_signals | ||
|
||
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 = 6 | ||
const namespace = "AppSignals" | ||
|
||
type AppSignalsMetricsRunner struct { | ||
test_runner.BaseTestRunner | ||
testName string | ||
dimensionKey string | ||
} | ||
|
||
func (t *AppSignalsMetricsRunner) Validate() status.TestGroupResult { | ||
metricsToFetch := t.GetMeasuredMetrics() | ||
testResults := make([]status.TestResult, len(metricsToFetch)) | ||
instructions := GetInstructionsFromTestName(t.testName) | ||
|
||
for i, metricName := range metricsToFetch { | ||
var testResult status.TestResult | ||
for j := 0; j < testRetryCount; j++ { | ||
testResult = metric.ValidateAppSignalsMetric(t.DimensionFactory, namespace, metricName, instructions) | ||
if testResult.Status == status.SUCCESSFUL { | ||
break | ||
} | ||
time.Sleep(30 * time.Second) | ||
} | ||
testResults[i] = testResult | ||
} | ||
|
||
return status.TestGroupResult{ | ||
Name: t.GetTestName(), | ||
TestResults: testResults, | ||
} | ||
} | ||
|
||
func (t *AppSignalsMetricsRunner) GetTestName() string { | ||
return t.testName | ||
} | ||
|
||
func (t *AppSignalsMetricsRunner) GetAgentRunDuration() time.Duration { | ||
return 3 * time.Minute | ||
} | ||
|
||
func (t *AppSignalsMetricsRunner) GetMeasuredMetrics() []string { | ||
return metric.AppSignalsMetricNames | ||
} | ||
|
||
func (e *AppSignalsMetricsRunner) GetAgentConfigFileName() string { | ||
return "" | ||
} | ||
|
||
func GetInstructionsFromTestName(testName string) []dimension.Instruction { | ||
return metric.ServerConsumerInstructions | ||
} | ||
|
||
var _ test_runner.ITestRunner = (*AppSignalsMetricsRunner)(nil) |
31 changes: 31 additions & 0 deletions
31
test/app_signals/high_cardinality_drop/resources/config.json
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,31 @@ | ||
{ | ||
"agent": { | ||
"debug": true | ||
}, | ||
"logs": { | ||
"metrics_collected": { | ||
"app_signals": { | ||
"enabled": true, | ||
"rules": [ | ||
{ | ||
"selectors": [ | ||
{ | ||
"dimensions": "RemoteTarget", | ||
"match": "remote-target" | ||
} | ||
], | ||
"action": "drop", | ||
"rule_name": "drop" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"traces": { | ||
"traces_collected": { | ||
"app_signals": { | ||
"enabled": true | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.