53 Commits

Author SHA1 Message Date
6832a35f65 libpod: cleanup store at shutdown
shutdown the containers store so that the home directory mount is not
leaked when "podman system service" exits.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-07-15 11:41:28 +02:00
471e001c7f test/system: speed up podman --log-level recognizes log levels
Use podman version over podman info because info has to query a lot of
internal state, e.g. contianer and image count, so it is slower than a
simple info. This speeds the test up by about 600ms locally.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-06-04 16:24:00 +02:00
4e4c3e3dbf cmd: support --config option to locate authentication file
Let's support --config option by setting environment variable
DOCKER_CONFIG instead of ignoring it for docker compatibility, so
it could be used to locate config.json as authentication file.

Also add a test case for this change, remove the deprecated one.

Signed-off-by: Ming Liu <liu.ming50@gmail.com>
2024-01-10 09:31:43 +01:00
a10b88cb2f CI: test overlay and vfs
We're only testing vfs in CI. That's bad. #18822 tried to
remedy that but that only worked on system tests, not e2e.

Here we introduce CI_DESIRED_STORAGE, to be set in .cirrus.yml
in the same vein as all the other CI_DESIRED_X. Since it's 2023
we default to overlay, testing vfs only in priorfedora.

Fixes required:
 - e2e tests:
   - in cleanup, umount ROOT/overlay to avoid leaking mounts

 - system tests:
   - fix a few badly-written tests that assumed/hardcoded overlay
   - buildx test: add weird exception to device-number test
   - mount tests: add special case code for vfs
   - unprivileged test: disable one section that is N/A on vfs

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-11-17 05:48:50 -07:00
1c969219d4 systests: add [NNN] prefix in logs, NNN = filename
This is something I've long wanted in logs: an indicator of
which bats file the test lives in. As of v1.7.0 there is
now a way to do that, BATS_TEST_NAME_PREFIX. Use it. Logs
now look like:

     ok 14 [001] podman - shutdown engines
     ok 15 [005] podman info - basic test
     ...
     not ok 195 [065] podman cp - dot notation ....

(As a bonus, we can remove the super-long "test blah blah pasta"
duplication from 505.bats).

Also, removed no-longer-necessary (fingers crossed) debug code
for the recently fixed containers-storage umount/EINVAL flake.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-11-06 14:45:45 -07:00
8f17ac5c17 Merge pull request #19997 from cgiradkar/Issue_15588
Change priority for cli flags for remotely operating Podman
2023-09-20 14:53:35 +02:00
8c95aa4021 Change priority for cli-flags for remotely operating Podman
cli flags couldn't override the active-destination when env variables were set. As a remedy, the precedence of cli flags has been changed.

Signed-off-by: Chetan Giradkar <cgiradka@redhat.com>
2023-09-20 10:49:33 +01:00
ff07abea47 systests: tighter checks for unwanted warnings
Part of RUN-1906.

Followup to #19878 (check stderr in system tests): allow_warnings()
and require_warning() functions to make sure no unexpected messages
fall through the cracks.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-19 15:22:58 -06:00
c2575f726d sys tests: run_podman: check for unwanted warnings/errors
With few exceptions, commands that exit 0 should not emit any
messages with level=warning or =error. Let's start enforcing
that in run_podman.

Allow one-off exceptions, typically when we're testing an
actual warning condition (usual case: "podman stop" where it
times out to SIGKILL). Exceptions are specified via:

    run_podman 0+w subcommand...
               ^^^---- or, rarely, 0+e

"0" stands for "expect exit status 0", which is the default
so it's implicit anyway. The +w / +e (or even +we) is the
new part. I have added it to tests where necessary.

And, because life is what it is, add two global exceptions:

  - Debian. Because runc has too many flakes.
  - kube. Ditto. Kube commands emit lots of nasty error
    messages (yes, level=error) that don't seem to affect
    results.

Similar to #18442

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-07 05:35:21 -06:00
33891e8e96 System tests: add test tags
BATS 1.8.0 introduces tags: metadata that can be applied to
a single test or one entire file, then used for filtering
in a test run.

Issue #19299 introduces the possibility of using OpenQA
for podman reverse dependency testing: continuous CI on
all packages that can affect podman, so we don't go two
months with no bodhi builds then get caught by surprise
when systemd or kernel or crun change in ways that break us.

This PR introduces one bats tag, "distro-integration".
The intention is for OpenQA (or other) tests to install
the podman-tests package and run:

    bats --filter-tags distro-integration /usr/share/podman/test/system

