diff --git a/generator/test_case_generator.go b/generator/test_case_generator.go index 008d0b023..3c9a0ed91 100644 --- a/generator/test_case_generator.go +++ b/generator/test_case_generator.go @@ -131,7 +131,7 @@ var testTypeToTestConfig = map[string][]testConfig{ {testDir: "../../test/performance/system"}, {testDir: "../../test/performance/statsd"}, {testDir: "../../test/performance/collectd"}, - {testDir: "../../test/performance/trace/xray",runMockServer: true}, + {testDir: "../../test/performance/trace/xray", runMockServer: true}, }, "ec2_windows_performance": { {testDir: "../../test/performance/windows/logs"}, diff --git a/mockserver/README b/mockserver/README deleted file mode 100644 index 10cdf5346..000000000 --- a/mockserver/README +++ /dev/null @@ -1,3 +0,0 @@ -# Mocked Servers - -The servers themselves are very basic. They listen for a message and tend to set a flag to success upon receiving it. Typically, they are set up with two servers: one to mock the backend and one to report on the status of that mock (if endpoint is called, how many times, etc.). There's a built-in 15ms of latency between each message that's received. The status reporter will always be on port 8080 and support the `:8080/` (returns "healthcheck") and the `:8080/check-data` (returns "success" if mock has received messages) endpoints. \ No newline at end of file diff --git a/mockserver/README.md b/mockserver/README.md new file mode 100644 index 000000000..39d5b6c0c --- /dev/null +++ b/mockserver/README.md @@ -0,0 +1,41 @@ +# The Mock Server + +## Overview + +The Mock Server is a simple server designed for receiving metric and trace data, providing a simulated endpoint for testing purposes. It listens on two separate ports: 8080 and 443. +## Running the server +This server is runs as a docker container to run this server: +1. First build the docker container with +```sh +sudo docker build -t mockserver . +``` +2. Run the container by mapping the ports you would like to use, for example: +```sh +sudo docker run --name mockserver -d -p 8080:8080 -p 443:443 mockserver +``` + +## How it Works +### The Receiver + +The receiver component of the Mock Server operates on port 443. It is responsible for receiving messages and incrementing the transaction count. To simulate real-world conditions, there is a built-in 15ms latency between each received message. The data received can be sent to three possible routes: + +- **Check Receiver Status:** You can check if the receiver is alive by making a request to `/ping`. + +- **Send Data:** Use the `/put-data` route to send data. This route supports two sub-routes: + - `/put-data/trace/v1`: Use this sub-route for sending trace data. + - `/put-data/metrics`: Use this sub-route for sending metrics data. + +> [!Important] +> Currently, both traces and metrics are handled in the same way. + +### The Verifier + +The verifier component can be accessed via a listener on port 8080. It provides information about the transactions, including: + +- **Transactions per Minute:** You can obtain the transactions per minute by making a request to `/tpm`. + +- **Transaction Count:** To check the total transaction count, use the `/check-data` route. + +- **Verifier Status:** Determine if the verification server is alive by sending a request to `/ping`. + + diff --git a/mockserver/go.sum b/mockserver/go.sum new file mode 100644 index 000000000..2a61a10c4 --- /dev/null +++ b/mockserver/go.sum @@ -0,0 +1 @@ +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= diff --git a/mockserver/main.go b/mockserver/main.go index a087b7c21..72dcfe0a1 100644 --- a/mockserver/main.go +++ b/mockserver/main.go @@ -1,4 +1,4 @@ -// Copyright 2021 Amazon.com, Inc. or its affiliates +// Copyright 2023 Amazon.com, Inc. or its affiliates // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package main import ( "context" "encoding/json" - "fmt" "io" "log" "net/http" @@ -39,45 +38,51 @@ var ( KeyFilePath = path.Join("certificates", "private.key") ) -type transactionStore struct { +type transactionHttpServer struct { transactions uint32 startTime time.Time } type TransactionPayload struct { - TransactionsPerMinute float64 `json:"tpm"` + TransactionsPerMinute float64 `json:"GetNumberOfTransactionsPerMinute"` } -func healthCheck(w http.ResponseWriter, _ *http.Request) { +func healthCheck(w http.ResponseWriter, _ *http.Request) { if _, err := io.WriteString(w, HealthCheckMessage); err != nil { + w.WriteHeader(http.StatusInternalServerError) log.Printf("Unable to write response: %v", err) + return } + w.WriteHeader(http.StatusOK) } -func (ts *transactionStore) checkData(w http.ResponseWriter, _ *http.Request) { +func (ts *transactionHttpServer) checkTransactionCount(w http.ResponseWriter, _ *http.Request) { var message string var t = atomic.LoadUint32(&ts.transactions) if t > 0 { message = SuccessMessage } - fmt.Printf("\033[31m Time: %d | checkData msg: %s | %d\033[0m \n", time.Now().Unix(), message, t) + log.Printf("\033[31m Time: %d | checkTransactionCount msg: %s | %d\033[0m \n", time.Now().Unix(), message, t) if _, err := io.WriteString(w, message); err != nil { + w.WriteHeader(http.StatusInternalServerError) io.WriteString(w, err.Error()) log.Printf("Unable to write response: %v", err) + return } + w.WriteHeader(http.StatusOK) } -func (ts *transactionStore) dataReceived(w http.ResponseWriter, _ *http.Request) { +func (ts *transactionHttpServer) recordTransaction(w http.ResponseWriter, _ *http.Request) { atomic.AddUint32(&ts.transactions, 1) // Built-in latency - fmt.Printf("\033[31m Time: %d | data Received \033[0m \n", time.Now().Unix()) + log.Printf("\033[31m Time: %s | transaction received \033[0m \n", time.Now().String()) time.Sleep(15 * time.Millisecond) w.WriteHeader(http.StatusOK) } // Retrieve number of transactions per minute -func (ts *transactionStore) tpm(w http.ResponseWriter, _ *http.Request) { +func (ts *transactionHttpServer) GetNumberOfTransactionsPerMinute(w http.ResponseWriter, _ *http.Request) { // Calculate duration in minutes duration := time.Now().Sub(ts.startTime) transactions := float64(atomic.LoadUint32(&ts.transactions)) @@ -85,46 +90,48 @@ func (ts *transactionStore) tpm(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(TransactionPayload{tpm}); err != nil { + w.WriteHeader(http.StatusInternalServerError) io.WriteString(w, err.Error()) log.Printf("Unable to write response: %v", err) } } -// Starts an HTTPS server that receives requests for the data handler service at the sample server port // Starts an HTTP server that receives request from validator only to verify the data ingestion func StartHttpServer() { var wg sync.WaitGroup log.Println("\033[31m Starting Server \033[0m") - store := transactionStore{startTime: time.Now()} + store := transactionHttpServer{startTime: time.Now()} + //2 servers one for receiving the data , one for verify data dataApp := mux.NewRouter() - daemonServer := &http.Server{Addr: ":443", Handler: dataApp} - verifyApp := http.NewServeMux() - appServer := &http.Server{Addr: ":8080", Handler: verifyApp} - go func(ts *transactionStore) { - wg.Add(1) + dataReceiverServer := &http.Server{Addr: ":443", Handler: dataApp} + verificationRequestServer := http.NewServeMux() + appServer := &http.Server{Addr: ":8080", Handler: verificationRequestServer} + wg.Add(2) + go func(ts *transactionHttpServer) { + defer wg.Done() dataApp.HandleFunc("/ping", healthCheck) - dataApp.PathPrefix("/put-data").HandlerFunc(ts.dataReceived) - dataApp.HandleFunc("/trace/v1", ts.dataReceived) - dataApp.HandleFunc("/metric/v1", ts.dataReceived) - if err := daemonServer.ListenAndServeTLS(CertFilePath, KeyFilePath); err != nil { + dataApp.PathPrefix("/put-data").HandlerFunc(ts.recordTransaction) + dataApp.HandleFunc("/trace/v1", ts.recordTransaction) + dataApp.HandleFunc("/metric/v1", ts.recordTransaction) + if err := dataReceiverServer.ListenAndServeTLS(CertFilePath, KeyFilePath); err != nil { log.Printf("HTTPS server error: %v", err) - err = daemonServer.Shutdown(context.TODO()) + err = dataReceiverServer.Shutdown(context.TODO()) log.Fatalf("Shutdown server error: %v", err) } }(&store) - go func(ts *transactionStore) { - wg.Add(1) - verifyApp.HandleFunc("/ping", healthCheck) - verifyApp.HandleFunc("/check-data", ts.checkData) - verifyApp.HandleFunc("/tpm", ts.tpm) + go func(ts *transactionHttpServer) { + defer wg.Done() + verificationRequestServer.HandleFunc("/ping", healthCheck) + verificationRequestServer.HandleFunc("/check-data", ts.checkTransactionCount) + verificationRequestServer.HandleFunc("/tpm", ts.GetNumberOfTransactionsPerMinute) if err := appServer.ListenAndServe(); err != nil { log.Printf("Verification server error: %v", err) err := appServer.Shutdown(context.TODO()) - log.Fatalf("Shuwdown server error: %v", err) + log.Fatalf("Shutdown server error: %v", err) } }(&store) - wg.Done() + wg.Wait() log.Println("\033[32m Stopping Server \033[0m") } diff --git a/terraform/performance/main.tf b/terraform/performance/main.tf index 264c183e8..e83c3813d 100644 --- a/terraform/performance/main.tf +++ b/terraform/performance/main.tf @@ -110,12 +110,10 @@ resource "null_resource" "validator_linux" { provisioner "remote-exec" { inline = [ #mock server dependencies getting transfered. - # todo make this optional with a env var. - "git clone https://github.com/aws/amazon-cloudwatch-agent-test.git", - "cd amazon-cloudwatch-agent-test && git checkout xray-performance-test", + "git clone --branch ${var.github_test_repo_branch} ${var.github_test_repo}", var.run_mock_server ? "cd mockserver && sudo docker build -t mockserver . && cd .." : "echo skipping mock server build", - var.run_mock_server ? "sudo docker run --name mockserver -d -p 8080:8080 -p 443:443 mockserver" : "echo skipping mock server", - "cd ..", + var.run_mock_server ? "sudo docker run --name mockserver -d -p 8080:8080 -p 443:443 mockserver" : "echo skipping mock server run", + "cd ..", # return to root , two copy xray configs next to validator "cp -r amazon-cloudwatch-agent-test/test/xray/resources /home/ec2-user/", "export AWS_REGION=${var.region}", "sudo chmod +x ./${local.install_validator}", diff --git a/terraform/performance/variables.tf b/terraform/performance/variables.tf index 06e93c120..f571f0911 100644 --- a/terraform/performance/variables.tf +++ b/terraform/performance/variables.tf @@ -66,6 +66,15 @@ variable "family" { error_message = "Valid values for family are (windows, linux)." } } +variable "github_test_repo" { + type = string + default = "https://github.com/aws/amazon-cloudwatch-agent-test.git" +} + +variable "github_test_repo_branch" { + type = string + default = "main" +} variable "run_mock_server" { type = bool default = false diff --git a/test/otlp/trace_test.go b/test/otlp/trace_test.go index 158bd11ce..fd68dd95e 100644 --- a/test/otlp/trace_test.go +++ b/test/otlp/trace_test.go @@ -6,7 +6,8 @@ import ( "time" "github.com/aws/amazon-cloudwatch-agent-test/environment" - "github.com/aws/amazon-cloudwatch-agent-test/util/common" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/otlp" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" ) @@ -25,11 +26,11 @@ func TestTraces(t *testing.T) { env := environment.GetEnvironmentMetaData() testCases := map[string]struct { agentConfigPath string - generatorConfig *common.TraceGeneratorConfig + generatorConfig *base.TraceGeneratorConfig }{ "WithOTLP/Simple": { agentConfigPath: filepath.Join("resources", "otlp-config.json"), - generatorConfig: &common.TraceGeneratorConfig{ + generatorConfig: &base.TraceGeneratorConfig{ Interval: loadGeneratorInterval, Annotations: map[string]interface{}{ "test_type": "simple_otlp", @@ -55,13 +56,13 @@ func TestTraces(t *testing.T) { t.Run(name, func(t *testing.T) { - OtlpTestCfg := common.TraceTestConfig{ - Generator: NewLoadGenerator(testCase.generatorConfig), + OtlpTestCfg := base.TraceTestConfig{ + Generator: otlp.NewLoadGenerator(testCase.generatorConfig), Name: name, AgentConfigPath: testCase.agentConfigPath, AgentRuntime: agentRuntime, } - err := common.TraceTest(t, OtlpTestCfg) + err := base.TraceTest(t, OtlpTestCfg) require.NoError(t, err, "TraceTest failed because %s", err) }) diff --git a/test/xray/trace_test.go b/test/xray/trace_test.go index b9ec305c8..430a147b4 100644 --- a/test/xray/trace_test.go +++ b/test/xray/trace_test.go @@ -6,7 +6,8 @@ import ( "time" "github.com/aws/amazon-cloudwatch-agent-test/environment" - "github.com/aws/amazon-cloudwatch-agent-test/util/common" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/xray" "github.com/stretchr/testify/require" ) @@ -26,11 +27,11 @@ func TestTraces(t *testing.T) { env := environment.GetEnvironmentMetaData() testCases := map[string]struct { agentConfigPath string - generatorConfig *common.TraceGeneratorConfig + generatorConfig *base.TraceGeneratorConfig }{ "WithXray/Simple": { agentConfigPath: filepath.Join("resources", "xray-config.json"), - generatorConfig: &common.TraceGeneratorConfig{ + generatorConfig: &base.TraceGeneratorConfig{ Interval: loadGeneratorInterval, Annotations: map[string]interface{}{ "test_type": "simple_xray", @@ -53,13 +54,13 @@ func TestTraces(t *testing.T) { for name, testCase := range testCases { t.Run(name, func(t *testing.T) { - XrayTestCfg := common.TraceTestConfig{ - Generator: NewLoadGenerator(testCase.generatorConfig), + XrayTestCfg := base.TraceTestConfig{ + Generator: xray.NewLoadGenerator(testCase.generatorConfig), Name: name, AgentConfigPath: testCase.agentConfigPath, AgentRuntime: agentRuntime, } - err := common.TraceTest(t, XrayTestCfg) + err := base.TraceTest(t, XrayTestCfg) require.NoError(t, err, "TraceTest failed because %s", err) }) diff --git a/util/common/traces.go b/util/common/traces/base/base.go similarity index 92% rename from util/common/traces.go rename to util/common/traces/base/base.go index 4cc3e48ea..72c43baa0 100644 --- a/util/common/traces.go +++ b/util/common/traces/base/base.go @@ -1,17 +1,17 @@ -package common +package base import ( "context" "encoding/json" - "reflect" - "testing" - "time" - "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" + "github.com/aws/amazon-cloudwatch-agent-test/util/common" "github.com/aws/aws-sdk-go-v2/service/xray/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" + "reflect" + "testing" + "time" ) const ( @@ -54,15 +54,15 @@ type TraceGeneratorInterface interface { func TraceTest(t *testing.T, traceTest TraceTestConfig) error { t.Helper() startTime := time.Now() - CopyFile(traceTest.AgentConfigPath, ConfigOutputPath) - require.NoError(t, StartAgent(ConfigOutputPath, true, false), "Couldn't Start the agent") + common.CopyFile(traceTest.AgentConfigPath, common.ConfigOutputPath) + require.NoError(t, common.StartAgent(common.ConfigOutputPath, true, false), "Couldn't Start the agent") go func() { require.NoError(t, traceTest.Generator.StartSendingTraces(context.Background()), "load generator exited with error") }() time.Sleep(traceTest.AgentRuntime) traceTest.Generator.StopSendingTraces() time.Sleep(AGENT_SHUTDOWN_DELAY) - StopAgent() + common.StopAgent() testsGenerated, testsEnded := traceTest.Generator.GetSegmentCount() t.Logf("For %s , Test Cases Generated %d | Test Cases Ended: %d", traceTest.Name, testsGenerated, testsEnded) endTime := time.Now() @@ -113,7 +113,7 @@ func SegmentValidationTest(t *testing.T, traceTest TraceTestConfig, segments []t } func GenerateTraces(traceTest TraceTestConfig) error { - CopyFile(traceTest.AgentConfigPath, ConfigOutputPath) + common.CopyFile(traceTest.AgentConfigPath, common.ConfigOutputPath) go func() { traceTest.Generator.StartSendingTraces(context.Background()) }() diff --git a/util/common/traces/generate.go b/util/common/traces/generate.go new file mode 100644 index 000000000..55a2857d0 --- /dev/null +++ b/util/common/traces/generate.go @@ -0,0 +1,43 @@ +package traces + +import ( + "fmt" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/xray" + "time" +) + +func StartTraceGeneration(receiver string, agentConfigPath string, agentRuntime time.Duration, traceSendingInterval time.Duration) error { + cfg := base.TraceTestConfig{ + Generator: nil, + Name: "", + AgentConfigPath: agentConfigPath, + AgentRuntime: agentRuntime, + } + xrayGenCfg := base.TraceGeneratorConfig{ + Interval: traceSendingInterval, + Annotations: map[string]interface{}{ + "test_type": "simple_otlp", + }, + Metadata: map[string]map[string]interface{}{ + "default": { + "nested": map[string]interface{}{ + "key": "value", + }, + }, + "custom_namespace": { + "custom_key": "custom_value", + }, + }, + } + switch receiver { + case "xray": + cfg.Generator = xray.NewLoadGenerator(&xrayGenCfg) + cfg.Name = "xray-performance-test" + case "otlp": + default: + return fmt.Errorf("%s is not supported.", receiver) + } + err := base.GenerateTraces(cfg) + return err +} diff --git a/test/otlp/generator.go b/util/common/traces/otlp/generator.go similarity index 90% rename from test/otlp/generator.go rename to util/common/traces/otlp/generator.go index 7064d0fd5..017fb3f4c 100644 --- a/test/otlp/generator.go +++ b/util/common/traces/otlp/generator.go @@ -5,7 +5,7 @@ import ( "errors" "time" - "github.com/aws/amazon-cloudwatch-agent-test/util/common" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" "go.opentelemetry.io/contrib/propagators/aws/xray" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" @@ -25,8 +25,8 @@ const ( ) type OtlpTracesGenerator struct { - common.TraceGenerator - common.TraceGeneratorInterface + base.TraceGenerator + base.TraceGeneratorInterface } func (g *OtlpTracesGenerator) StartSendingTraces(ctx context.Context) error { @@ -51,9 +51,9 @@ func (g *OtlpTracesGenerator) StartSendingTraces(ctx context.Context) error { func (g *OtlpTracesGenerator) StopSendingTraces() { close(g.Done) } -func NewLoadGenerator(cfg *common.TraceGeneratorConfig) *OtlpTracesGenerator { +func NewLoadGenerator(cfg *base.TraceGeneratorConfig) *OtlpTracesGenerator { return &OtlpTracesGenerator{ - TraceGenerator: common.TraceGenerator{ + TraceGenerator: base.TraceGenerator{ Cfg: cfg, Done: make(chan struct{}), SegmentsGenerationCount: 0, @@ -90,7 +90,7 @@ func (g *OtlpTracesGenerator) GetAgentRuntime() time.Duration { func (g *OtlpTracesGenerator) GetName() string { return g.Name } -func (g *OtlpTracesGenerator) GetGeneratorConfig() *common.TraceGeneratorConfig { +func (g *OtlpTracesGenerator) GetGeneratorConfig() *base.TraceGeneratorConfig { return g.Cfg } diff --git a/test/xray/generator.go b/util/common/traces/xray/generator.go similarity index 85% rename from test/xray/generator.go rename to util/common/traces/xray/generator.go index 49262e92e..344202877 100644 --- a/test/xray/generator.go +++ b/util/common/traces/xray/generator.go @@ -3,21 +3,21 @@ package xray import ( "context" "errors" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" + "github.com/aws/aws-xray-sdk-go/strategy/sampling" + "github.com/aws/aws-xray-sdk-go/xray" + "github.com/aws/aws-xray-sdk-go/xraylog" "log" "os" "path" "time" - "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "github.com/aws/aws-xray-sdk-go/strategy/sampling" - "github.com/aws/aws-xray-sdk-go/xray" - "github.com/aws/aws-xray-sdk-go/xraylog" ) var generatorError = errors.New("Generator error") type XrayTracesGenerator struct { - common.TraceGenerator - common.TraceGeneratorInterface + base.TraceGenerator + base.TraceGeneratorInterface } func (g *XrayTracesGenerator) StartSendingTraces(ctx context.Context) error { @@ -37,7 +37,7 @@ func (g *XrayTracesGenerator) StartSendingTraces(ctx context.Context) error { func (g *XrayTracesGenerator) StopSendingTraces() { close(g.Done) } -func NewLoadGenerator(cfg *common.TraceGeneratorConfig) *XrayTracesGenerator { +func NewLoadGenerator(cfg *base.TraceGeneratorConfig) *XrayTracesGenerator { s, err := sampling.NewLocalizedStrategyFromFilePath( path.Join("resources", "sampling-rule.json")) if err != nil { @@ -46,7 +46,7 @@ func NewLoadGenerator(cfg *common.TraceGeneratorConfig) *XrayTracesGenerator { xray.Configure(xray.Config{SamplingStrategy: s}) xray.SetLogger(xraylog.NewDefaultLogger(os.Stdout, xraylog.LogLevelWarn)) return &XrayTracesGenerator{ - TraceGenerator: common.TraceGenerator{ + TraceGenerator: base.TraceGenerator{ Cfg: cfg, Done: make(chan struct{}), SegmentsGenerationCount: 0, @@ -56,7 +56,6 @@ func NewLoadGenerator(cfg *common.TraceGeneratorConfig) *XrayTracesGenerator { } func (g *XrayTracesGenerator) Generate(ctx context.Context) error { rootCtx, root := xray.BeginSegment(ctx, "load-generator") - log.Println("\033[34mGenerated Trace\033[0m") g.SegmentsGenerationCount++ defer func() { root.Close(nil) @@ -100,6 +99,6 @@ func (g *XrayTracesGenerator) GetAgentRuntime() time.Duration { func (g *XrayTracesGenerator) GetName() string { return g.Name } -func (g *XrayTracesGenerator) GetGeneratorConfig() *common.TraceGeneratorConfig { +func (g *XrayTracesGenerator) GetGeneratorConfig() *base.TraceGeneratorConfig { return g.Cfg } diff --git a/validator/models/validation_config.go b/validator/models/validation_config.go index d4446eded..6d29ee2c7 100644 --- a/validator/models/validation_config.go +++ b/validator/models/validation_config.go @@ -15,7 +15,7 @@ import ( "gopkg.in/yaml.v3" ) -var supportedReceivers = []string{"logs", "statsd", "collectd", "system", "emf","xray"} +var supportedReceivers = []string{"logs", "statsd", "collectd", "system", "emf", "xray"} type ValidateConfig interface { GetPluginsConfig() []string diff --git a/validator/validators/basic/basic_validator.go b/validator/validators/basic/basic_validator.go index 60ed6faed..885b5a61c 100644 --- a/validator/validators/basic/basic_validator.go +++ b/validator/validators/basic/basic_validator.go @@ -16,6 +16,7 @@ import ( "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" "github.com/aws/amazon-cloudwatch-agent-test/util/common" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces" "github.com/aws/amazon-cloudwatch-agent-test/validator/models" "github.com/aws/amazon-cloudwatch-agent-test/validator/validators/util" ) @@ -50,7 +51,7 @@ func (s *BasicValidator) GenerateLoad() error { case "logs": return common.StartLogWrite(agentConfigFilePath, agentCollectionPeriod, metricSendingInterval, dataRate) case "traces": - return util.StartTraceGeneration(receiver,agentConfigFilePath,agentCollectionPeriod,metricSendingInterval) + return traces.StartTraceGeneration(receiver, agentConfigFilePath, agentCollectionPeriod, metricSendingInterval) default: // Sending metrics based on the receivers; however, for scraping plugin (e.g prometheus), we would need to scrape it instead of sending return common.StartSendingMetrics(receiver, agentCollectionPeriod, metricSendingInterval, dataRate, logGroup, metricNamespace) diff --git a/validator/validators/util/common.go b/validator/validators/util/common.go index d78498382..048abe9fe 100644 --- a/validator/validators/util/common.go +++ b/validator/validators/util/common.go @@ -5,9 +5,6 @@ package util import ( "fmt" - "time" - "github.com/aws/amazon-cloudwatch-agent-test/test/xray" - "github.com/aws/amazon-cloudwatch-agent-test/util/common" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" ) @@ -21,38 +18,3 @@ func LogCloudWatchDimension(dims []types.Dimension) string { return dimension } -func StartTraceGeneration(receiver string, agentConfigPath string, agentRuntime time.Duration, traceSendingInterval time.Duration) error { - cfg := common.TraceTestConfig{ - Generator: nil, - Name: "", - AgentConfigPath: agentConfigPath, - AgentRuntime: agentRuntime, - } - xrayGenCfg := common.TraceGeneratorConfig{ - Interval: traceSendingInterval, - Annotations: map[string]interface{}{ - "test_type": "simple_otlp", - }, - Metadata: map[string]map[string]interface{}{ - "default": { - "nested": map[string]interface{}{ - "key": "value", - }, - }, - "custom_namespace": { - "custom_key": "custom_value", - }, - }, - } - switch receiver { - case "xray": - cfg.Generator = xray.NewLoadGenerator(&xrayGenCfg) - cfg.Name = "xray-performance-test" - case "otlp": - panic("Only supports xray for now.") - default: - panic("Invalid trace receiver") - } - err := common.GenerateTraces(cfg) - return err -}