Node SDK: add unit tests for the partitioning serialiser

Abierto Apto para principiantes
#5,032 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
Medio día
Aptitud para principiantes
85/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, typescript
Área
testing

Línea de trabajo

Empieza con foreign/node/src/wire/message/partitioning.utils.ts, que contiene serializePartitioning, serializePartitioningValue y serializeMessageKey, y con number.utils.ts para el diseño little-endian. Usa foreign/node/src/wire/topic/delete-topic.command.test.ts como patrón para el nuevo partitioning.utils.test.ts. Está terminado cuando los casos listados en el issue (distribución equilibrada, ID de partición, claves string, number, bigint y Buffer, y el throw para un valor no soportado) pasan con npm run test:unit y npm run lint en foreign/node.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Rust
Estrellas
5.3k
Forks
548
Merge medio
2 d 20 h
PR fusionados (30 d)
194

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/iggy

Todos los issues de apache/iggy

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.