Goal is to keep the test list short and sweet: we do not
need to test command-line option parsing. We *DO* need to
test interactions with systemd, kernel, nethack, and other
critical components.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-07-26 13:50:33 -06:00
dde6bcbca3 system tests: add and use _prefetch
Add new _prefetch helper for fetching and caching images.
Use it in a few places, most importantly 120-load.bats
where our teardown() now runs 'rmi -af'.

Reason: in #17911 we discovered that podman save + load do
not actually preserve the image: annotations and other metadata
are lost. This means that a test which runs after 120-load.bats
is operating on a different $IMAGE than a test which runs before.

This is not a problem except in very obscure corner cases, like
one fixed in #18542, but it seems irresponsible to just handwave
that issue away

The _prefetch function uses skopeo for fetching and saving
images, because skopeo preserves digests and metadata.

[Side note for posterity: I tried amending basic_setup() to
always rmi -a + prefetch, instead of the current images -a +
rmi unwanted ones. That slowed down system tests by 10 minutes,
presumably because loads are much slower than queries. I reverted
that change and am documenting it as a reminder of why we do things
the way we do.]

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-06-26 06:51:01 -06:00
bb2deef8e1 podman: added the --out option for capturing formatted output emitted by various commands
Commands like podman-create(1), podman-run(1), podman-inspect(1),
podman-ps(1) will emit formatted output upon success. This allows
the output from commands to be emitted directly to a file and
can supersede the --noout parameter by using /dev/null. An issue
with --noout was also remedied.

This closes issue #18120.

Signed-off-by: Ali Rizvi-Santiago <arizvisa@gmail.com>
2023-04-11 10:41:13 -05:00
e2d49fb650 CI: test and confirm DESIRED_DATABASE
Just like we do with RUNTIME and NETWORK. Skipped for now in
system tests because there's no way yet to actually set the
database backend.

Also, in system test oneliner (first test), include DB

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-03-16 15:32:56 -06:00
2d8225cd44 cobra: move engine shutdown to Execute
If the run errors, cobra does not execute post runs.  It is a somehow
known issue (https://github.com/spf13/cobra/issues/914) but problematic
for Podmand as the runtime is shutdown during post run.

Since some commands overwrite the post run and a general lack in cobra
of post runs on errors, move the shutting down the engines directly into
Execute.  Fixing the issue may fix a number of flakes.

Note that the shutdowns are NOPs for the remote client.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-01-10 13:30:41 +01:00
f17479c711 Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-28 15:13:43 -05:00
7c1ad8a582 Fix podman --noout to suppress all output
Podman --noout was not suppressing output from commands that do not
create the podman engine. Now, podman --noout properly suppresses output
from every command.

Fixes: https://github.com/containers/podman/issues/16201

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-11-15 08:16:46 -05:00
b3cf836841 test/system: Move network-related helpers to helpers.network.bash
The main helpers.bash file is rather bloated and it's difficult to
find stuff there. Move networking functions to their own helper
file.

While at it, apply a consistent style, and rearrange logically
related functions into sections.

Suggested-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2022-11-08 00:16:36 +01:00
496d4c7533 System tests: stop deep-checking log-level
I was testing --log-level by --storage-opt=mount_program=/bin/false

Stop doing that. It's just constantly breaking everything (#15698
and #15977).

I am violently of the opinion that a command-line option must
not destroy a user's system (except for --set-something, --config,
something that makes it very very clear that it is a lasting
change). I seem to be in the minority on this opinion. So, I
give up.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-09-28 09:30:23 -06:00
3508bd22fe Add support for podman context as alias to podman system connection
Alias
podman --context -> podman --connection
podman context use -> podman system connection default
podman context rm -> podman system connection rm
podman context create -> podman system connection add
podman context ls ->podman system connection ls
podman context inspect ->podman system connection ls --json (For
specified connections)

Podman context is a hidden command, but can be used for existing scripts
that assume Docker under the covers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-15 08:17:15 -04:00
e24c2f0099 system tests: periodic cleanup and fixes
- basic       : add actual log-level tests
- events      : clean up, add --format tests
- systemd     : reorder proxy args for legibility
- auto-update : fix missing timeout that could lead to hang

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-09-12 12:17:51 -06:00
1994f38232 Add --config for Docker compatibility
Fixes: https://github.com/containers/podman/issues/14767

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-08 16:20:30 -04:00
8d40bf3f14 proper --debug/-D flag support
--debug should not be a global flag, you can only use this as podman
--debug never podman ps --debug. This matches docker and allows us to
add the shorthand "D" since they now no longer conflict.

