Skip to content

Improve tests for Metrics Service #650

Open
devendra-lohar wants to merge 4 commits intomasterfrom
improve_metrics_tests
Open

Improve tests for Metrics Service #650
devendra-lohar wants to merge 4 commits intomasterfrom
improve_metrics_tests

Conversation

@devendra-lohar
Copy link
Copy Markdown

This PR adds tests for MetricsService and improves coverage for the uncovered GetRetryPolicy function.

@devendra-lohar devendra-lohar requested a review from a team as a code owner March 30, 2026 06:46
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.91%. Comparing base (f156431) to head (34dfc32).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #650      +/-   ##
==========================================
+ Coverage   77.71%   77.91%   +0.20%     
==========================================
  Files         136      136              
  Lines       13226    13226              
  Branches     1991     1991              
==========================================
+ Hits        10278    10305      +27     
+ Misses       2112     2083      -29     
- Partials      836      838       +2     

see 4 files with indirect coverage changes

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

@ozangoktan
Copy link
Copy Markdown
Contributor

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces unit tests to verify the retry policy of the metrics server, specifically for transient HTTP errors and exceptions. It also implements a FakeLogger to facilitate log assertion in tests. The review feedback identifies a signature mismatch in the ILogger.Log implementation within FakeLogger, recommending the use of nullable Exception? to ensure compatibility with Nullable Reference Types.

Hmnt39
Hmnt39 previously approved these changes Apr 1, 2026
Copy link
Copy Markdown

@Hmnt39 Hmnt39 left a comment

Choose a reason for hiding this comment

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

LGTM, just a nit (by gemini).

Hmnt39
Hmnt39 previously approved these changes Apr 1, 2026
Comment on lines +321 to +336
#nullable enable
private sealed class FakeLogger<T> : ILogger<T>
{
public List<(LogLevel Level, string Message)> Entries { get; } = new List<(LogLevel Level, string Message)>();

IDisposable ILogger.BeginScope<TState>(TState state) => NullScope.Instance;
bool ILogger.IsEnabled(LogLevel logLevel) => true;
void ILogger.Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
=> Entries.Add((logLevel, formatter(state, exception)));

private sealed class NullScope : IDisposable
{
public static readonly NullScope Instance = new NullScope();
public void Dispose() { }
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Something like this belongs in ExtractorUtils.Test project, if we don't already have one.

@devendra-lohar devendra-lohar added the waiting-for-risk-review Waiting for a member of the risk review team to take an action label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-for-risk-review Waiting for a member of the risk review team to take an action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants