Skip to content

Commit

Permalink
App Signals: High Cardinality User Configuration Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
majanjua-amzn committed Oct 31, 2023
1 parent b5fe490 commit 5aff0ec
Show file tree
Hide file tree
Showing 17 changed files with 1,885 additions and 0 deletions.
15 changes: 15 additions & 0 deletions generator/test_case_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,21 @@ var testTypeToTestConfig = map[string][]testConfig{
{testDir: "./test/app_signals", terraformDir: "terraform/eks/daemon/app_signals",
targets: map[string]map[string]struct{}{"arc": {"amd64": {}}},
},
{
testDir: "./test/app_signals/high_cardinality_drop",
terraformDir: "terraform/eks/daemon/app_signals",
targets: map[string]map[string]struct{}{"arc": {"amd64": {}}},
},
{
testDir: "./test/app_signals/high_cardinality_keep",
terraformDir: "terraform/eks/daemon/app_signals",
targets: map[string]map[string]struct{}{"arc": {"amd64": {}}},
},
{
testDir: "./test/app_signals/high_cardinality_replace",
terraformDir: "terraform/eks/daemon/app_signals",
targets: map[string]map[string]struct{}{"arc": {"amd64": {}}},
},
},
"eks_deployment": {
{testDir: "./test/metric_value_benchmark"},
Expand Down
93 changes: 93 additions & 0 deletions test/app_signals/high_cardinality_drop/app_signals_test.go
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},

Check failure on line 64 in test/app_signals/high_cardinality_drop/app_signals_test.go

View workflow job for this annotation

GitHub Actions / compile (ubuntu-latest)

undefined: AppSignalsTracesRunner
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))
}
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 test/app_signals/high_cardinality_drop/resources/config.json
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
}
}
}
}
Loading

0 comments on commit 5aff0ec

Please sign in to comment.