Node SDK: add unit tests for the cluster node and metadata deserialisers

Open Beginner friendly
#5,033 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
nodejs, typescript
Domain
testing

Research direction

Read deserializeNode and deserializeMetadata in foreign/node/src/wire/cluster/cluster.utils.ts, and the role and status values in cluster.type.ts. Create cluster.utils.test.ts beside them, following the pattern in delete-topic.command.test.ts, with a helper that builds a node buffer from plain values. Done when the listed cases pass under npm run test:unit and npm run lint passes in foreign/node.

Written by the indexing model from the issue text.

Description

good first issue javascript test
Description

deserializeNode and deserializeMetadata in foreign/node/src/wire/cluster/cluster.utils.ts have no unit test. deserializeNode reads a replica id, a length-prefixed name and IP, four uint16 ports, a role byte and a status byte, and throws when the buffer is too short at any step. deserializeMetadata reads a cluster name and a list of nodes. This is separate from #4968 and #4969, which add bounds checks to the client and consumer group deserialisers.

Affected area / component

Node SDK

Proposed solution

Add foreign/node/src/wire/cluster/cluster.utils.test.ts, modelled on foreign/node/src/wire/topic/delete-topic.command.test.ts. cluster.type.ts has the role and status values. A small helper in the test file that builds a node buffer from plain values lets each test change one field.

  • Decode one hand-built node and check every field of the result, including length.
  • Check the role and status names for each valid byte.
  • Check that a buffer shorter than 19 bytes throws, and that a name length running past the end throws.
  • Check that an unknown role byte throws Invalid ClusterNodeRole.
  • Decode a metadata buffer with two nodes.

How to test: npm run test:unit and npm run lint pass in foreign/node.

Good first issue
  • I think this could be a good first issue for a new contributor
Dominant language
Rust
Stars
5.3k
Forks
548
Avg merge
2d 20h
Merged PRs (30d)
194

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/iggy

All issues in apache/iggy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.