mirror of
https://github.com/containers/podman.git
synced 2025-12-03 11:49:18 +08:00
Merge pull request #21069 from umohnani8/new-farmbuild-2
farm build: push built images to registry
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
load helpers.bash
|
||||
|
||||
|
||||
@test "farm - check farm has been created" {
|
||||
run_podman farm ls
|
||||
assert "$output" =~ $FARMNAME
|
||||
@@ -17,18 +16,20 @@ load helpers.bash
|
||||
empty_farm="empty-farm"
|
||||
# create an empty farm
|
||||
run_podman farm create $empty_farm
|
||||
run_podman farm build --farm $empty_farm -t $iname $PODMAN_TMPDIR
|
||||
run_podman farm build --farm $empty_farm --authfile $AUTHFILE --tls-verify=false -t $REGISTRY/$iname $FARM_TMPDIR
|
||||
assert "$output" =~ "Local builder ready"
|
||||
|
||||
# get the system architecture
|
||||
run_podman info --format '{{.Host.Arch}}'
|
||||
ARCH=$output
|
||||
# inspect manifest list built and saved in local containers-storage
|
||||
# FIXME: use --format?
|
||||
run_podman manifest inspect $iname
|
||||
assert "$output" =~ $ARCH
|
||||
|
||||
run_podman images -a
|
||||
echo "# skopeo inspect ..."
|
||||
run skopeo inspect "$@" --tls-verify=false --authfile $AUTHFILE docker://$REGISTRY/$iname
|
||||
echo "$output"
|
||||
is "$status" "0" "skopeo inspect - exit status"
|
||||
|
||||
# FIXME-someday: why do we need the prune?
|
||||
run_podman manifest rm $iname
|
||||
@@ -37,18 +38,19 @@ load helpers.bash
|
||||
|
||||
@test "farm - build on farm node only with --cleanup" {
|
||||
iname="test-image-2"
|
||||
run_podman farm build --cleanup --local=false -t $iname $PODMAN_TMPDIR
|
||||
run_podman farm build --cleanup --local=false --authfile $AUTHFILE --tls-verify=false -t $REGISTRY/$iname $FARM_TMPDIR
|
||||
assert "$output" =~ "Farm \"$FARMNAME\" ready"
|
||||
# get the system architecture
|
||||
run_podman info --format '{{.Host.Arch}}'
|
||||
ARCH=$output
|
||||
# inspect manifest list built and saved in dir
|
||||
# FIXME FIXME FIXME! #20505: do not write anything under cwd
|
||||
ls -l $iname
|
||||
# inspect manifest list built and saved in local containers-storage
|
||||
run_podman manifest inspect $iname
|
||||
assert "$output" =~ $ARCH
|
||||
|
||||
# FIXME FIXME FIXME FIXME! NEVER WRITE INTO PWD!
|
||||
manifestarch=$(jq -r '.manifests[].platform.architecture' <$iname/manifest.json)
|
||||
assert "$manifestarch" = "$ARCH" "arch from $iname/manifest.json"
|
||||
echo "# skopeo inspect ..."
|
||||
run skopeo inspect "$@" --tls-verify=false --authfile $AUTHFILE docker://$REGISTRY/$iname
|
||||
echo "$output"
|
||||
is "$status" "0" "skopeo inspect - exit status"
|
||||
|
||||
# see if we can ssh into node to check the image was cleaned up
|
||||
run ssh $ROOTLESS_USER@localhost podman images --filter dangling=true --noheading
|
||||
@@ -58,21 +60,27 @@ load helpers.bash
|
||||
run_podman images --filter dangling=true --noheading
|
||||
assert "$output" = "" "podman images on local host"
|
||||
|
||||
run_podman manifest rm $iname
|
||||
run_podman image prune -f
|
||||
}
|
||||
|
||||
@test "farm - build on farm node and local" {
|
||||
iname="test-image-3"
|
||||
run_podman farm build -t $iname $PODMAN_TMPDIR
|
||||
run_podman farm build --authfile $AUTHFILE --tls-verify=false -t $REGISTRY/$iname $FARM_TMPDIR
|
||||
assert "$output" =~ "Farm \"$FARMNAME\" ready"
|
||||
|
||||
# get the system architecture
|
||||
run_podman info --format '{{.Host.Arch}}'
|
||||
ARCH=$output
|
||||
# inspect manifest list built and saved in dir
|
||||
# inspect manifest list built and saved
|
||||
run_podman manifest inspect $iname
|
||||
assert "$output" =~ $ARCH
|
||||
|
||||
echo "# skopeo inspect ..."
|
||||
run skopeo inspect "$@" --tls-verify=false --authfile $AUTHFILE docker://$REGISTRY/$iname
|
||||
echo "$output"
|
||||
is "$status" "0" "skopeo inspect - exit status"
|
||||
|
||||
run_podman manifest rm $iname
|
||||
run_podman image prune -f
|
||||
}
|
||||
@@ -81,15 +89,21 @@ load helpers.bash
|
||||
|
||||
@test "farm - build on farm node only (podman-remote)" {
|
||||
iname="test-image-4"
|
||||
run_podman --remote farm build -t $iname $PODMAN_TMPDIR
|
||||
run_podman --remote farm build --authfile $AUTHFILE --tls-verify=false -t $REGISTRY/$iname $FARM_TMPDIR
|
||||
assert "$output" =~ "Farm \"$FARMNAME\" ready"
|
||||
|
||||
# get the system architecture
|
||||
run_podman --remote info --format '{{.Host.Arch}}'
|
||||
ARCH=$output
|
||||
# inspect manifest list built and saved in dir
|
||||
manifestarch=$(jq -r '.manifests[].platform.architecture' <$iname/manifest.json)
|
||||
assert "$manifestarch" = "$ARCH" "arch from $iname/manifest.json"
|
||||
# inspect manifest list built and saved
|
||||
run_podman manifest inspect $iname
|
||||
assert "$output" =~ $ARCH
|
||||
|
||||
echo "# skopeo inspect ..."
|
||||
run skopeo inspect "$@" --tls-verify=false --authfile $AUTHFILE docker://$REGISTRY/$iname
|
||||
echo "$output"
|
||||
is "$status" "0" "skopeo inspect - exit status"
|
||||
|
||||
run_podman manifest rm $iname
|
||||
run_podman image prune -f
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
load ../system/helpers.bash
|
||||
|
||||
export FARM_TMPDIR=$(mktemp -d --tmpdir=${BATS_TMPDIR:-/tmp} podman_bats.XXXXXX)
|
||||
|
||||
function setup(){
|
||||
basic_setup
|
||||
|
||||
# Always create the same containerfile
|
||||
cat >$PODMAN_TMPDIR/Containerfile <<EOF
|
||||
cat >$FARM_TMPDIR/Containerfile <<EOF
|
||||
FROM $IMAGE
|
||||
RUN arch | tee /arch.txt
|
||||
RUN date | tee /built.txt
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
bats_require_minimum_version 1.8.0
|
||||
|
||||
load helpers
|
||||
load ../system/helpers
|
||||
load ../system/helpers.registry
|
||||
load ../system/helpers.network
|
||||
|
||||
function setup_suite(){
|
||||
if [[ -z "$ROOTLESS_USER" ]]; then
|
||||
@@ -32,9 +35,29 @@ function setup_suite(){
|
||||
# only set up the podman farm before the first test
|
||||
run_podman system connection add --identity $sshkey test-node $ROOTLESS_USER@localhost
|
||||
run_podman farm create $FARMNAME test-node
|
||||
|
||||
export PODMAN_LOGIN_WORKDIR=$(mktemp -d --tmpdir=${BATS_TMPDIR:-${TMPDIR:-/tmp}} podman-bats-registry.XXXXXX)
|
||||
|
||||
export PODMAN_LOGIN_USER="user$(random_string 4)"
|
||||
export PODMAN_LOGIN_PASS="pw$(random_string 15)"
|
||||
|
||||
# FIXME: racy! It could be many minutes between now and when we start it.
|
||||
# To mitigate, we use a range not used anywhere else in system tests.
|
||||
export PODMAN_LOGIN_REGISTRY_PORT=$(random_free_port 42000-42999)
|
||||
|
||||
# create a local registry to push images to
|
||||
export REGISTRY=localhost:${PODMAN_LOGIN_REGISTRY_PORT}
|
||||
export AUTHFILE=$FARM_TMPDIR/authfile.json
|
||||
start_registry
|
||||
run_podman login --authfile=$AUTHFILE \
|
||||
--tls-verify=false \
|
||||
--username ${PODMAN_LOGIN_USER} \
|
||||
--password ${PODMAN_LOGIN_PASS} \
|
||||
$REGISTRY
|
||||
}
|
||||
|
||||
function teardown_suite(){
|
||||
# clear out the farms after the last farm test
|
||||
run_podman farm rm --all
|
||||
stop_registry
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user