Extend `exec`: reject on failure, stdin, streaming output and a timeout
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- docker, node.js, typescript
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 2.6k
- Fork
- 274
- Merge medio
- 1g 14h
- PR unite (30g)
- 44
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di testcontainers/testcontainers-node
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
testcontainers/testcontainers-node#1539 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
testcontainers/testcontainers-node#1533 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
testcontainers/testcontainers-node#1531 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
testcontainers/testcontainers-node#1529 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
testcontainers/testcontainers-node#1528 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di testcontainers/testcontainers-node
Issue simili
-
Documentation Link TypoAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 83/100
Zettlr/Zettlr#6610 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Feil lovtekst i bekreftelsen når leder melder unntak fra oppfølgingsplanForse già presa @AudunSorheim l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
navikt/syfo-oppfolgingsplan-frontend#1110 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
db-ux-design-system/core-web#8461 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Cannot run an integration on windows when power shell is selected as the default profile terminalApertaPriority/Blocker Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
wso2/product-integrator#2767 ·
I maintainer di solito rispondono entro 1 giorno