container-structure-test
container-structure-test copied to clipboard
exit_code not working ?
Hi,
I'm using this yaml for testing my Debian container :
commandTests:
- name: "package_locales"
command: "dpkg"
args: ["-l", "locales" ]
exit_code: 0
- name: "package_htop"
command: "dpkg"
args: ["-l", "htop" ]
exit_code: 1
expected_error: "dpkg-query: no packages found matching htop"
But :
~/tmp/docker docker run --rm -i -v /var/run/docker.sock:/var/run/docker.sock:ro -v ${PWD}:/src gcr.io/gcp-runtimes/container-structure-test:latest test --image "debian:jessie" --config /src/test.yaml
==================================
====== Test file: test.yaml ======
==================================
=== RUN: [Command Test: package_locales]
--- PASS
=== RUN: [Command Test: package_htop]
--- FAIL
Error: Test 'package_htop' exited with incorrect error code. Expected: 0, Actual: 1
=== RUN: [Metadata Test]
--- PASS
===============
=== RESULTS ===
===============
Passes: 2
Failures: 1
Total tests: 3
FAIL
In my container :
root@b58a723b1ec5:/# dpkg -l htop
dpkg-query: no packages found matching htop
root@b58a723b1ec5:/# echo $?
1
The test "package_htop" shouldn't break...
I'll respond myself.
With the right parameter, it is working :
commandTests:
- name: "package_locales"
command: "dpkg"
args: ["-l", "locales" ]
exitCode: 0
- name: "package_htop"
command: "dpkg"
args: ["-l", "htop" ]
exitCode: 1
expected_error: "dpkg-query: no packages found matching htop"
exit_code vs exitCode, thanks to the commit 5ca19944ec76419715a90daca92123c0a5a78348.
Maybe someone can add to the README a full list of parameters ?
Thanks @Jeoffreybauvin. We can look at some tool to generate docs for all tests and add them in.
That would be a great idea ;).