Commit graph

140 commits

Author SHA1 Message Date
Debarshi Ray
08e40e666e test/system: Shorten the names of the tests and use consistent wording
Currently, some of the names of the tests were too long, and had
inconsistent and verbose wording.  This made it difficult to look at
them and get a gist of all the scenarios being tested.  The names are
like headings.  They shouldn't be too long, should capture the primary
objective of the test and be consistent in their wording.

https://github.com/containers/toolbox/pull/1276
2023-03-21 19:11:20 +01:00
Debarshi Ray
5b8a7a00c0 test/system: Use long options, instead of their shorter aliases
The long options are easier to grep(1) for in the sources than their
shorter aliases.

https://github.com/containers/toolbox/pull/1276
2023-03-21 19:11:13 +01:00
Debarshi Ray
f364812781 test/system: Shorten the names of the tests and use consistent wording
Currently, some of the names of the tests were too long, and had
inconsistent and verbose wording.  This made it difficult to look at
them and get a gist of all the scenarios being tested.  The names are
like headings.  They shouldn't be too long, should capture the primary
objective of the test and be consistent in their wording.

https://github.com/containers/toolbox/pull/1271
2023-03-20 18:28:10 +01:00
Debarshi Ray
edd82d7e6e test/system: Style fixes
Fallout from e5bab51bca

https://github.com/containers/toolbox/pull/1271
2023-03-20 18:28:07 +01:00
Debarshi Ray
c6760299d2 pkg/utils, test/system: Add some more tests for parsing RHEL releases
https://github.com/containers/toolbox/pull/1262
2023-03-16 22:01:45 +01:00
Debarshi Ray
e01927bfdc pkg/utils, test/system: Add some more tests for parsing Fedora releases
https://github.com/containers/toolbox/pull/1262
2023-03-16 22:01:45 +01:00
Debarshi Ray
a4cc791f39 test/system: Synchronize with the parseRelease() unit tests
https://github.com/containers/toolbox/pull/1266
2023-03-16 18:41:24 +01:00
Debarshi Ray
1bd6cf17ce test/system: Split the tests for parsing releases
This will make it easier to find out exactly which test failed.

https://github.com/containers/toolbox/pull/1266
2023-03-16 18:31:12 +01:00
Debarshi Ray
e5bab51bca test/system: Shorten the names of the tests and use consistent wording
Currently, some of the names of the tests were too long, and had
inconsistent and verbose wording.  This made it difficult to look at
them and get a gist of all the scenarios being tested.  The names are
like headings.  They shouldn't be too long, should capture the primary
objective of the test and be consistent in their wording.

https://github.com/containers/toolbox/pull/1265
2023-03-16 17:57:46 +01:00
Debarshi Ray
068d22a199 test/system: Use long options, instead of their shorter aliases
The long options are easier to grep(1) for in the sources than their
shorter aliases.

https://github.com/containers/toolbox/pull/1265
2023-03-16 17:37:16 +01:00
Debarshi Ray
052666840a Fix spelling mistakes
The noun is 'setup' and the verb is 'set up'.  Similarly 'lookup' and
'look up'.

Original patch from Erik Sjölund for Podman [1,2].

[1] Podman commit aa4279ae151fa9df
    https://github.com/containers/podman/commit/aa4279ae151fa9df
    https://github.com/containers/podman/pull/14658

[2] Podman commit 2827140907255ed0
    https://github.com/containers/podman/commit/2827140907255ed0
    https://github.com/containers/podman/pull/14659

https://github.com/containers/toolbox/pull/1223
2023-01-31 15:53:15 +01:00
Debarshi Ray
936a157117 doc, test/system: Fix the titles of the manuals
Currently, the titles of the manuals are rendered with a pair of empty
parentheses and no section title:
  toolbox(1)()                                              toolbox(1)()

  NAME
         toolbox - Tool for containerized command line environments...

However, they should be:
  toolbox(1)             General Commands Manual              toolbox(1)

  NAME
         toolbox - Tool for containerized command line environments...

