-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testbed: refactor TestCase with broken out LoadGenerator interface #30303
testbed: refactor TestCase with broken out LoadGenerator interface #30303
Conversation
c3f6d62
to
14ada2b
Compare
@@ -34,10 +34,9 @@ type TestCase struct { | |||
// Agent process. | |||
agentProc OtelcolRunner | |||
|
|||
Sender DataSender |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the main breaking change, with Sender
now only being available on the ProviderSender
instance, which is still available on the LoadGenerator
field. In the cases where this was used, the tests already have* access to the sender directly so the indirect access is unnecessary to begin with. I decided to not address potential simplifications* in this initial pass to keep the changes localized to the involved types.
14ada2b
to
a416745
Compare
a416745
to
d581d99
Compare
…pen-telemetry#30303) **Description:** Adding a feature - These changes break out the current `testbed.LoadGenerator` to an interface of the same name, migrating its (reference) implementation to a new `testbed.ProviderSender` type. This will allow future test cases (in arbitrary distributions) to use the existing* `TestCase` flow, but with arbitrary load generator implementations beyond the capabilities of the current one. They also provide a new `testbed.NewLoadGeneratorTestCase` similar to the existing `testbed.NewTestCase` that is now called indirectly. I chose this route to not force further signature changes. In the process of this work, I found a few edge cases that can lead to* races and hanging processes in error scenarios. They've been addressed w/ some minimal synchronization. Here's a partial* example of a LoadGenerator that can manage an arbitrary number of `ProviderSender` instances, each of varying telemetry types, that can now be used: ```go type CompositeLoadGenerator struct { startTime time.Time loadGenerators []testbed.LoadGenerator } func NewCompositeLoadGenerator(loadGenerators ...testbed.LoadGenerator) testbed.LoadGenerator { return &CompositeLoadGenerator{ loadGenerators: loadGenerators, } } func (o *CompositeLoadGenerator) Start(options testbed.LoadOptions) { o.startTime = time.Now() for _, lg := range o.loadGenerators { lg.Start(options) } } func (o *CompositeLoadGenerator) Stop() { for _, lg := range o.loadGenerators { lg.Stop() } } func (o *CompositeLoadGenerator) DataItemsSent() uint64 { var dataItemsSent uint64 for _, lg := range o.loadGenerators { dataItemsSent += lg.DataItemsSent() } return dataItemsSent } <...> ``` **Documentation:** Updated readme.
Description:
Adding a feature - These changes break out the current
testbed.LoadGenerator
to an interface of the same name, migrating its (reference) implementation to a newtestbed.ProviderSender
type. This will allow future test cases (in arbitrary distributions) to use the existing*TestCase
flow, but with arbitrary load generator implementations beyond the capabilities of the current one. They also provide a newtestbed.NewLoadGeneratorTestCase
similar to the existingtestbed.NewTestCase
that is now called indirectly. I chose this route to not force further signature changes.In the process of this work, I found a few edge cases that can lead to* races and hanging processes in error scenarios. They've been addressed w/ some minimal synchronization.
Here's a partial* example of a LoadGenerator that can manage an arbitrary number of
ProviderSender
instances, each of varying telemetry types, that can now be used:Documentation:
Updated readme.