Skip to content
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

[cmd/mdatagen] optimize mdatagen for batchprocessor failed test #9768

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/optimize-mdatagen-for-batchprocessor.yaml
@@ -0,0 +1,25 @@
# 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. otlpreceiver)
component: cmd/mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: optimiz the mdatagen for the case like batchprocessor which use a common struct to implement consumer.Traces, consumer.Metrics, consumer.Logs in the meantime.

# One or more tracking issues or pull requests related to the change
issues: [9688]

# (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:

# 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: []
28 changes: 20 additions & 8 deletions cmd/mdatagen/templates/component_test.go.tmpl
Expand Up @@ -108,20 +108,26 @@ func TestComponentLifecycle(t *testing.T) {
err = c.Start(context.Background(), host)
require.NoError(t, err)
require.NotPanics(t, func() {
switch e := c.(type) {
case exporter.Logs:
switch test.name {
case "logs":
e, ok := c.(exporter.Logs)
require.True(t, ok)
logs := generateLifecycleTestLogs()
if !e.Capabilities().MutatesData {
logs.MarkReadOnly()
}
err = e.ConsumeLogs(context.Background(), logs)
case exporter.Metrics:
case "metrics":
e, ok := c.(exporter.Metrics)
require.True(t, ok)
metrics := generateLifecycleTestMetrics()
if !e.Capabilities().MutatesData {
metrics.MarkReadOnly()
}
err = e.ConsumeMetrics(context.Background(), metrics)
case exporter.Traces:
case "traces":
e, ok := c.(exporter.Traces)
require.True(t, ok)
traces := generateLifecycleTestTraces()
if !e.Capabilities().MutatesData {
traces.MarkReadOnly()
Expand Down Expand Up @@ -199,20 +205,26 @@ func TestComponentLifecycle(t *testing.T) {
err = c.Start(context.Background(), host)
require.NoError(t, err)
require.NotPanics(t, func() {
switch e := c.(type) {
case processor.Logs:
switch test.name {
case "logs":
e, ok := c.(processor.Logs)
require.True(t, ok)
logs := generateLifecycleTestLogs()
if !e.Capabilities().MutatesData {
logs.MarkReadOnly()
}
err = e.ConsumeLogs(context.Background(), logs)
case processor.Metrics:
case "metrics":
e, ok := c.(processor.Metrics)
require.True(t, ok)
metrics := generateLifecycleTestMetrics()
if !e.Capabilities().MutatesData {
metrics.MarkReadOnly()
}
err = e.ConsumeMetrics(context.Background(), metrics)
case processor.Traces:
case "traces":
e, ok := c.(processor.Traces)
require.True(t, ok)
traces := generateLifecycleTestTraces()
if !e.Capabilities().MutatesData {
traces.MarkReadOnly()
Expand Down
14 changes: 10 additions & 4 deletions exporter/debugexporter/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions exporter/loggingexporter/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions exporter/nopexporter/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions exporter/otlpexporter/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions exporter/otlphttpexporter/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions processor/batchprocessor/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions processor/batchprocessor/metadata.yaml
Expand Up @@ -7,5 +7,3 @@ status:
distributions: [core, contrib]

tests:
# TODO: https://github.com/open-telemetry/opentelemetry-collector/issues/9688
skip_lifecycle: true
14 changes: 10 additions & 4 deletions processor/memorylimiterprocessor/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.