Skip to content

feat(bdd): add shared stream operations scenario for Go SDK#3245

Open
ex172000 wants to merge 7 commits into
apache:masterfrom
ex172000:qichao/convert-go-bdd-1
Open

feat(bdd): add shared stream operations scenario for Go SDK#3245
ex172000 wants to merge 7 commits into
apache:masterfrom
ex172000:qichao/convert-go-bdd-1

Conversation

@ex172000
Copy link
Copy Markdown
Contributor

Continues / supersedes #3063, which was auto-closed due to inactivity. The branch was force-pushed (rebase on current master plus a new fixup commit), so GitHub does not allow reopening the original PR.

Which issue does this PR close?

Related to #1986

What changed?

The four commits on this branch add a shared Gherkin feature file for stream CRUD operations and corresponding godog step definitions, then layer in update/delete for streams across all SDKs. The new commit on top addresses the remaining review feedback from #3063:

  • chengxilo: thenStreamDeletedSuccessfully now verifies via GetStream against the server instead of checking a local pointer that whenDeleteStream itself set to nil.
  • chengxilo: anchored all sc.Step regexes in bdd/go/tests/basic_messaging.go with ^...$ for consistency.
  • chengxilo: kept the per-scenario After cleanup but documented it as best-effort, with a note that a global cleanup script is the better long-term direction.
  • hubcio: made the stream-delete step explicit in the shared feature file (When I delete the stream with name "...") instead of relying on implicit prior-step state. Updated the Go, Rust, Python, Java, C#, and Node step definitions to match.

Local Execution

  • Branch rebased on current master.
  • go vet ./tests/... and go test -count=0 ./tests/... pass for bdd/go.
  • Pre-commit hooks pass (golangci-lint and csharp-dotnet-format were skipped locally due to toolchain gaps — golangci-lint pinned at v1.64.8 (Go 1.23) cannot lint a Go 1.25 project, and dotnet is not on this machine; CI will exercise both properly).

AI Usage

  1. Which tools? Claude Code
  2. Scope of usage? Generate functions under supervision and planning
  3. How did you verify the generated code works correctly? Build/vet on Go side, manual diff review on the other SDKs
  4. Can you explain every line of the code if asked? Yes

ex172000 and others added 5 commits May 12, 2026 15:23
)

Add a shared Gherkin feature file for stream CRUD operations and
corresponding godog step definitions, beginning the migration of Go
BDD tests from embedded Ginkgo scenarios to shared .feature files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move step definitions from stream_operations_test.go to
stream_operations.go (non-test file) and register the suite in
suite_test.go, matching the pattern used by basic_messaging and
leader_redirection. Update imports to use refactored Go SDK paths
(client, client/tcp, contracts).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
apache#1986)

Extend the shared basic_messaging.feature with stream update and delete
steps, covering full CRUD lifecycle. Add matching step definitions in
all 6 SDKs (Go, Python, Rust, Java, Node, C#). Add update_stream and
delete_stream methods to the Python SDK (PyO3). Remove the separate
stream_operations.feature and its Go-only implementation to avoid
duplication.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use iggy::prelude::Identifier instead of iggy::identifier::Identifier
and unwrap Option<StreamDetails> from get_stream. Add null assertion
for stream.get() return value in Node step definition.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Verify stream deletion via GetStream rather than checking the local
  pointer, which whenDeleteStream sets to nil itself (chengxilo).
- Anchor all Go sc.Step regexes with ^...$ for consistency (chengxilo).
- Document the per-scenario After cleanup as best-effort and note the
  longer-term direction of a global cleanup script (chengxilo).
- Make the stream-delete step explicit by passing the stream name in
  the feature file instead of relying on implicit prior-step state
  (hubcio). Update Go, Rust, Python, Java, C#, and Node step
  definitions to match the new "I delete the stream with name ..."
  step.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 0% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.77%. Comparing base (fdce300) to head (0342d86).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
foreign/python/src/client.rs 0.00% 31 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3245      +/-   ##
============================================
- Coverage     74.17%   73.77%   -0.41%     
  Complexity      943      943              
============================================
  Files          1200     1190      -10     
  Lines        109618   107020    -2598     
  Branches      86509    84011    -2498     
============================================
- Hits          81312    78953    -2359     
+ Misses        25561    25330     -231     
+ Partials       2745     2737       -8     
Components Coverage Δ
Rust Core 74.87% <ø> (-0.54%) ⬇️
Java SDK 60.14% <ø> (+1.70%) ⬆️
C# SDK 69.13% <ø> (-0.33%) ⬇️
Python SDK 77.42% <0.00%> (-4.02%) ⬇️
Node SDK 91.41% <ø> (-0.13%) ⬇️
Go SDK 39.91% <ø> (ø)
Files with missing lines Coverage Δ
foreign/python/src/client.rs 82.37% <0.00%> (-9.09%) ⬇️

... and 63 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.

@hubcio
Copy link
Copy Markdown
Contributor

hubcio commented May 14, 2026

/ready

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label May 14, 2026
Copy link
Copy Markdown
Contributor

@hubcio hubcio left a comment

Choose a reason for hiding this comment

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

minor extra note that didn't fit a hunk: bdd/python/tests/test_basic_messaging.py:63-68 - no_streams_in_system is pass. other 5 SDKs actually call get_streams() and assert empty. relies on the --fresh server flag instead. asymmetric vs the rest; worth fixing while in the area but not blocking.

also noting a pre-existing gotcha that the new symmetric regex highlights: bdd/rust/tests/steps/streams.rs:36 uses ^I create a stream with name (.+)$ (no quote strip) so it captures the literal gherkin quotes - rust BDD has been creating a stream actually named "test-stream" (with the double quotes) on the server. the new step at line 68 uses "([^"]*)" correctly. follow-up.

