2020-07-27 13:35:17 +00:00
|
|
|
|
#!/usr/bin/env bats
|
2022-11-29 12:54:13 +00:00
|
|
|
|
#
|
2023-03-21 11:10:44 +00:00
|
|
|
|
# Copyright © 2019 – 2023 Red Hat, Inc.
|
2022-11-29 12:54:13 +00:00
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
#
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
load 'libs/bats-support/load'
|
|
|
|
|
load 'libs/bats-assert/load'
|
|
|
|
|
load 'libs/helpers'
|
|
|
|
|
|
|
|
|
|
setup() {
|
2023-03-21 16:12:48 +00:00
|
|
|
|
bats_require_minimum_version 1.7.0
|
2021-11-11 00:46:21 +00:00
|
|
|
|
_setup_environment
|
2020-07-27 13:35:17 +00:00
|
|
|
|
cleanup_all
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
|
cleanup_all
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-03-21 11:23:13 +00:00
|
|
|
|
@test "list: Smoke test" {
|
2023-03-21 15:33:09 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2023-03-21 15:33:09 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 0 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2020-07-27 13:35:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 11:23:13 +00:00
|
|
|
|
@test "list: Smoke test (using --containers)" {
|
2023-03-21 15:33:09 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --containers
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2023-03-21 15:33:09 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 0 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2020-07-27 13:35:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 11:23:13 +00:00
|
|
|
|
@test "list: Smoke test (using --images)" {
|
2023-03-21 15:33:09 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --images
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2023-03-21 15:33:09 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 0 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2020-07-27 13:35:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 11:23:13 +00:00
|
|
|
|
@test "list: With just one non-Toolbx image" {
|
2021-05-25 22:09:53 +00:00
|
|
|
|
pull_distro_image busybox
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
2023-03-21 18:50:22 +00:00
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
2023-03-21 15:33:09 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2023-03-21 15:33:09 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 0 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2020-07-27 13:35:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 17:02:12 +00:00
|
|
|
|
@test "list: With just one non-Toolbx image (using --images)" {
|
|
|
|
|
pull_distro_image busybox
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert [ ${#lines[@]} -eq 0 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 17:26:11 +00:00
|
|
|
|
@test "list: Default image" {
|
|
|
|
|
local default_image
|
|
|
|
|
default_image="$(get_default_image)"
|
|
|
|
|
|
|
|
|
|
pull_default_image
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "$default_image"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: Default image (using --images)" {
|
|
|
|
|
local default_image
|
|
|
|
|
default_image="$(get_default_image)"
|
|
|
|
|
|
|
|
|
|
pull_default_image
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "$default_image"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-22 07:37:30 +00:00
|
|
|
|
@test "list: Fedora 34 image" {
|
|
|
|
|
pull_distro_image fedora 34
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "registry.fedoraproject.org/fedora-toolbox:34"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: Fedora 34 image (using --images)" {
|
|
|
|
|
pull_distro_image fedora 34
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "registry.fedoraproject.org/fedora-toolbox:34"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-22 07:58:12 +00:00
|
|
|
|
@test "list: RHEL 8.7 image" {
|
|
|
|
|
pull_distro_image rhel 8.7
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "registry.access.redhat.com/ubi8/toolbox:8.7"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: RHEL 8.7 image (using --images)" {
|
|
|
|
|
pull_distro_image rhel 8.7
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "registry.access.redhat.com/ubi8/toolbox:8.7"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-15 15:08:24 +00:00
|
|
|
|
@test "list: Ubuntu 16.04 image" {
|
|
|
|
|
pull_distro_image ubuntu 16.04
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "quay.io/toolbx-images/ubuntu-toolbox:16.04"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: Ubuntu 16.04 image (using --images)" {
|
|
|
|
|
pull_distro_image ubuntu 16.04
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "quay.io/toolbx-images/ubuntu-toolbox:16.04"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: Ubuntu 18.04 image" {
|
|
|
|
|
pull_distro_image ubuntu 18.04
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "quay.io/toolbx-images/ubuntu-toolbox:18.04"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: Ubuntu 18.04 image (using --images)" {
|
|
|
|
|
pull_distro_image ubuntu 18.04
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "quay.io/toolbx-images/ubuntu-toolbox:18.04"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: Ubuntu 20.04 image" {
|
|
|
|
|
pull_distro_image ubuntu 20.04
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "quay.io/toolbx-images/ubuntu-toolbox:20.04"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: Ubuntu 20.04 image (using --images)" {
|
|
|
|
|
pull_distro_image ubuntu 20.04
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "quay.io/toolbx-images/ubuntu-toolbox:20.04"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 11:23:13 +00:00
|
|
|
|
@test "list: An image without a name" {
|
2022-12-09 10:02:28 +00:00
|
|
|
|
build_image_without_name >/dev/null
|
2022-12-07 18:21:31 +00:00
|
|
|
|
|
2023-03-22 09:22:15 +00:00
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
2022-12-07 20:02:17 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list
|
2022-12-07 18:21:31 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "<none>"
|
2022-12-07 20:16:46 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
2023-03-21 16:12:48 +00:00
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2022-12-07 18:21:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 17:02:12 +00:00
|
|
|
|
@test "list: An image without a name (using --images)" {
|
|
|
|
|
build_image_without_name >/dev/null
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "<none>"
|
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 22:12:53 +00:00
|
|
|
|
@test "list: Image and its copy" {
|
|
|
|
|
local default_image
|
|
|
|
|
default_image="$(get_default_image)"
|
|
|
|
|
|
|
|
|
|
pull_default_image_and_copy
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 2
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "$default_image"
|
|
|
|
|
assert_line --index 2 --partial "$default_image-copy"
|
|
|
|
|
assert [ ${#lines[@]} -eq 4 ]
|
2023-03-21 16:12:48 +00:00
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2022-12-07 22:12:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 17:02:12 +00:00
|
|
|
|
@test "list: Image and its copy (using --images)" {
|
|
|
|
|
local default_image
|
|
|
|
|
default_image="$(get_default_image)"
|
|
|
|
|
|
|
|
|
|
pull_default_image_and_copy
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 2
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "$default_image"
|
|
|
|
|
assert_line --index 2 --partial "$default_image-copy"
|
|
|
|
|
assert [ ${#lines[@]} -eq 4 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 11:23:13 +00:00
|
|
|
|
@test "list: Containers and images" {
|
2023-03-22 08:08:46 +00:00
|
|
|
|
local default_image
|
|
|
|
|
default_image="$(get_default_image)"
|
|
|
|
|
|
2023-03-22 09:06:08 +00:00
|
|
|
|
local default_container
|
|
|
|
|
default_container="$(get_system_id)-toolbox-$(get_system_version)"
|
|
|
|
|
|
2020-07-27 13:35:17 +00:00
|
|
|
|
# Pull the two images
|
|
|
|
|
pull_default_image
|
2022-12-05 19:54:51 +00:00
|
|
|
|
pull_distro_image fedora 34
|
2021-05-25 22:09:53 +00:00
|
|
|
|
|
2023-03-22 09:22:15 +00:00
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 2
|
|
|
|
|
|
2021-05-25 22:09:53 +00:00
|
|
|
|
# Create three containers
|
2020-07-27 13:35:17 +00:00
|
|
|
|
create_default_container
|
|
|
|
|
create_container non-default-one
|
|
|
|
|
create_container non-default-two
|
|
|
|
|
|
|
|
|
|
# Check images
|
2022-12-07 20:02:17 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --images
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2023-03-22 08:08:46 +00:00
|
|
|
|
assert_line --index 1 --partial "registry.fedoraproject.org/fedora-toolbox:34"
|
|
|
|
|
assert_line --index 2 --partial "$default_image"
|
2022-12-07 20:16:46 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 4 ]
|
2023-03-21 16:12:48 +00:00
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
# Check containers
|
2022-12-07 20:02:17 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --containers
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2023-03-22 09:06:08 +00:00
|
|
|
|
assert_line --index 1 --partial "$default_container"
|
2022-12-07 12:34:38 +00:00
|
|
|
|
assert_line --index 2 --partial "non-default-one"
|
|
|
|
|
assert_line --index 3 --partial "non-default-two"
|
2022-12-07 20:16:46 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 5 ]
|
2023-03-21 16:12:48 +00:00
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
# Check all together
|
2022-12-07 20:02:17 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2023-03-22 08:08:46 +00:00
|
|
|
|
assert_line --index 1 --partial "registry.fedoraproject.org/fedora-toolbox:34"
|
|
|
|
|
assert_line --index 2 --partial "$default_image"
|
2023-03-22 09:06:08 +00:00
|
|
|
|
assert_line --index 5 --partial "$default_container"
|
2022-12-07 14:22:04 +00:00
|
|
|
|
assert_line --index 6 --partial "non-default-one"
|
|
|
|
|
assert_line --index 7 --partial "non-default-two"
|
2022-12-07 20:16:46 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 9 ]
|
2023-03-21 16:12:48 +00:00
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2020-07-27 13:35:17 +00:00
|
|
|
|
}
|
2022-12-07 18:52:50 +00:00
|
|
|
|
|
2023-03-21 17:02:12 +00:00
|
|
|
|
@test "list: Images with and without names" {
|
|
|
|
|
local default_image
|
|
|
|
|
default_image="$(get_default_image)"
|
|
|
|
|
|
|
|
|
|
pull_default_image
|
|
|
|
|
pull_distro_image fedora 34
|
|
|
|
|
build_image_without_name >/dev/null
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 3
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "<none>"
|
2023-03-22 08:08:46 +00:00
|
|
|
|
assert_line --index 2 --partial "registry.fedoraproject.org/fedora-toolbox:34"
|
2023-03-21 17:02:12 +00:00
|
|
|
|
assert_line --index 3 --partial "$default_image"
|
|
|
|
|
assert [ ${#lines[@]} -eq 5 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 17:17:06 +00:00
|
|
|
|
@test "list: Images with and without names (using --images)" {
|
2022-12-07 18:52:50 +00:00
|
|
|
|
local default_image
|
|
|
|
|
default_image="$(get_default_image)"
|
|
|
|
|
|
|
|
|
|
pull_default_image
|
|
|
|
|
pull_distro_image fedora 34
|
2022-12-09 10:02:28 +00:00
|
|
|
|
build_image_without_name >/dev/null
|
2022-12-07 18:52:50 +00:00
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "<none>"
|
2023-03-22 08:08:46 +00:00
|
|
|
|
assert_line --index 2 --partial "registry.fedoraproject.org/fedora-toolbox:34"
|
Unbreak sorting and clearly identify copied images in 'list'
Currently, if an image was copied with:
$ skopeo copy \
containers-storage:registry.fedoraproject.org/fedora-toolbox:36 \
containers-storage:localhost/fedora-toolbox:36
... or:
$ podman tag \
registry.fedoraproject.org/fedora-toolbox:36 \
localhost/fedora-toolbox:36
... then it would show up twice in 'list' with the same name, and in the
wrong order.
Either as:
$ toolbox list --images
IMAGE ID IMAGE NAME CREATED
2110dbbc33d2 localhost/fedora-toolbox:36 1 day...
e085805ade4a registry.access.redhat.com/ubi8/toolbox:latest 1 day...
2110dbbc33d2 localhost/fedora-toolbox:36 1 day...
70cbe2ce60ca registry.fedoraproject.org/fedora-toolbox:34 1 day...
... or as:
$ toolbox list --images
IMAGE ID IMAGE NAME CREATED
2110dbbc33d2 registry.fedoraproject.org/fedora-toolbox:36 1 day...
e085805ade4a registry.access.redhat.com/ubi8/toolbox:latest 1 day...
2110dbbc33d2 registry.fedoraproject.org/fedora-toolbox:36 1 day...
70cbe2ce60ca registry.fedoraproject.org/fedora-toolbox:34 1 day...
The correct output should be similar to 'podman images', and be sorted
in ascending order of the names:
$ toolbox list --images
IMAGE ID IMAGE NAME CREATED
2110dbbc33d2 localhost/fedora-toolbox:36 1 day...
e085805ade4a registry.access.redhat.com/ubi8/toolbox:latest 1 day...
70cbe2ce60ca registry.fedoraproject.org/fedora-toolbox:34 1 day...
2110dbbc33d2 registry.fedoraproject.org/fedora-toolbox:36 1 day...
The problem is that, in these situations, 'podman images --format json'
returns separate identical JSON collections for each copy of the image,
and all of those copies have multiple names:
[
{
"Id": "2110dbbc33d2",
...
"Names": [
"localhost/fedora-toolbox:36",
"registry.fedoraproject.org/fedora-toolbox:36"
],
...
},
{
"Id": "e085805ade4a",
...
"Names": [
"registry.access.redhat.com/ubi8/toolbox:latest"
],
...
},
{
"Id": "2110dbbc33d2",
...
"Names": [
"localhost/fedora-toolbox:36",
"registry.fedoraproject.org/fedora-toolbox:36"
],
...
}
{
"Id": "70cbe2ce60ca",
...
"Names": [
"registry.fedoraproject.org/fedora-toolbox:34"
],
...
},
]
The image objects need to be flattened to have only one unique name per
copy, but with the same ID, and then sorted to ensure the right order.
Note that the ordering was already broken since commit 2369da5d31830e5c,
which started using 'podman images --sort repository'. Podman can sort
by either the image's repository or tag, but not by the unified name,
which is what Toolbx needs. Therefore, even without copied images,
Toolbx really does need to sort the images itself.
Prior to commit 2369da5d31830e5c, the ordering was correct, but copied
images would only show up once.
Fallout from 2369da5d31830e5cd3e1a13857a686365875ae61
This reverts parts of commit 67e210378e7b43cc0847cd171209861862f225b0.
https://github.com/containers/toolbox/issues/1043
2022-12-06 17:15:15 +00:00
|
|
|
|
assert_line --index 3 --partial "$default_image"
|
2022-12-07 18:52:50 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 5 ]
|
2023-03-21 16:12:48 +00:00
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
2022-12-07 18:52:50 +00:00
|
|
|
|
}
|
2023-03-22 10:00:47 +00:00
|
|
|
|
|
|
|
|
|
@test "list: With just one non-Toolbx container and one non-Toolbx image" {
|
|
|
|
|
local busybox_image
|
|
|
|
|
busybox_image="$(get_busybox_image)"
|
|
|
|
|
|
|
|
|
|
pull_distro_image busybox
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
$PODMAN create --name busybox-container "$busybox_image"
|
|
|
|
|
|
|
|
|
|
local num_of_containers
|
|
|
|
|
num_of_containers="$(list_containers)"
|
|
|
|
|
assert_equal "$num_of_containers" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert [ ${#lines[@]} -eq 0 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: With just one non-Toolbx container and one non-Toolbx image (using --containers)" {
|
|
|
|
|
local busybox_image
|
|
|
|
|
busybox_image="$(get_busybox_image)"
|
|
|
|
|
|
|
|
|
|
pull_distro_image busybox
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
$PODMAN create --name busybox-container "$busybox_image"
|
|
|
|
|
|
|
|
|
|
local num_of_containers
|
|
|
|
|
num_of_containers="$(list_containers)"
|
|
|
|
|
assert_equal "$num_of_containers" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --containers
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert [ ${#lines[@]} -eq 0 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "list: With just one non-Toolbx container and one non-Toolbx image (using --images)" {
|
|
|
|
|
local busybox_image
|
|
|
|
|
busybox_image="$(get_busybox_image)"
|
|
|
|
|
|
|
|
|
|
pull_distro_image busybox
|
|
|
|
|
|
|
|
|
|
local num_of_images
|
|
|
|
|
num_of_images="$(list_images)"
|
|
|
|
|
assert_equal "$num_of_images" 1
|
|
|
|
|
|
|
|
|
|
$PODMAN create --name busybox-container "$busybox_image"
|
|
|
|
|
|
|
|
|
|
local num_of_containers
|
|
|
|
|
num_of_containers="$(list_containers)"
|
|
|
|
|
assert_equal "$num_of_containers" 1
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert [ ${#lines[@]} -eq 0 ]
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
}
|