From cae415b91cf81416ad7d89f9b3ba16a26ae28fc5 Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Mon, 15 Jan 2018 16:10:56 +0800 Subject: Update podman_import test to use podman Update the podman_import test to use podman run, and update the check method for string check method. Signed-off-by: Yiqiao Pu --- test/podman_import.bats | 102 ++++++++++-------------------------------------- 1 file changed, 20 insertions(+), 82 deletions(-) (limited to 'test') diff --git a/test/podman_import.bats b/test/podman_import.bats index 6303141c9..69c704a68 100644 --- a/test/podman_import.bats +++ b/test/podman_import.bats @@ -2,8 +2,6 @@ load helpers -IMAGE="redis:alpine" - function teardown() { cleanup_test } @@ -13,133 +11,73 @@ function setup() { } @test "podman import with source and reference" { - skip "Test needs to be converted to podman run bash -c" - start_crio - run bash -c crioctl pod run bash -c --config "$TESTDATA"/sandbox_config.json - echo "$output" - [ "$status" -eq 0 ] - pod_id="$output" - run bash -c crioctl image pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run bash -c crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $ALPINE sleep 60" echo "$output" [ "$status" -eq 0 ] ctr_id="$output" - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar "$ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} import container.tar imported-image + run bash -cp "${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id" echo "$output" [ "$status" -eq 0 ] - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} images + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} import container.tar imported-image" echo "$output" [ "$status" -eq 0 ] - images="$output" - run bash -c grep "imported-image" <<< "$images" + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} images" echo "$output" [ "$status" -eq 0 ] - cleanup_ctrs - cleanup_pods - stop_crio + [[ "$output" == *"imported-image"* ]] rm -f container.tar } @test "podman import without reference" { - skip "Test needs to be converted to podman run bash -c" - start_crio - run bash -c crioctl pod run bash -c --config "$TESTDATA"/sandbox_config.json - echo "$output" - [ "$status" -eq 0 ] - pod_id="$output" - run bash -c crioctl image pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run bash -c crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $ALPINE sleep 60" echo "$output" [ "$status" -eq 0 ] ctr_id="$output" - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar "$ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} import container.tar + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id" echo "$output" [ "$status" -eq 0 ] - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} images + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} import container.tar" echo "$output" [ "$status" -eq 0 ] - images="$output" - run bash -c grep "" <<< "$images" + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} images" echo "$output" [ "$status" -eq 0 ] - cleanup_ctrs - cleanup_pods - stop_crio + [[ "$output" == *""* ]] rm -f container.tar } @test "podman import with message flag" { - skip "Test needs to be converted to podman run bash -c" - start_crio - run bash -c crioctl pod run bash -c --config "$TESTDATA"/sandbox_config.json - echo "$output" - [ "$status" -eq 0 ] - pod_id="$output" - run bash -c crioctl image pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run bash -c crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $ALPINE sleep 60" echo "$output" [ "$status" -eq 0 ] ctr_id="$output" - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar "$ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} import --message "importing container test message" container.tar imported-image + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id" echo "$output" [ "$status" -eq 0 ] - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} history imported-image + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} import --message 'importing container test message' container.tar imported-image" echo "$output" [ "$status" -eq 0 ] - history="$output" - run bash -c grep "importing container test message" <<< "$history" + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} history imported-image" echo "$output" [ "$status" -eq 0 ] - cleanup_ctrs - cleanup_pods - stop_crio + [[ "$output" == *"importing container test message"* ]] rm -f container.tar } @test "podman import with change flag" { - skip "Test needs to be converted to podman run bash -c" - start_crio - run bash -c crioctl pod run bash -c --config "$TESTDATA"/sandbox_config.json - echo "$output" - [ "$status" -eq 0 ] - pod_id="$output" - run bash -c crioctl image pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run bash -c crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $ALPINE sleep 60" echo "$output" [ "$status" -eq 0 ] ctr_id="$output" - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar "$ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} import --change "CMD=/bin/bash" container.tar imported-image + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id" echo "$output" [ "$status" -eq 0 ] - run bash -c ${PODMAN_BINARY} ${PODMAN_OPTIONS} inspect imported-image + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} import --change 'CMD=/bin/bash' container.tar imported-image" echo "$output" [ "$status" -eq 0 ] - inspect="$output" - run bash -c grep "/bin/bash" <<< "$inspect" + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} inspect imported-image" echo "$output" [ "$status" -eq 0 ] - cleanup_ctrs - cleanup_pods - stop_crio + [[ "$output" == *"/bin/bash"* ]] rm -f container.tar } -- cgit v1.2.3-54-g00ecf