mirror of https://github.com/containers/podman.git
Add e2e tests for farm build
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
This commit is contained in:
parent
dd8f57a3b4
commit
ebe01ca292
19
.cirrus.yml
19
.cirrus.yml
|
@ -910,6 +910,24 @@ minikube_test_task:
|
|||
main_script: *main
|
||||
always: *logs_artifacts
|
||||
|
||||
farm_test_task:
|
||||
name: *std_name_fmt
|
||||
alias: farm_test
|
||||
# Docs: ./contrib/cirrus/CIModes.md
|
||||
only_if: *not_tag_build_docs
|
||||
depends_on:
|
||||
- build
|
||||
- rootless_system_test
|
||||
gce_instance: *standardvm
|
||||
env:
|
||||
<<: *stdenvars
|
||||
TEST_FLAVOR: farm
|
||||
PRIV_NAME: rootless
|
||||
clone_script: *get_gosrc
|
||||
setup_script: *setup
|
||||
main_script: *main
|
||||
always: *logs_artifacts
|
||||
|
||||
buildah_bud_test_task:
|
||||
name: *std_name_fmt
|
||||
alias: buildah_bud_test
|
||||
|
@ -1054,6 +1072,7 @@ success_task:
|
|||
- rootless_system_test
|
||||
- rootless_remote_system_test
|
||||
- minikube_test
|
||||
- farm_test
|
||||
- buildah_bud_test
|
||||
- rootless_buildah_bud_test
|
||||
- upgrade_test
|
||||
|
|
|
@ -137,7 +137,11 @@ setup_rootless() {
|
|||
# shellcheck disable=SC2154
|
||||
if passwd --status $ROOTLESS_USER
|
||||
then
|
||||
if [[ $PRIV_NAME = "rootless" ]]; then
|
||||
# Farm tests utilize the rootless user to simulate a "remote" podman instance.
|
||||
# Root still needs to own the repo. clone and all things under `$GOPATH`. The
|
||||
# opposite is true for the lower-level podman e2e tests, the rootless user
|
||||
# runs them, and therefore needs permissions.
|
||||
if [[ $PRIV_NAME = "rootless" ]] && [[ "$TEST_FLAVOR" != "farm" ]]; then
|
||||
msg "Updating $ROOTLESS_USER user permissions on possibly changed libpod code"
|
||||
chown -R $ROOTLESS_USER:$ROOTLESS_USER "$GOPATH" "$GOSRC"
|
||||
return 0
|
||||
|
@ -184,6 +188,13 @@ setup_rootless() {
|
|||
# Maintain access-permission consistency with all other .ssh files.
|
||||
install -Z -m 700 -o $ROOTLESS_USER -g $ROOTLESS_USER \
|
||||
/root/.ssh/known_hosts /home/$ROOTLESS_USER/.ssh/known_hosts
|
||||
|
||||
if [[ -n "$ROOTLESS_USER" ]]; then
|
||||
showrun echo "conditional setup for ROOTLESS_USER [=$ROOTLESS_USER]"
|
||||
# Make all future CI scripts aware of these values
|
||||
echo "ROOTLESS_USER=$ROOTLESS_USER" >> /etc/ci_environment
|
||||
echo "ROOTLESS_UID=$ROOTLESS_UID" >> /etc/ci_environment
|
||||
fi
|
||||
}
|
||||
|
||||
install_test_configs() {
|
||||
|
|
|
@ -126,6 +126,12 @@ function _run_minikube() {
|
|||
showrun bats test/minikube |& logformatter
|
||||
}
|
||||
|
||||
function _run_farm() {
|
||||
_bail_if_test_can_be_skipped test/farm test/system
|
||||
msg "Testing podman farm."
|
||||
showrun bats test/farm |& logformatter
|
||||
}
|
||||
|
||||
exec_container() {
|
||||
local var_val
|
||||
local cmd
|
||||
|
|
|
@ -269,13 +269,6 @@ case "$PRIV_NAME" in
|
|||
*) die_unknown PRIV_NAME
|
||||
esac
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
if [[ -n "$ROOTLESS_USER" ]]; then
|
||||
showrun echo "conditional setup for ROOTLESS_USER [=$ROOTLESS_USER]"
|
||||
echo "ROOTLESS_USER=$ROOTLESS_USER" >> /etc/ci_environment
|
||||
echo "ROOTLESS_UID=$ROOTLESS_UID" >> /etc/ci_environment
|
||||
fi
|
||||
|
||||
# FIXME! experimental workaround for #16973, the "lookup cdn03.quay.io" flake.
|
||||
#
|
||||
# If you are reading this on or after April 2023:
|
||||
|
@ -403,6 +396,13 @@ case "$TEST_FLAVOR" in
|
|||
die "Invalid value for \$TEST_ENVIRON=$TEST_ENVIRON"
|
||||
fi
|
||||
|
||||
install_test_configs
|
||||
;;
|
||||
farm)
|
||||
showrun loginctl enable-linger $ROOTLESS_USER
|
||||
showrun ssh $ROOTLESS_USER@localhost systemctl --user enable --now podman.socket
|
||||
remove_packaged_podman_files
|
||||
showrun make install PREFIX=/usr ETCDIR=/etc
|
||||
install_test_configs
|
||||
;;
|
||||
minikube)
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
podmanRegistry "github.com/containers/podman/v4/hack/podman-registry-go"
|
||||
"github.com/containers/podman/v4/libpod/define"
|
||||
"github.com/containers/podman/v4/pkg/bindings"
|
||||
"github.com/containers/podman/v4/pkg/bindings/containers"
|
||||
"github.com/containers/podman/v4/pkg/bindings/images"
|
||||
|
@ -409,7 +410,8 @@ var _ = Describe("Podman images", func() {
|
|||
results, err := images.Build(bt.conn, []string{"fixture/Containerfile"}, entities.BuildOptions{})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(*results).To(MatchFields(IgnoreMissing, Fields{
|
||||
"ID": Not(BeEmpty()),
|
||||
"ID": Not(BeEmpty()),
|
||||
"SaveFormat": ContainSubstring(define.OCIArchive),
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/env bats
|
||||
#
|
||||
# Tests of podman farm commands
|
||||
#
|
||||
|
||||
load helpers.bash
|
||||
|
||||
###############################################################################
|
||||
# BEGIN tests
|
||||
|
||||
fname="test-farm"
|
||||
containerfile="test/farm/Containerfile"
|
||||
|
||||
@test "farm - check farm has been created" {
|
||||
run_podman farm ls
|
||||
assert "$output" =~ $fname
|
||||
assert "$output" =~ "test-node"
|
||||
}
|
||||
|
||||
@test "farm - build on local only" {
|
||||
iname="test-image-1"
|
||||
empty_farm="empty-farm"
|
||||
# create an empty farm
|
||||
run_podman farm create $empty_farm
|
||||
run_podman farm --farm $empty_farm build -f $containerfile -t $iname .
|
||||
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
|
||||
run_podman manifest inspect $iname
|
||||
assert "$output" =~ $ARCH
|
||||
}
|
||||
|
||||
@test "farm - build on farm node only with --cleanup" {
|
||||
iname="test-image-2"
|
||||
run_podman farm build -f $containerfile --cleanup --local=false -t $iname .
|
||||
assert "$output" =~ "Farm \"$fname\" ready"
|
||||
# get the system architecture
|
||||
run_podman info --format '{{.Host.Arch}}'
|
||||
ARCH=$output
|
||||
# inspect manifest list built and saved in dir
|
||||
manifest=$(cat $iname/manifest.json)
|
||||
assert "$manifest" =~ $ARCH
|
||||
# see if we can ssh into node to check the image was cleaned up
|
||||
nodeimg=$(ssh $ROOTLESS_USER@localhost podman images --filter dangling=true --noheading 2>&1)
|
||||
assert "$nodeimg" = ""
|
||||
# check that no image was built locally
|
||||
run_podman images --filter dangling=true --noheading
|
||||
assert "$output" = ""
|
||||
}
|
||||
|
||||
@test "farm - build on farm node and local" {
|
||||
iname="test-image-3"
|
||||
run_podman farm build -f $containerfile -t $iname .
|
||||
assert "$output" =~ "Farm \"$fname\" ready"
|
||||
# get the system architecture
|
||||
run_podman info --format '{{.Host.Arch}}'
|
||||
ARCH=$output
|
||||
# inspect manifest list built and saved in dir
|
||||
run_podman manifest inspect $iname
|
||||
assert "$output" =~ $ARCH
|
||||
}
|
||||
|
||||
# Test out podman-remote
|
||||
|
||||
@test "farm - build on farm node only (podman-remote)" {
|
||||
iname="test-image-4"
|
||||
run_podman --remote farm build -f $containerfile -t $iname .
|
||||
assert "$output" =~ "Farm \"$fname\" ready"
|
||||
# get the system architecture
|
||||
run_podman --remote info --format '{{.Host.Arch}}'
|
||||
ARCH=$output
|
||||
# inspect manifest list built and saved in dir
|
||||
manifest=$(cat $iname/manifest.json)
|
||||
assert "$manifest" =~ $ARCH
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
FROM alpine
|
||||
RUN arch | tee /arch.txt
|
||||
RUN date | tee /built.txt
|
|
@ -0,0 +1,11 @@
|
|||
# -*- bash -*-
|
||||
|
||||
load ../system/helpers.bash
|
||||
|
||||
function setup(){
|
||||
basic_setup
|
||||
}
|
||||
|
||||
function teardown(){
|
||||
basic_teardown
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
# -*- bash -*-
|
||||
|
||||
load helpers.bash
|
||||
|
||||
function setup_suite(){
|
||||
# only set up the podman farm before the first test
|
||||
run_podman system connection add --identity /home/$ROOTLESS_USER/.ssh/id_rsa test-node $ROOTLESS_USER@localhost
|
||||
run_podman farm create test-farm test-node
|
||||
}
|
||||
|
||||
function teardown(){
|
||||
# clear out the farms after the last farm test
|
||||
run podman farm rm --all
|
||||
}
|
Loading…
Reference in New Issue