Skip to content

otelconf: Increased test coverage for Prometheus-related code #7440

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sonalgaud12
Copy link
Contributor

This PR fixes #6821

  • Added test for prometheusReader function for both v0.3.0 & v0.2.0

  • Locally tested

@sonalgaud12 sonalgaud12 requested review from pellared and a team as code owners June 7, 2025 15:16
Copy link

codecov bot commented Jun 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.3%. Comparing base (088be4b) to head (a4d6493).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7440   +/-   ##
=====================================
  Coverage   82.3%   82.3%           
=====================================
  Files        205     205           
  Lines      17967   17967           
=====================================
+ Hits       14794   14800    +6     
+ Misses      2736    2731    -5     
+ Partials     437     436    -1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dmathieu dmathieu added the Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG label Jun 10, 2025
@sonalgaud12 sonalgaud12 requested a review from pellared June 11, 2025 04:54
assert.True(t, strings.Contains(addr, "localhost") || strings.Contains(addr, "127.0.0.1"),
"server address %s should contain localhost or 127.0.0.1", addr)

resp, err := http.DefaultClient.Get("http://" + server.Addr + "/metrics")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resp, err := http.DefaultClient.Get("http://" + server.Addr + "/metrics")
resp, err := http.DefaultClient.Get("http://" + addr + "/metrics")

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
reader, err := prometheusReader(context.Background(), tt.config)
assert.Error(t, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is redundant with the next one

Suggested change
assert.Error(t, err)

Comment on lines +1276 to +1278
if err != nil {
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it not?

require.NoError(t, err)
require.NotNil(t, reader)

WithResourceConstantLabels: &IncludeExclude{},
}
reader, err := prometheusReader(context.Background(), &cfg)
assert.Error(t, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.Error(t, err)

Comment on lines +1477 to +1479
if err != nil {
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it not?

require.NoError(t, err)
require.NotNil(t, reader)

}
}

func TestPrometheusReaderConfigurationOptions(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It this test missing for v0.3.0?

@github-actions github-actions bot requested a review from codeboten July 7, 2025 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

otelconf: Increase test coverage for Prometheus-related code
3 participants