Node SDK: add unit tests for the partitioning serialiser

Aperta Adatta ai principianti
#5,032 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
Mezza giornata
Idoneità per principianti
85/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
testing

Direzione di ricerca

Inizia da foreign/node/src/wire/message/partitioning.utils.ts, che contiene serializePartitioning, serializePartitioningValue e serializeMessageKey, e da number.utils.ts per il layout little-endian. Usa foreign/node/src/wire/topic/delete-topic.command.test.ts come modello per il nuovo partitioning.utils.test.ts. È completato quando i casi elencati nell'issue (distribuzione bilanciata, ID di partizione, chiavi string, number, bigint e Buffer, e il throw per un valore non supportato) passano con npm run test:unit e npm run lint in foreign/node.

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

Descrizione

good first issue javascript test
Description

serializePartitioning, serializePartitioningValue and serializeMessageKey in foreign/node/src/wire/message/partitioning.utils.ts have no unit test. The wire format is the kind (1 byte), the value length (1 byte), then the value. Balanced has an empty value, a partition id is a uint32, and a message key is a string (UTF-8), a number (uint32), a bigint (uint64) or a Buffer passed through unchanged. A wrong kind code or a changed key encoding would send messages to the wrong partition without any test failing.

Affected area / component

Node SDK

Proposed solution

Add foreign/node/src/wire/message/partitioning.utils.test.ts, modelled on foreign/node/src/wire/topic/delete-topic.command.test.ts. Build the expected bytes by hand, so the test does not call the code it checks. number.utils.ts shows the little-endian layout of uint32ToBuf and uint64ToBuf.

  • serializePartitioning() with no argument gives 1, 0.
  • Partitioning.PartitionId(7) gives 2, 4, 7, 0, 0, 0.
  • Partitioning.MessageKey('ab') gives 3, 2, 97, 98.
  • A numeric key, a bigint key and a Buffer key each give the expected length and bytes.
  • serializeMessageKey throws for an unsupported value, such as a plain object cast to the key type.

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.