This is because the troff generated by go-md2man from Markdown has a
faulty invocation of the .TH macro [1]:
  .nh
  .TH toolbox(1)
  .SH NAME
  .PP
  toolbox - Tool for containerized command line environments on Linux

It should be:
  .nh
  .TH toolbox 1
  .SH NAME
  .PP
  toolbox - Tool for containerized command line environments on Linux

Original patch from Andrew Denton for Podman [2].

[1] https://www.gnu.org/software/groff/manual/groff.html

[2] Podman commit 63c779a857b55b00
    https://github.com/containers/podman/pull/15621

https://github.com/containers/toolbox/pull/1210
2023-01-12 18:45:00 +01:00
Debarshi Ray
cac6b25f19 test/system: Tighten the regular expression used to detect the image ID
An OCI image's identifier (or ID) is a SHA-256 hash [1] whose length is
64 hexadecimal digits.  The ID can be abbreviated to a smaller number of
digits but the minimum is 6.  The regular expression being used to parse
the image ID wasn't checking the number of digits, and would even accept
an empty string as a valid ID, which was clearly wrong.

The format of a image reference is defined in:
https://github.com/moby/moby/blob/master/image/spec/v1.1.md
https://github.com/distribution/distribution/blob/main/reference/reference.go
https://github.com/distribution/distribution/blob/main/reference/regexp.go

Fallout from c6c2e426e0

[1] https://en.wikipedia.org/wiki/SHA-2

https://github.com/containers/toolbox/pull/1209
2023-01-12 14:44:05 +01:00
Debarshi Ray
65194bd45e test/system: Avoid false positives from codespell
Otherwise codespell would complain:
  : @test "create: Try to create a container with invalid custom name...
  >   run $TOOLBOX -y create "ßpeci@l.Nam€"
  :
  ./test/system/101-create.bats:57: Nam ==> Name

CentOS Stream 9 has codespell-2.2.1, while so far the 'unit tests' were
being run on Fedora 36, which only has codespell-2.1.0.

This is a step towards testing on CentOS Stream 9.

https://github.com/containers/toolbox/pull/1200
2022-12-14 23:09:21 +01:00
Debarshi Ray
5f5f7b6aab test/system: Fix spelling mistake using codespell
CentOS Stream 9 has codespell-2.2.1, while so far the 'unit tests' were
being run on Fedora 36, which only has codespell-2.1.0.

This is a step towards testing on CentOS Stream 9.

Fallout from ecd1ced719

https://github.com/containers/toolbox/pull/1200
2022-12-14 23:09:21 +01:00
Martin Krajnak
05a062f8c9 test/system: Ensure that copied images are clearly identified
Note that 'run --keep-empty-lines' counts the trailing newline on the
last line as a separate line.

Until Bats 1.7.0, 'run --keep-empty-lines' had a bug where even when a
command produced no output, it would report a line count of one [1] due
to a stray line feed character.  This needs to be conditionalized, since
Fedora 35 has Bats 1.5.0.

[1] https://github.com/bats-core/bats-core/issues/573

https://github.com/containers/toolbox/issues/1043
2022-12-12 21:49:21 +01:00
Debarshi Ray
6aab0a6175 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 2369da5d31,
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 2369da5d31, the ordering was correct, but copied
images would only show up once.

Fallout from 2369da5d31

This reverts parts of commit 67e210378e.

https://github.com/containers/toolbox/issues/1043
2022-12-12 21:49:21 +01:00
Debarshi Ray
51eccd3da5 test/system: Test 'rmi' with an image
https://github.com/containers/toolbox/pull/1195
2022-12-12 20:59:52 +01:00
Debarshi Ray
bbdf4ddb63 test/system: Test 'rmi' with an image and its copy
https://github.com/containers/toolbox/issues/1043
2022-12-12 20:59:52 +01:00
Martin Krajnak
d5daa7167e test/system: Add a helper to pull the default image and copy it
This will be used in subsequent commits to test the handling of such
copied images in 'toolbox list' and 'toolbox rmi'.

