def test_wait_for_status(podman_backend): image = podman_backend.ImageClass(FEDORA_MINIMAL_REPOSITORY, tag=FEDORA_MINIMAL_REPOSITORY_TAG) cmd = ['true'] cont = image.run_via_binary(command=cmd) try: p = Probe(timeout=6, fnc=cont.is_running, expected_retval=False) p.run() # let's wait for the container to exit assert cont.exit_code() == 0 # let's make sure it exited fine finally: cont.delete(force=True)
def test_exit_code(podman_backend): image = podman_backend.ImageClass(FEDORA_MINIMAL_REPOSITORY, tag=FEDORA_MINIMAL_REPOSITORY_TAG) cmd = ['sleep', '0.3'] cont = image.run_via_binary(command=cmd) try: p = Probe(timeout=5, fnc=cont.is_running, expected_retval=False) p.run() assert not cont.is_running() and cont.exit_code() == 0 finally: cont.delete(force=True) cmd = ['bash', '-c', "exit 42"] cont = image.run_via_binary(command=cmd) try: cont.wait() assert cont.exit_code() == 42 finally: cont.delete(force=True)