Skip to content

test(csharp): add leader_redirection scenario to BDD tests#2948

Open
yeyomontana wants to merge 9 commits intoapache:masterfrom
yeyomontana:feat/csharp-bdd-leader-redirection
Open

test(csharp): add leader_redirection scenario to BDD tests#2948
yeyomontana wants to merge 9 commits intoapache:masterfrom
yeyomontana:feat/csharp-bdd-leader-redirection

Conversation

@yeyomontana
Copy link

@yeyomontana yeyomontana commented Mar 16, 2026

Summary

Add support for the leader_redirection BDD scenario in the C# SDK test suite.

Changes

  • add LeaderRedirectionSteps.cs with step definitions for the scenario
  • update the C# BDD test project wiring so the scenario is included
  • update test context and hooks required for the scenario

LLM usage: LLM tools were used to help inspect the repository and assist with debugging CI/compiler issues. The final changes were reviewed and verified manually before submission.

Notes

This adds the missing C# BDD scenario support to align coverage with the existing shared scenario set.

Closes #2628

@yeyomontana yeyomontana changed the title feat(csharp-bdd): add leader_redirection scenario support [csharp SDK] Implement leader_redirection scenario in BDD tests Mar 16, 2026
@yeyomontana yeyomontana force-pushed the feat/csharp-bdd-leader-redirection branch from 812b07f to b0f1f7e Compare March 16, 2026 16:25
@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.39%. Comparing base (a3328c8) to head (c964e32).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2948      +/-   ##
============================================
+ Coverage     70.37%   70.39%   +0.02%     
  Complexity      925      925              
============================================
  Files          1029     1029              
  Lines         85281    85279       -2     
  Branches      62655    62664       +9     
============================================
+ Hits          60015    60033      +18     
+ Misses        22762    22731      -31     
- Partials       2504     2515      +11     
Flag Coverage Δ
csharp 67.43% <ø> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 138 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yeyomontana yeyomontana changed the title [csharp SDK] Implement leader_redirection scenario in BDD tests [csharp sdk] implement leader_redirection scenario in bdd tests Mar 16, 2026
@atharvalade
Copy link
Contributor

@yeyomontana this PR title is invalid, the CI won't pass. Can you rename the PR title from one of these options:

  • feat
  • fix
  • docs
  • style
  • refactor
  • perf
  • test
  • build
  • ci
  • chore
  • revert
  • repo
  • deps

Please look at other PRs for reference.

@yeyomontana yeyomontana changed the title [csharp sdk] implement leader_redirection scenario in bdd tests test (csharp-sdk): add leader_redirection scenario to BDD tests Mar 16, 2026
@lukaszzborek lukaszzborek changed the title test (csharp-sdk): add leader_redirection scenario to BDD tests test(csharp): add leader_redirection scenario to BDD tests Mar 16, 2026
@lukaszzborek
Copy link
Contributor

Hi, I see unrelated changes from rust file. Please remove it.
Also please answer questions about LLM usage which are in pr template

@yeyomontana
Copy link
Author

Thanks for the feedback, I removed the unrelated change so the PR now only contains the C# BDD files.

I’ve also answered the LLM usage question in the PR description.

@yeyomontana yeyomontana requested a review from hubcio March 17, 2026 12:14
Copy link
Contributor

@lukaszzborek lukaszzborek left a comment

Choose a reason for hiding this comment

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

@yeyomontana I added some comments. I propose creating client test metadata where you can store information about the initial address or redirection.
You can also check what it looks like in other languages. Rust and Go have implemented that.

[Given(@"I have cluster configuration enabled with (\d+) nodes")]
public void GivenIHaveClusterConfigurationEnabledWithNodes(int nodeCount)
{
nodeCount.ShouldBe(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

it's information how many nodes we have. We should store it not check if scenario have 2 nodes

[Given(@"node (\d+) is configured on port (\d+)")]
public void GivenNodeIsConfiguredOnPort(int nodeId, int port)
{
_ = nodeId;
Copy link
Contributor

Choose a reason for hiding this comment

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

we should store node information in context. nodeId can be key of dictionary or something

};
}

private static async Task WaitForServerPortAsync(string address)
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need that. Docker Compose will wait for the server to start.

[Then(@"the client should not perform any redirection")]
public void ThenTheClientShouldNotPerformAnyRedirection()
{
GetClient("main").GetCurrentAddress().ShouldBe(_context.InitialAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think information about redirection should be in some test client metadata, where you can store initial address for specific client

Comment on lines +164 to +174
[Then(@"client ([A-Z]) should stay connected to port (\d+)")]
public async Task ThenClientShouldStayConnectedToPort(string clientName, int port)
{
await AssertClientAddress(clientName, port);
}

[Then(@"client ([A-Z]) should redirect to port (\d+)")]
public async Task ThenClientShouldRedirectToPort(string clientName, int port)
{
await AssertClientAddress(clientName, port);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Both steps have the same code. It can be merge into single step with client ([A-Z]) should (?:redirect to|stay connected to) port (\d+)

@yeyomontana
Copy link
Author

@lukaszzborek

Thanks for the detailed review — I’ve applied all the suggested changes:
• removed hardcoded node count and store it in context
• store nodeId/port mapping in context
• removed the manual wait (relying on docker compose)
• switched to per-client metadata for redirection checks
• merged duplicate step definitions

Let me know if anything still needs adjustment 👍

@lukaszzborek
Copy link
Contributor

@yeyomontana please make sure the code compiles and the tests pass. You should also do this locally.

@atharvalade
Copy link
Contributor

@lukaszzborek

Thanks for the detailed review — I’ve applied all the suggested changes: • removed hardcoded node count and store it in context • store nodeId/port mapping in context • removed the manual wait (relying on docker compose) • switched to per-client metadata for redirection checks • merged duplicate step definitions

Let me know if anything still needs adjustment 👍

@yeyomontana It'll be awesome if you could use the PR template for future PRs to maintain consistency. It'll be there when you open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[csharp SDK] Implement leader_redirection scenario in BDD tests

4 participants