https://github.com/containers/toolbox/issues/1043
2022-12-12 20:59:47 +01:00
Debarshi Ray
a0d4c957b3 test/system: Test 'rmi' with an image without a name
https://github.com/containers/toolbox/pull/1195
2022-12-12 15:13:26 +01:00
Debarshi Ray
e25ab310fa test/system: Test 'rmi --all' with an image without a name
https://github.com/containers/toolbox/pull/1195
2022-12-12 15:13:26 +01:00
Debarshi Ray
8a37c08780 test/system: Test 'rmi --all' without any images
https://github.com/containers/toolbox/pull/1195
2022-12-12 15:13:26 +01:00
Debarshi Ray
210985ecd1 test/system: Ensure that error messages go to the standard error stream
Currently, there's no way to get assert_line to use the stderr_lines
array [1].  This is worked around by assigning stderr_lines to the
'lines' array.

[1] https://github.com/bats-core/bats-assert/issues/42

https://github.com/containers/toolbox/pull/1195
2022-12-12 15:13:26 +01:00
Debarshi Ray
26ed682cd1 test/system: Keep empty lines to prevent missing and spurious newlines
https://github.com/containers/toolbox/pull/1195
2022-12-12 15:13:26 +01:00
Debarshi Ray
303c7ae99a test/system: Don't ignore copies when counting images
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 the image ID is only showed once in 'podman images --quiet',
not twice.

A subsequent commit will use this to write tests to ensure that copied
images are correctly handled.

https://github.com/containers/toolbox/issues/1043
2022-12-12 15:04:42 +01:00
Debarshi Ray
5e8446971c test/system: Use long options, instead of their shorter aliases
The long options are easier to grep(1) for in the sources than their
shorter aliases.

https://github.com/containers/toolbox/pull/1197
2022-12-12 15:00:46 +01:00
Debarshi Ray
f17a632f9a test/system: Check the line count in the standard error & output streams
Note that 'run --keep-empty-lines' counts the trailing newline on the
last line as a separate line.

Until Bats 1.7.0, 'run --keep-empty-lines' had a bug where even when a
command produced no output, it would report a line count of one [1] due
to a stray line feed character.  This needs to be conditionalized, since
Fedora 35 has Bats 1.5.0.

[1] https://github.com/bats-core/bats-core/issues/573

https://github.com/containers/toolbox/pull/1192
2022-12-08 23:08:47 +01:00
Debarshi Ray
89385e12b5 test/system: Ensure that non-error messages go to the standard output
https://github.com/containers/toolbox/pull/1192
2022-12-08 22:33:35 +01:00
Debarshi Ray
4d1cc5b39b test/system: Test the order in 'list' for images with & without names
Note that 'run --keep-empty-lines' counts the trailing newline on the
last line as a separate line.

Until Bats 1.7.0, 'run --keep-empty-lines' had a bug where even when a
command produced no output, it would report a line count of one [1] due
to a stray line feed character.  This needs to be conditionalized, since
Fedora 35 has Bats 1.5.0.

[1] https://github.com/bats-core/bats-core/issues/573

https://github.com/containers/toolbox/pull/1192
2022-12-08 22:33:35 +01:00
Debarshi Ray
cc60bc6893 test/system: Split out the code to build an image without a name
This will be used by a subsequent commit to test the order in which
images with and without names are listed.

https://github.com/containers/toolbox/pull/1192
2022-12-08 22:33:35 +01:00
Debarshi Ray
54f09ae8a6 test/system: Group the test cases somewhat logically
A subsequent commit will test the order in which images with and without
names are listed.  It's logical for that test to come after the one
about the basic support for images without names.

