You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The open telemetry project has a receivertest module that can be used to test a receiver's contract. I'm particularly interested in the CheckConsumerContract function that is used to test the contract between the receiver and the next consumer in the pipeline.
This test has a couple of interesting scenarios such as:
Always succeed. We expect all data to be delivered as is.
Random non-permanent error
Random permanent error
Random error
This test is based on a Generator that is responsible to produce the data used during the test. For this to work properly the beats receiver must implement the ReceiveLogs(data plog.Logs) function to receive the logs from this external source. In the case of beats receivers, the beats themselves produce their own data, so we need to come up with a way to adapt this generator concept or implement said function. I believe the messages should be unique, so perhaps the benchmark input being able to output unique strings or an integer counter should be enough.
This seems quite handy to setup once and use the same machinery to test every beats receiver.
// TestConsumeContract is an example of testing of the receiver for the contract between the// receiver and next consumer.funcTestConsumeContract(t*testing.T) {
// Number of log records to send per scenario.constlogsPerTest=100generator:=&exampleLogGenerator{t: t}
cfg:=&exampleReceiverConfig{generator: generator}
params:=CheckConsumeContractParams{
T: t,
Factory: newExampleFactory(),
Signal: pipeline.SignalLogs,
Config: cfg,
Generator: generator,
GenerateCount: logsPerTest,
}
// Run the contract checker. This will trigger test failures if any problems are found.CheckConsumeContract(params)
}
During my initial experimentation with this I found a bug with global state in libbeat that is now resolved by #41475.
The text was updated successfully, but these errors were encountered:
The open telemetry project has a
receivertest
module that can be used to test a receiver's contract. I'm particularly interested in theCheckConsumerContract
function that is used to test the contract between the receiver and the next consumer in the pipeline.This test has a couple of interesting scenarios such as:
This test is based on a Generator that is responsible to produce the data used during the test. For this to work properly the beats receiver must implement the
ReceiveLogs(data plog.Logs)
function to receive the logs from this external source. In the case of beats receivers, the beats themselves produce their own data, so we need to come up with a way to adapt this generator concept or implement said function. I believe the messages should be unique, so perhaps thebenchmark
input being able to output unique strings or an integer counter should be enough.This seems quite handy to setup once and use the same machinery to test every beats receiver.
Here is an example test:
During my initial experimentation with this I found a bug with global state in libbeat that is now resolved by #41475.
The text was updated successfully, but these errors were encountered: