it does not means that the command fail, with that said, the check will
fail unless you modify te test appending "|| true" at the end to force
it to return 0. A good example is if you want to test if a rpm package
is istalled or not in the target container.
If the package exists, there will be no exception, but if the package
does not exists (and this is the intention of the test) it will thrown a
exception and will hide the root cause.
E.g.
Scenario: Ensure the openjdk8 packages are not installed on container.
When container is ready
Then run sh -c '/usr/bin/rpm -q java-1.8.0-openjdk-devel' in
container and check its output contains package java-1.8.0-openjdk-devel
is not installed
In this example, the package is not installed and the test fails unless
|| true is appended at the end.
With this change we will have a better output about why the test has
failed:
Exception: ("Phrase 'package java-1.8.0-openjdk-devel is not
installed' was not found in the output of running the 'sh -c
'/usr/bin/rpm -q java-1.8.0-openjdk-devel'' command", b'package
java-1.8.0-openjdk-devel is not installed\n', ExecException("Command sh
-c '/usr/bin/rpm -q java-1.8.0-openjdk-devel' failed to execute, return
code: 1"))
it does not means that the command fail, with that said, the check will fail unless you modify te test appending "|| true" at the end to force it to return 0. A good example is if you want to test if a rpm package is istalled or not in the target container.
If the package exists, there will be no exception, but if the package does not exists (and this is the intention of the test) it will thrown a exception and will hide the root cause.
E.g.
In this example, the package is not installed and the test fails unless || true is appended at the end.
With this change we will have a better output about why the test has failed: