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

Aperta Adatta ai principianti
#5,033 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nodejs, typescript
Ambito
testing

Direzione di ricerca

Leggi deserializeNode e deserializeMetadata in foreign/node/src/wire/cluster/cluster.utils.ts, e i valori di ruolo e stato in cluster.type.ts. Crea cluster.utils.test.ts accanto a questi file, seguendo il modello di delete-topic.command.test.ts, con una funzione helper che costruisce un buffer di nodo a partire da valori semplici. Il lavoro è completato quando i casi elencati passano con npm run test:unit e npm run lint termina con successo in foreign/node.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Rust
Stelle
5.3k
Fork
548
Merge medio
2g 20h
PR unite (30g)
194

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/iggy

Tutte le issue di apache/iggy

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.