https://github.com/containers/toolbox/pull/1192
2022-12-08 22:33:35 +01:00
Debarshi Ray
f0a805af84 test/system: Fix indentation
https://github.com/containers/toolbox/pull/1192
2022-12-08 22:33:35 +01:00
Debarshi Ray
0fde202d82 test/system: Keep empty lines to prevent missing and spurious newlines
The tests are intended for Toolbx, not Podman or other commands.  Hence,
it's only necessary to keep the empty lines for Toolbx invocations.
Being too sensitive about the exact output of other commands can lead to
spurious failures [1].

[1] Commit 259afdf815
    https://github.com/containers/toolbox/pull/846

https://github.com/containers/toolbox/pull/1192
2022-12-08 22:33:35 +01:00
Debarshi Ray
da1724c896 test/system: Test the order in 'list' for images and containers
https://github.com/containers/toolbox/pull/1192
2022-12-08 22:33:35 +01:00
Debarshi Ray
7375be82d0 test/system: Remove stray (possibly for debugging) 'podman images'
This was making it difficult to read the Bats assertions on test
failures, by polluting it with unexpected and irrelevant output from
'podman images'.  For example [1]:
  not ok 39 list: Images with and without names in 12332ms
  # (from function `assert' in file test/system/libs/bats-assert/src/assert.bash, line 46,
  #  in test file test/system/102-list.bats, line 126)
  #   `assert [ ${#stderr_lines[@]} -eq 0 ]' failed
  # REPOSITORY                                 TAG         IMAGE ID      CREATED      SIZE
  # registry.fedoraproject.org/fedora-toolbox  35          862705390e8b  4 weeks ago  332 MB
  # REPOSITORY                                 TAG         IMAGE ID      CREATED       SIZE
  # registry.fedoraproject.org/fedora-toolbox  35          862705390e8b  4 weeks ago   332 MB
  # registry.fedoraproject.org/fedora-toolbox  34          70cbe2ce60ca  7 months ago  354 MB
  #
  # -- assertion failed --
  # expression : [ 1 -eq 0 ]
  # --
  #

Fallout from 7973181136

[1] https://github.com/containers/toolbox/pull/1192

https://github.com/containers/toolbox/pull/1193
2022-12-08 00:32:12 +01:00
Debarshi Ray
aeb5d8ec1a test/system: Test a container with an old forward incompatible runtime
Commit ae43560d45 had added a test with a similar intention.  When
the test suite is run on a Fedora Rawhide host, it tests whether the
containers for the two previous stable Fedora releases start or not.
Fedora N-2 reaches End of Life 4 weeks after Fedora N is released [1].
So, testing the containers for Fedora Rawhide and the two previous
stable releases on a Fedora Rawhide host is a decent test of general
backwards compatibility.

However, as seen recently [2], this isn't enough to catch some known
ABI compatibility issues [3,4].  These involve toolbox binaries built
on hosts with newer toolchains that aren't meant to be run against
containers with older runtimes.  A targeted test is needed to defend
against these scenarios.

The fedora-toolbox:34 image has glibc-2.33, which is old enough to be
unable to run binaries compiled on Fedora 35 with glibc-2.34 and newer.

[1] https://docs.fedoraproject.org/en-US/releases/

[2] https://github.com/containers/toolbox/pull/1180

[3] Commit 6063eb27b9
    https://github.com/containers/toolbox/issues/821

[4] Commit 6ad9c63180
    https://github.com/containers/toolbox/issues/529

https://github.com/containers/toolbox/pull/1187
2022-12-07 13:03:09 +01:00
Debarshi Ray
7ab2f9b866 test/system: Replace fedora-toolbox:32 with fedora-toolbox:34
Fedora 32 reached End of Life on 25th May 2021:
https://docs.fedoraproject.org/en-US/releases/eol/

That's quite old because right now Fedora 35 is nearing its End of Life.

Since the tests are intended for Toolbx, not the Fedora infrastructure,
it will be better to use a newer image, because images that are too old
can get lost from registry.fedoraproject.org.  The fedora-toolbox:34
image can be a drop-in replacement for the fedora-toolbox:32 image for
the purposes of this test suite, and has the advantage of being newer.

