#!/usr/bin/env bats -*- bats -*- # # tests for podman import # load helpers @test "podman import" { local archive=$PODMAN_TMPDIR/archive.tar local random_content=$(random_string 12) # Generate a random name and tag (must be lower-case) local random_name=x0$(random_string 12 | tr A-Z a-z) local random_tag=t0$(random_string 7 | tr A-Z a-z) local fqin=localhost/$random_name:$random_tag run_podman run --name import $IMAGE sh -c "echo ${random_content} > /random.txt" run_podman export import -o $archive run_podman rm -t 0 -f import # Simple import run_podman import -q $archive iid="$output" run_podman run --rm $iid cat /random.txt is "$output" "$random_content" "simple import" run_podman rmi -f $iid # Simple import via stdin run_podman import -q - < <(cat $archive) iid="$output" run_podman run --rm $iid cat /random.txt is "$output" "$random_content" "simple import via stdin" run_podman rmi -f $iid # Tagged import run_podman import -q $archive $fqin run_podman run --rm $fqin cat /random.txt is "$output" "$random_content" "tagged import" run_podman rmi -f $fqin # Tagged import via stdin run_podman import -q - $fqin < <(cat $archive) run_podman run --rm $fqin cat /random.txt is "$output" "$random_content" "tagged import via stdin" run_podman rmi -f $fqin } # Integration tag to catch future breakage in tar, e.g. #19407 # bats test_tags=distro-integration @test "podman export, alter tarball, re-import" { # FIXME: #21373 - tar < 1.35 is broken. # Remove this skip once all VMs are updated to 1.35.2 or above # (.2, because of #19407) tar_version=$(tar --version | head -1 | awk '{print $NF}' | tr -d .) if [[ $tar_version -lt 135 ]]; then skip "test requires tar >= 1.35 (you have: $tar_version)" fi # Create a test file following test mkdir $PODMAN_TMPDIR/tmp touch $PODMAN_TMPDIR/testfile1 echo "modified tar file" >> $PODMAN_TMPDIR/tmp/testfile2 # Create Dockerfile for test dockerfile=$PODMAN_TMPDIR/Dockerfile cat >$dockerfile <