Skip to content

test(go): cover ClusterNodeStatus decoding and String - #5082

Open
Kidkender wants to merge 1 commit into
apache:masterfrom
Kidkender:go-node-status-tests
Open

Kidkender wants to merge 1 commit into
apache:masterfrom
Kidkender:go-node-status-tests

Conversation

@Kidkender

Copy link
Copy Markdown

Which issue does this PR address?

Closes #5036

Rationale

ClusterNodeStatus is decoded from cluster metadata responses, and nothing tested it. The detail most likely to break quietly is that Unknown (5) is a valid constant but TryFrom rejects it on the wire.

What changed?

Adds foreign/go/contracts/node_status_test.go. It has table tests for TryFrom over bytes 0 to 5 and 255, a MarshalBinary/UnmarshalBinary round trip for each valid status, a check that UnmarshalBinary rejects an empty slice and byte 5 and leaves the value unchanged, and the String output for every status, including unknown. No production code changes.

Local Execution

  • Passed: go test ./contracts/... and go vet ./contracts/ in foreign/go
  • Pre-commit hooks ran: prek run passes

Docs

  • No user-facing change

AI Usage

  1. Claude Code (Claude).
  2. It wrote the test file, following the plan in my comment on the issue.
  3. I checked each case against node_status.go and ran go test, go vet and prek run locally.
  4. Yes.

ClusterNodeStatus is read from cluster node data and had no tests.
The easy case to break is Unknown (5): it is a valid constant, but
TryFrom rejects it as a wire value. Cover TryFrom, the binary round
trip, rejected input to UnmarshalBinary, and String.

Closes apache#5036
@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Nov 25, 2026
@justinmclean

Copy link
Copy Markdown
Member

Thanks @Kidkender, and welcome. The description says Claude Code wrote the tests, so please run the team-review skill, as CONTRIBUTING.md asks, and post the result here.

@Kidkender

Copy link
Copy Markdown
Author

Thanks @justinmclean, sorry I missed that step. I ran team-review on e1045ef and all four roles came back APPROVE with no findings on the diff.

It did point out a few things in the existing node_status.go that this PR doesn't touch:

  • String has a pointer receiver, so fmt.Sprint(node.Status) prints the number instead of the name (role.go has the same thing)
  • TryFrom is a generic name next to ClusterNodeRoleTryFrom
  • a bad status byte comes back as ErrInvalidCommand

Happy to open a separate issue for the String one if that's useful.

team-review report
Findings: none
Pre-existing (does not block): node_status.go:69 String pointer receiver (warning),
  node_status.go:41 TryFrom naming (warning), node_status.go:46 ErrInvalidCommand for decode (nit)
Simplifications: none
Verdict: APPROVE
Verification: CI had not run on this head; no local commands during the review

@github-actions

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

If AI assistance was used to create this PR, you are required to run the team-review skill before opening it.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer
  • /pin - exempt the PR from the stale bot, /unpin to undo

See CONTRIBUTING.md for details.

@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.15%. Comparing base (8e827e1) to head (e1045ef).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #5082   +/-   ##
=========================================
  Coverage     92.15%   92.15%           
  Complexity     4357     4357           
=========================================
  Files          1574     1574           
  Lines        417671   417671           
  Branches     346184   346184           
=========================================
+ Hits         384895   384919   +24     
+ Misses        27295    27275   -20     
+ Partials       5481     5477    -4     
Components Coverage Δ
Rust Core 93.49% <ø> (ø)
Java SDK 81.00% <ø> (ø)
C# SDK 86.40% <ø> (ø)
Python SDK 85.52% <ø> (ø)
PHP SDK 90.35% <ø> (ø)
Node SDK 97.25% <ø> (ø)
Go SDK 73.89% <ø> (+0.19%) ⬆️
C++ SDK 85.29% <ø> (ø)
see 6 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.

@spetz spetz left a comment

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 tests cover wire decoding, round trips, invalid input, receiver preservation, and status names.

@justinmclean

Copy link
Copy Markdown
Member

@Kidkender yes please, open the issue for the String receiver.

This branch has not been deployed

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

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go SDK: add unit tests for ClusterNodeStatus

3 participants