Note that fedora-toolbox:34 is also old enough to test that the toolbox
binary runs against it's build-time ABI from the host, and not the
Toolbx container's ABI, when it's invoked as the entry point of the
container [1,2].  This is important because the subsequent commit will
add a test to ensure that.

[1] Commit 6063eb27b9
    https://github.com/containers/toolbox/issues/821

[2] Commit 6ad9c63180
    https://github.com/containers/toolbox/issues/529

https://github.com/containers/toolbox/pull/1187
2022-12-07 12:56:41 +01:00
Debarshi Ray
021053716e test/system: Add copyright and license notices
https://github.com/containers/toolbox/pull/1179
2022-11-29 13:54:13 +01:00
Nieves Montero
f2b7e440e1 Fix spelling mistakes using codespell
https://github.com/containers/toolbox/pull/1166
https://github.com/containers/toolbox/pull/1149

Signed-off-by: Nieves Montero <nmontero@redhat.com>
2022-11-17 11:56:58 +01:00
Debarshi Ray
1b85f711e4 test/system: Test 'completion'
https://github.com/containers/toolbox/pull/1165
2022-11-17 11:34:42 +01:00
Debarshi Ray
685f1f794d test/system: Be more strict when checking the version
https://github.com/containers/toolbox/pull/1165
2022-11-17 11:28:00 +01:00
Debarshi Ray
68d63bf09e test/system: Ensure that the right containers are run
https://github.com/containers/toolbox/pull/1163
2022-11-16 20:46:47 +01:00
Debarshi Ray
a61f88d7b2 test/system: Ensure that /run/.containerenv and /run/.toolboxenv exist
This is a precursor to verifying the names of the containers and
ensuring that the right ones are getting used.

https://github.com/containers/toolbox/pull/1163
2022-11-16 20:46:47 +01:00
Debarshi Ray
0000c68ee6 test/system: Ensure that 'toolbox run false' has exit code 1
This is a precursor to checking that higher valued exit codes from the
command running inside the container are retained, and commands like
test(1) can be used with 'toolbox run ...' in subsequent test cases.

https://github.com/containers/toolbox/pull/1163
2022-11-16 20:46:40 +01:00
Debarshi Ray
78683b38ae test/system: Use long options, instead of their shorter aliases
The long options are easier to grep(1) for in the sources than their
shorter aliases.

https://github.com/containers/toolbox/pull/1162
2022-11-16 19:56:24 +01:00
Debarshi Ray
220164b396 test/system: Shorten the names of the tests and use consistent wording
Currently, some of the names of the tests were too long, and had
inconsistent and verbose wording.  This made it difficult to look at
them and get a gist of all the scenarios being tested.  The names are
like headings.  They shouldn't be too long, should capture the primary
objective of the test and be consistent in their wording.

https://github.com/containers/toolbox/pull/1161
2022-11-16 19:49:56 +01:00
Debarshi Ray
8ec03ab85f test/system: Order the tests by increasing order of the exit code
This is another step towards making it easy to look at the file and get
a gist of all the scenarios being tested.

https://github.com/containers/toolbox/pull/1161
2022-11-16 13:41:43 +01:00
Debarshi Ray
485489867b test/system: Simplify the exit code checks by relying on Bats >= 1.5.0
Commit 978bb524e4 already added a dependency on Bats >= 1.5.0,
which is present in Fedora >= 35.  Therefore, it should be exploited
wherever possible to simplify things.

However, bats_require_minimum_version can't be used, because it's
only available from Bats 1.7.0 [1], which is new enough that it's absent
from Fedora 35.

[1] Bats commit 71d6b71cebc3d32b
    https://github.com/bats-core/bats-core/issues/556
    https://bats-core.readthedocs.io/en/stable/warnings/BW02.html

https://github.com/containers/toolbox/pull/1161
2022-11-16 13:41:39 +01:00
Debarshi Ray
80f9ac754d test/system: Remove redundant assertion
Fallout from 978bb524e4

https://github.com/containers/toolbox/pull/1161
2022-11-16 13:40:36 +01:00