-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add connector usage to the testbed (#32881)
**Description:** Added a new component to the testbed called DataConnectors which allows connectors to be added to the testbed config. Also, added a sample connector correctness test using the routingconnector as an example of the usage. **Link to tracking Issue:** #30165 **Testing:** Sample correctness test using routingconnector. **Documentation:** Will update the testbed README with new addition. --------- Co-authored-by: Bryan Aguilar <bryaag@amazon.com>
- Loading branch information
1 parent
6015403
commit fba8658
Showing
14 changed files
with
375 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: testbed | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add the use of connectors to the testbed | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [30165] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [api] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,97 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package connectors | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/testbed/correctnesstests" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed" | ||
) | ||
|
||
var correctnessResults testbed.TestResultsSummary = &testbed.CorrectnessResults{} | ||
|
||
func TestMain(m *testing.M) { | ||
testbed.DoTestMain(m, correctnessResults) | ||
} | ||
|
||
func TestGoldenData(t *testing.T) { | ||
processors := map[string]string{ | ||
"batch": ` | ||
batch: | ||
send_batch_size: 1024 | ||
`, | ||
} | ||
sampleTest := correctnesstests.PipelineDef{ | ||
TestName: "test routing", | ||
Receiver: "otlp", | ||
Exporter: "otlp", | ||
Connector: "routing", | ||
} | ||
|
||
sampleTest.DataSender = correctnesstests.ConstructTraceSender(t, sampleTest.Receiver) | ||
sampleTest.DataReceiver = correctnesstests.ConstructReceiver(t, sampleTest.Exporter) | ||
sampleTest.DataConnector = correctnesstests.ConstructConnector(t, sampleTest.Connector, "traces") | ||
t.Run(sampleTest.TestName, func(t *testing.T) { | ||
testWithGoldenDataset(t, sampleTest.DataSender, sampleTest.DataReceiver, sampleTest.ResourceSpec, sampleTest.DataConnector, processors) | ||
}) | ||
|
||
} | ||
|
||
func testWithGoldenDataset( | ||
t *testing.T, | ||
sender testbed.DataSender, | ||
receiver testbed.DataReceiver, | ||
resourceSpec testbed.ResourceSpec, | ||
connector testbed.DataConnector, | ||
processors map[string]string, | ||
) { | ||
dataProvider := testbed.NewGoldenDataProvider( | ||
"../../../internal/coreinternal/goldendataset/testdata/generated_pict_pairs_traces.txt", | ||
"../../../internal/coreinternal/goldendataset/testdata/generated_pict_pairs_spans.txt", | ||
"") | ||
factories, err := testbed.Components() | ||
require.NoError(t, err, "default components resulted in: %v", err) | ||
runner := testbed.NewInProcessCollector(factories) | ||
validator := testbed.NewCorrectTestValidator(sender.ProtocolName(), receiver.ProtocolName(), dataProvider) | ||
config := correctnesstests.CreateConfigYaml(t, sender, receiver, connector, processors) | ||
log.Println(config) | ||
configCleanup, cfgErr := runner.PrepareConfig(config) | ||
require.NoError(t, cfgErr, "collector configuration resulted in: %v", cfgErr) | ||
defer configCleanup() | ||
tc := testbed.NewTestCase( | ||
t, | ||
dataProvider, | ||
sender, | ||
receiver, | ||
runner, | ||
validator, | ||
correctnessResults, | ||
testbed.WithResourceLimits(resourceSpec), | ||
) | ||
defer tc.Stop() | ||
|
||
tc.EnableRecording() | ||
tc.StartBackend() | ||
tc.StartAgent() | ||
|
||
tc.StartLoad(testbed.LoadOptions{ | ||
DataItemsPerSecond: 1024, | ||
ItemsPerBatch: 1, | ||
}) | ||
|
||
tc.Sleep(2 * time.Second) | ||
|
||
tc.StopLoad() | ||
|
||
tc.WaitForN(func() bool { return tc.LoadGenerator.DataItemsSent() == tc.MockBackend.DataItemsReceived() }, | ||
3*time.Second, "all data items received") | ||
|
||
tc.StopAgent() | ||
|
||
} |
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
Oops, something went wrong.