Fixes changes from commit 2d30b4dee596 which claims to add -D but never
did.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-07 14:50:23 +02:00
2d30b4dee5 Add compatibility support for --debug -D flag from docker
This is another fix for https://github.com/containers/podman/issues/14917

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-15 08:21:15 -04:00
c1f04a024a podman-remote pull: fix duplicate progress outputs
By vendoring the fixes from containers/image.  Also add a test (thanks
@edsantiago) to make sure we won't regress in the future again.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-07-21 10:04:45 +02:00
97ee411465 system tests: add assert(), and start using it
Problem: the system test 'is()' checker was poorly thought out.
For example, there is no way to check for inequality or for
absence of a substring.

Solution, step 1: introduce new assert(), copied almost verbatim
from buildah, where it has been successful in addressing the
gaps in is().

The logical next step is to search the tests for 'die' and
for 'run', looking for negative assertions which we can
replace with assert(). There were a lot, and in the process
I found a number of ugly bugs in the tests themselves. I've
taken the liberty of fixing these.

Important note: at this time we have both assert() and is().
Replacing all instances of is() would be impossible to review.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-04-20 16:14:42 -06:00
b3963e7081 Merge pull request #13296 from Romain-Geissler-1A/url-and-connection-implies-remote
Option --url and --connection should imply --remote.
2022-02-21 15:21:37 -05:00
c9359e1494 Merge pull request #13306 from Luap99/flag-error
provide better error on invalid flag
2022-02-21 15:11:37 -05:00
44d037898e provide better error on invalid flag
Add a extra `See 'podman command --help'` to the error output.
With this patch you now get:
```
$ podman run -h
Error: flag needs an argument: 'h' in -h
See 'podman run --help'
```

Fixes #13082
Fixes #13002

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-21 19:12:12 +01:00
f018c07edf System tests: show one-line config overview
We're running into problems that are impossible to diagnose
because we have no idea if the SUT is using netavark or CNI.
We've previously run into similar problems with runc/crun,
or cgroups 1/2.

This adds a one-line 'echo' with important system info. Now,
when viewing a full test log, it will be possible to view
system settings in one glance.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-02-21 08:49:11 -07:00
23a7f4e0de Option --url and --connection should imply --remote.
Closes #13242

Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
2022-02-19 14:53:37 +00:00
8f2358eeaa Add podman rm --depend
This option causes Podman to not only remove the specified containers
but all of the containers that depend on the specified
containers.
Fixes: https://github.com/containers/podman/issues/10360

Also ran codespell on the code

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-11 14:33:54 -05:00
7d22cc88ef Refactor podman system to report.Formatter
[NO NEW TESTS NEEDED]

Support better compatibility output for podman system commands

* Format and content of output from podman version changed to
  be more compatible

See #10974
Depends on containers/common#831

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-12-03 13:48:58 -07:00
abfec8144a Merge pull request #11953 from markusthoemmes/help-default
Display help text on empty subcommand by default
2021-11-08 18:23:17 +01:00
756dda298c Keep error semantics intact
Signed-off-by: Markus Thömmes <markusthoemmes@me.com>
2021-11-05 09:34:22 +01:00
960a55c09d system tests: CONTAINER_* and --help: cleanup
A small part of this test was written in a confusing and fragile
way: it was very hard to understand, and in fact only worked
through pure luck (using 'echo $output', which emitted everything
in one long line, vs the standard quoted 'echo "$output"' which
would've kept the formatting and caused the test to pass,
incorrectly, no matter whether --remote was in the output
or not). Plus, the '$?' check in the next line would never
trigger on failure anyway, so the failure message would've
been unhelpful if the test were ever to fail.

Anyhow. Make it readable and make it work.

(Followup to #11990)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-10-19 14:22:50 -06:00
468e7c689b Move CONTAINER_HOST and _CONNECTION to IsRemote Function
Current code does not check early enough.

Follow up to https://github.com/containers/podman/pull/11978

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-15 14:40:02 -04:00
4f857bc106 If CONTAINER_HOST env variable is set default podman --remote=true
Users enabling CONTAINER_HOST==PATH is indicating to podman they intend
to use remote functionality.

Fixes: https://github.com/containers/podman/issues/11196

Update man pages to document all of the environment variables.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-14 17:08:48 -04:00
184de3955c Adjust tests to verify all subcommands show the help message
Signed-off-by: Markus Thömmes <markusthoemmes@me.com>
2021-10-14 13:54:52 +02:00
bf94ebf423 System tests: tighten 'is' operator
Fix day-one sloppiness: when I first wrote this framework
it compared strings using 'expr', not '=', to be more
forgiving of extra cruft in output. This was a bad decision.
It means that warnings or additional text are ignored:

    is "all is ok, NOT!"  "all is ok"  <-- this would pass

Solution: tighten up the 'is' check. Use '=' (direct
compare) first. If it fails, look for wild cards ('*')
or character classes ('[') in the expect string. If
so, and only then, use 'expr'. And, thanks to a clever
suggestion from Luap99, include '(using expr)' in the
error message when we do so; this could make it easier
for a developer to understand a string mismatch.

This change exposes a lot of instances in which we weren't
doing proper comparisons. Fix those. Thankfully, there
weren't as many as I'd feared.

Also, and completely unrelated, add '-T' flag to bats
helper, for showing timing results. (I will open this
as a separate PR if requested. I too find it offensive
to jumble together unrelated commits.)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-09-30 13:32:51 -06:00
92ee2f372b remote untag: support digests
Fix a bug when remotely untagging an image via tag@digest.
The digest has been lost in the remote client and hence led
to a wrong behaviour on the server.

Fixes: #11557
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-09-20 15:06:37 +02:00
fb4a0c572e support tag@digest notation
Vendor in the latest HEAd of containers/common to implicitly support the
tag@digest notation for images.  To remain compatible with Docker, the
tag will be stripped off the image reference and is entirely ignored.

Fixes: #6721
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-31 14:38:43 +02:00
471f4898f0 Remove obsolete skips
The following bugs seem to be fixed:

* #6510 (e2e tests) - podman rmi gives "layer not known"

* #9915 (buildah-bud tests) - podman build --arch

* #10248 - spurious warning from first-ever invocation
  of rootless podman

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-05-10 07:43:35 -06:00
95a50a936a CI: run rootless tests under ubuntu
Reason: to catch errors before they surface in RHEL.

One of the Ubuntus is specially crafted to run with cgroups v1
and runc. Although this isn't quite the same as RHEL, it's as
close as we can come in our CI environment, and I suspect it
would have caught #10234 (a regression).

Sorry, team.

Also: play kube limits test: skip on all rootless, not just
rootless+fedora. There was a complicated and unnecessary
check in there for Fedora.

Also: workaround for bug #10248, a spurious error message on
the first invocation of rootless podman on Ubuntu.Old

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-05-06 08:40:11 -06:00
bc86c50cd8 Test that we don't error out on advertised --log-level values
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-14 14:16:09 -04:00
c6a21a38b3 Add support for podman --context default
This is a noop but helps with scripting and docker-compose.

Fixes: https://github.com/containers/podman/issues/9806

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-05 12:41:47 -04:00
b3f17936aa podman-remote does not support most of the global flags
podman-remote --help is showing a bunch of global flags that it
does not support

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-02 06:32:17 -04:00
ea71f613e6 Don't setup the Image/ContainerEngine when calling a cmd with subcmds
There is no need to setup the image and container engine when calling
a command with subcommands since we only print a usage message.
e.g `podman`,`podman container`

This also allows the remote client to show the usage message on
these commands without a running endpoint. I added a test for this.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-09-08 21:05:11 +02:00
d9f0c48176 fix podman version output to include git commit and builttime
Add the go module version v2 to the libpod path.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-08-18 20:37:18 +02:00
3c880a9b83 system tests: podman-remote, image tree
- new sanity checks for podman-remote:
  - first, confirm that when PODMAN is "-remote",
    we actually talk to a server (validated by
    presence of "Server:" string in "podman version").
  - second, add test for #7212, in which we run
    "podman --remote" (podman with --remote flag,
    not podman-remote command) and make sure --remote
    is allowed both as the first option and also
    with other flag options preceding.

- new test for "podman image tree" (piggybacking on
  top of a "podman build" test, because that gives
  us lots of layers).

- skip "podman exec - basic test" when remote. It is consistently
  causing CI failures, breaking all of CI, due to #7241.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-10 06:27:44 -06:00
7b188f7b5b podman version --format ... was not working
This patch fixes the podman --version --format command.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-21 16:31:34 -04:00