#[then("the stream should be deleted successfully")]
pub async fn then_stream_deleted_successfully(world: &mut GlobalContext) {
assert!(
world.last_stream_id.is_none(),
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.

this only checks world.last_stream_id, which the when-step at line 101 just set to None - it can never fail. for real coverage mirror the go pattern at bdd/go/tests/basic_messaging.go:250-261: re-fetch via client.get_stream(&identifier) against the deleted id and expect not-found / None.

@then("the stream should be deleted successfully")
def verify_stream_deleted(context):
"""Verify stream was deleted"""
assert context.last_stream_id is None
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.

tautological - the when-step three lines above nulled context.last_stream_id, and this just asserts it's None. add a server roundtrip - await context.client.get_stream(...) against the deleted id and expect missing - to match bdd/go/tests/basic_messaging.go:250-261.


@Then("the stream should be deleted successfully")
public void streamDeletedSuccessfully() {
assertNull(context.lastStreamId, "Stream should have been deleted");
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.

assertNull(context.lastStreamId) re-checks a local field the when-step at line 230 just nulled, so it can't fail. mirror bdd/go/tests/basic_messaging.go:250-261: call getClient().streams().getStream(...) against the deleted id and assert empty Optional.

[Then(@"the stream should be deleted successfully")]
public void ThenTheStreamShouldBeDeletedSuccessfully()
{
_context.CreatedStream.ShouldBeNull();
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.

the when-step at line 221 already nulled _context.CreatedStream, so this assertion can't fail. mirror bdd/go/tests/basic_messaging.go:250-261: await _context.IggyClient.GetStreamByIdAsync(...) against the deleted id and assert null.

'the stream should be deleted successfully',
async function (this: TestWorld) {
// If we reached here without error, the stream was deleted successfully
assert.ok(true);
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.

assert.ok(true) is a no-op - it never fails regardless of server state. the when-step at line 71 already wraps the delete call in assert.ok(...), so this then-step adds zero coverage. re-fetch via this.client.stream.get({ streamId: name }) and assert it returns null / throws, matching bdd/go/tests/basic_messaging.go:250-261.


Returns Option of stream details or a PyRuntimeError on failure.
"""
def update_stream(
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.

apache_iggy.pyi is auto-generated by pyo3_stub_gen per the header at line 18. can you confirm this diff was produced by re-running the generator rather than hand-edited? hand edits get clobbered on next regen. the stub shape matches the surrounding methods so it's probably regenerated, just want to be sure.

When I update the stream name to "test-stream-updated"
Then the stream name should be updated to "test-stream-updated"

When I delete the stream with name "test-stream-updated"
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.

delete-step uses the new name test-stream-updated. nothing in the scenario asserts the old name test-stream no longer resolves after the rename. minor gap - delete-by-new-name succeeding implies the rename happened, but an explicit Then stream "test-stream" should not exist would lock it down.

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author PR is waiting on author response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants