GoogleContainerTools / GoogleContainerTools/container-structure-test
Add Expected Log validation
- Dominant language
- Go
- Stars
- 2.5k
- Forks
- 212
- PR merge metrics
- No merged PRs in 30d
Description
I'd like to use this tool to test if the main process of a docker image can start successfully, without issues. The fact is that the process is meant to not exit, since it has to keep the container alive, and so there is no exit code/output. Looking at the available features I didn't find anything allowing this.
The process logs something like this if starts successfully:
`2023-05-09 13:20:48.242 UTC [1] LOG: database system is ready to accept connections`
The `container-structure-test test` process gets stuck if used this way, because it waits for the container to exit which never happens.
It would be cool having an `ExpectedLog` field to be used along with a timeout. Something like this:
```
schemaVersion: '2.0.0'
commandTests:
- name: "Test Postgres starting successfully"
command: "bash"
args:
- -c
- |
docker-entrypoint.sh postgres
envVars:
- key: POSTGRES_PASSWORD
value: password
expectedLog: [".*database system is ready to accept connections.*"]
timeOut: 20s
```
Contributor guide
Assessment
This issue has not been assessed yet.