Extend `exec`: reject on failure, stdin, streaming output and a timeout
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- docker, node.js, typescript
Línea de trabajo
Read ExecOptions in packages/testcontainers/src/types.ts and the two exec implementations in packages/testcontainers/src/generic-container/started-generic-container.ts and packages/testcontainers/src/container-runtime/clients/container/docker-container-client.ts. Check the dependency issues #1525, #1531, and #1532, then trace existing exec tests and callers. Done means the four optional behaviors work while defaults stay unchanged; the issue says the work can be split by option.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
exec runs a command and resolves with { output, stdout, stderr, exitCode } once it finishes. Its options are workingDir, user and env. Four things are missing.
It never rejects on failure, so callers who expect success check every time:
const result = await container.exec(["psql", "-c", sql]);
if (result.exitCode !== 0) {
throw new Error(`Command failed with exit code ${result.exitCode}: ${result.output}`);
}
Seven module files carry this check, nine times in total, each with its own message. In tests it is easy to forget, and a failed setup command then surfaces later as an unrelated assertion failure.
It cannot be given input. Piping a SQL file or a dump into a command means copying the file into the container first.
Output is buffered in full and returned at the end. A long-running command shows nothing until it exits, and a large output is held in memory.
It has no timeout. A command that never exits never resolves.
Expected
await container.exec(["psql", "-U", "test"], {
throwOnError: true,
stdin: fs.createReadStream("./seed.sql"),
onOutput: (chunk, stream) => process.stdout.write(chunk),
timeout: 30_000,
});
throwOnErrorrejects on a non-zero exit code, with an error that carries the command, exit code, stdout and stderr.stdinaccepts a string,BufferorReadable.onOutputreceives output as it arrives.timeoutrejects and stops waiting for the command.
The defaults stay as they are.
Where
execinpackages/testcontainers/src/generic-container/started-generic-container.tsexecinpackages/testcontainers/src/container-runtime/clients/container/docker-container-client.tsExecOptionsinpackages/testcontainers/src/types.ts
Notes
- Java and Go return the exit code and leave the check to the caller, as this library does today. Go's
exec.ProcessOptioncovers user, working directory and environment. This goes further than either. - Can be split into one change per option.
Dependencies
- Stack on #1525, #1531: same function, and both change
ExecOptions. - Coordinate with #1532: for the error class.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.6k
- Forks
- 274
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 44
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testcontainers/testcontainers-node
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
testcontainers/testcontainers-node#1539 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
testcontainers/testcontainers-node#1533 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
testcontainers/testcontainers-node#1531 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
testcontainers/testcontainers-node#1529 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
testcontainers/testcontainers-node#1528 ·
Los mantenedores suelen responder en 1 día
Todos los issues de testcontainers/testcontainers-node
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
one-zero-eight/apply-bot#39 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bigbluebutton/bbb-ui-components-react#108 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
high priority
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
CI-CMG/deep-sea-corals-exb#84 · 1 comentario ·