Commit Graph

198 Commits

Author SHA1 Message Date
Paul Holzinger 74454bf59c
rework system connection and farm storage
We now no longer write containers.conf, instead system connections and
farms are written to a new file called podman-connections.conf.

This is a major rework and I had to change a lot of things to get this
to compile again with my c/common changes.

It is a breaking change for users as connections/farms added before this
commit can now no longer be removed or modified directly. However because
the logic keeps reading from containers.conf the old connections can
still be used to connect to a remote host.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-01-31 15:08:41 +01:00
Philip Dubé 522934d5cf Replace strings.SplitN with strings.Cut
Cut is a cleaner & more performant api relative to SplitN(_, _, 2) added in go 1.18

Previously applied this refactoring to buildah:
https://github.com/containers/buildah/pull/5239

Signed-off-by: Philip Dubé <philip@peerdb.io>
2024-01-11 13:50:15 +00:00
Oleksandr Redko 8bdf77aa20 Refactor: replace StringInSlice with slices.Contains
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 16:25:56 +02:00
Tsubasa Watanabe ec5422af5b e2e: Skip journalctl if journald is unavailable
Test "podman start container by systemd" is failed on the system in
which rootless users don't have accessibility to journald. Therefore,
skip the part that reads journal with journalctl.

Signed-off-by: Tsubasa Watanabe <w.tsubasa@fujitsu.com>
2023-12-31 15:27:53 +09:00
Ed Santiago 1c59a9ced1 CI: safer podman-stop tests
A number of tests start a container then immediately run podman stop.
This frequently flakes with:

   StopSignal SIGTERM failed to stop [...] in 10 seconds, resorting to SIGKILL

Likely reason: container is still initializing, and its process
has not yet set up its signal handlers.

Solution: if possible (containers running "top"), wait for "Mem:"
to indicate that top is running. If not possible (pods / catatonit),
sleep half a second.

Intended to fix some of the flakes cataloged in #20196 but I'm
leaving that open in case we see more. These are hard to identify
just by looking in the code.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-12-14 04:49:46 -07:00
Ed Santiago 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
Ed Santiago 2a17baa29d CI: default to sqlite
Followup to #20318: now that sqlite is the podman default,
enforce that in CI as well. Test boltdb only in Prior Fedora.

In the process, discovered & cleaned up some duplication
and unused YAML anchors.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-11-02 13:17:21 -06:00
Ed Santiago c841fa9e9a CI: e2e: safer GetPort()
Problem: frequent CI flakes of the form:

   Error: cannot listen on the TCP port: listen tcp4 :5355: bind: address already in use

Always 5355.

Cause: systemd-resolve listens on 5355, but not on 127.0.0.1. So
when GetPort() tries its is-it-in-use check by binding localhost,
it succeeds; but then podman binds * and fails.

Solution: GetPort(): test by binding 0.0.0.0.

Also, improve the failure message.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-10-26 05:52:02 -06:00
Ed Santiago c3ba0221ec ginkgo setup: retry cache pulls
Because all registries flake.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-10-23 19:29:18 -06:00
Paul Holzinger 29273cda10
lint: fix warnings found by perfsprint
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-20 16:27:46 +02:00
Paul Holzinger 0b5ea1e6ec
test/e2e: default to netavark
When you run e2e tests locally they use CNI unless the NETWORK_BACKEND
env was set to netavark. Because our main focus is on netavark we should
test it by default.

For local tests this should help to prevent CNI/netavark conflicts as I
assume most systems where people run tests on are on netavark by now.

For  CI testing we hardcode NETWORK_BACKEND there to test both netavark
(on current fedora) and CNI (prior fedora). MAke sure to switch the
logic in the CI setup to reflect that.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-27 13:30:20 +02:00
Ed Santiago e4b7455b72 e2e: ExitCleanly(): manual fixes to get tests working
Commit 2 of 2: fixes to get tests passing

Mostly reverting back to Exit(0) on tests that produce stderr,
adding stderr checks when those are missing.

One pretty big exception: "run check dns" test was completely
broken in many respects. It should never have worked under CNI,
but was passing because nslookup in that alpine image was
checking /etc/hosts. This has been fixed in subsequent alpine
images, which we're now using in this test (CITEST_IMAGE).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-26 08:47:16 -06:00
Anders F Björklund 336055fe3b Use url with scheme and path for the unix address
Shortcuts like unix:path and unix:/path do not work everywhere,
so make sure to use unix://path when quoting the url (or address)

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2023-09-11 07:55:12 +02:00
Chris Evich c193dbd942
Require a non-generic reason for non-Fedora skip
Signed-off-by: Chris Evich <cevich@redhat.com>
2023-08-08 14:34:24 -04:00
Hari Kannan 413552e10e quadlet recursively scan for unit files
Signed-off-by: Hari Kannan <harikannan512@gmail.com>
2023-07-20 23:10:28 +01:00
Daniel J Walsh 0dcfe6e069
Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-11 16:44:22 -04:00
Paul Holzinger 97fd03ccdf
test/e2e: wait for socket
Do not use podman info/version as they are expensive and clutter the log
for no reason. Just checking if we can connect to the socket should be
good enough and much faster.

Fix the non existing error checking, so that we actually see an useful
error when this does not work.

Also change the interval, why wait 2s for a retry lets take 100ms steps
instead.

Fixes #19010

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-10 17:27:11 +02:00
Paul Holzinger ea8992cb45
test/e2e: use random ImageCacheDir
Like LockTmpDir use a random tmpdir for this directory. Make sure it is
set for all parallel ginkgo processes.

Also GinkgoT().TempDir() will automatcially remove the directory at the
end so we do not need to worry about cleanup.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-05 10:40:24 +02:00
Paul Holzinger 17a06d3431
test/e2e: remove RHEL7 workaround
AFAIK the latest podman will not even run on RHEL 7 anymore, in any case
we do not need these tests to run there.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-05 10:39:57 +02:00
Paul Holzinger bc22aefce6
test/e2e: remove unnecessary code in SynchronizedAfterSuite
This code does not do anything useful beside removing the cache dir.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-05 10:39:46 +02:00
Paul Holzinger ff77900387
test/e2e: do not use /tmp for podman commands
Using the OS tempdir here is not good. This defaults to /tmp which means
the inital podman test setup uses these paths:
`--root /tmp/root --runroot /tmp/runroot and --tmpdir /tmp`

Thus we create many files directly under /tmp. Also they were never
removed thus leaked out. When running as root and then later as rooltess
this would fail to permission problems.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-05 10:39:02 +02:00
Paul Holzinger c20612babc
test/e2e: write timings directly to file
There is no need to buffer them all into an array then write them once
at the end. Just write directly to the file.

Fixes #19104

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-05 10:12:43 +02:00
Ed Santiago 26721b0a06 GetSafeIPAddress(): discourage its use
Add header comment suggesting podman network create instead.

Stop using it in checkpoint tests. Turned out to be much more
complicated than expected.

Also, fix two issues caught while scanning the code:
 - remove obsolete f28-and-earlier code.
 - remove seccomp workaround needed for RHEL7

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-06-21 07:47:00 -06:00
Ed Santiago ef42f54aca e2e: GetSafeIPAddress() replaces GetRandomIPAddress
For tests that use '--ip XX', random IP allocation is not
working well. Switch instead to a deterministic algorithm
with CPU affinity and a fudge factor for CNI.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-06-15 11:06:40 -06:00
Ed Santiago 837b472441 e2e: GetRandomIPAddress(): parallelize
Fixes: #18855

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-06-12 12:42:59 -06:00
OpenShift Merge Robot 3cae574ab2
Merge pull request #18507 from mheon/fix_rm_depends
Fix `podman rm -fa` with dependencies
2023-06-12 13:27:34 -04:00
Ed Santiago 137c8ef4d5 logformatter: better recognition of ginkgo test names
Ginkgo test names can have more than two levels: there can be
a nested series of Describes() before the final It(). (e.g.,
quadlet_test.go). Handle that.

Before: we just assumed that the third-or-maybe-fourth line
after a "-----" divider was the test name.

Now: examine every line after the "-----" divider, until the
first empty line. Lines with /path/to/source/file are ignored,
lines with text strings are assembled together to make anchors.
This is still imperfect but it's much better than before.

SPECIAL NOTE: in order to allow linking to timing results
in the AfterSuite, I've changed the test name from Leaf to Full.
This will now be a much longer string, and hence much less
readable, but I'm inclined to think it's more correct. Please
review carefully and lmk if I should revert.

Finally, as an unrelated add-on, add links (at top) to original
log, journal, and (if applicable) podman-remote server logs.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-06-06 14:32:15 -06:00
Ed Santiago 28934897e3 e2e: GetPort(): safer allocation of random ports
Intented to fix an obscure, unlikely race condition in which (I
think) two parallel jobs called GetPort() and were assigned the
same port.

Also, add actual proper testing to two HTTP-registry tests, and
Skip a third that's a waste of cycles (filed #18768)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-06-01 16:04:34 -06:00
Matthew Heon bafb3d6cc5 Revert "ginkgo-v2 cleanup workaround for #18180"
This reverts commit c4b9f4b34e.

This was a temporary workaround until a fix for #18180 landed.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2023-06-01 16:27:27 -04:00
Ed Santiago 88e78456db e2e: make BuildImage parallel-safe
"image rm concurrent" test is still failing, even after #18664:

    Error: no contents in "/tmp/podman_test967723851/Dockerfile"

Probable cause: the images are built in parallel, and p.BuildImage()
writes one single Dockerfile. (This almost certainly renders the
test less effective than intended, since the generated images
might end up being identical).

Solution: write and use a uniquely-named Dockerfile

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-05-30 08:16:26 -06:00
Gunjan Vyas 5f29c7bf98 fix: podman event --filter volume=vol-name should compare the event name with volume name
Fixes: https://github.com/containers/podman/issues/18618

Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
2023-05-22 19:11:15 +05:30
Paul Holzinger ab29ff2f66
test/e2e: dedup Before/AfterEach nodes
There is no reason to define the same code every time in each file, just
use global nodes. This diff should speak for itself.

CleanupSecrets()/Volume() no longer call Cleanup() directly, as the
global AfterEach node will always call Cleanup() this is no longer
necessary. If one AfterEach() node fails it will still run the others.

Also always unset the CONTAINERS_CONF env vars. This prevents people
from forgetting to unset it. And fix the special CONTAINERS_CONF logic
in the system connection tests, we do not want to preserve
CONTAINERS_CONF anyway so just remove this logic.

Ginkgo orders the BeforeEach and AfterEach nodes. They will be executed
from the outer-most defined to inner-most. This means our global
BeforeEach is always first. Only then the inner one (in the Describe()
function in each file). For AfterEach it is inverted, from the inner to
the outer.
Also see https://onsi.github.io/ginkgo/#organizing-specs-with-container-nodes

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-15 16:56:18 +02:00
Paul Holzinger c4b9f4b34e
ginkgo-v2 cleanup workaround for #18180
Add a workaround for #18180 so the ginkgo work can be merged without
being blocked by the issue. Please revert this commit when the issue
is fixed.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:40 +02:00
Paul Holzinger 5eb99a0ac8
test/e2e: fix custom timing reporting
This never worked when ginkgo runs with more than one thread, we use 3
in CI. The problem is that the SynchronizedAfterSuite() function accepts
two functions. The first one is run for each ginkgo node while the
second one is only run once for the whole suite.

Because the timings are stored as slice thus in memory we loose all
timings from the other nodes as they were only reported on node 1.
Moving the printing in the first function solves this but causes the
problem that the result is now no longer sorted. To fix this we let
each node write the result to a tmp file and only then let the final
after suite function collect the timings from all these files, then
sort them and print the output like we did before.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:40 +02:00
Paul Holzinger c5922cc6f0
test/e2e: fix CleanupVolume/Secrets()
Just like Cleanup() they should check the error codes.
While doing this it was clear that some volume tests were calling
Cleanup() twice so remove this.

Instead make sure they call Cleanup() themselves so callers only need to
do one call. This is required because we cannot use Expect().To() before
doing all the cleanup. An error causes panic does results in an early
return thus missing potentially important cleanup.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:39 +02:00
Paul Holzinger bc1ed07b56
ginkgo v2: fix new Skip() behavior
It looks like AfterEach() is now executed even after Skip(), this is a
good idea because the fact that it did't before caused us to leak tmp
directories. However in case Skip() is called before the podmanTest is
initialized it will no result in a panic. To fix it simply prevent such
panic by checking the pointer against nil and do nothing in such case.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:39 +02:00
Paul Holzinger fb7a96638c
test/e2e: switch to GinkgoWriter
Directly writing to stdout/err is not safe when run in parallel.
Ginkgo v2 fixed this buffering the output and syncing the output so it
is not mangled between tests.

This means we should use the GinkgoWriter everywhere to make sure the
output stays in sync.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:38 +02:00
Paul Holzinger 9c1f713c75
test/e2e: fix Cleanup()
Only check exit codes last, othwerwise in case of errors it will return
early and miss other commands.
Also explicitly stop before rm, rm is not working in all cases (#18180).

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:37 +02:00
Paul Holzinger 629a6a6e45
test/e2e: actually check for cleanup errors
We blindy trust these commands to work but as it turns out they do not
under certain circumstances.

The "podman run ipcns ipcmk container test" can be used to fail this
reliably, if a container has dependencies the order of rm --all may
cause it to fail because the contianers are deleted in the wrong order.
This is th eonly one I found so far, adding this will uncover many more
of such problems without proper cleanup we leak processes and ginkgo v2
will block because of them.

Of course this cannot be merged without fixing these issues.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:36 +02:00
Paul Holzinger c564d9d7af
ginkgo v2: remove CurrentGinkgoTestDescription()
This function is deprecated and replaced with CurrentSpecReport().
Also fix inconsitent callers.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:36 +02:00
Paul Holzinger 445815036f
update to ginkgo v2
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:35 +02:00
Chris Evich 221e3023f6
Fix rand.Seed() deprecation in golang 1.20
Ref: https://pkg.go.dev/math/rand@go1.20#Seed

Note: For `runtime_test.go`, this test-case was never actually doing
what appears as it's intent .  Fixing it to work as intended would be
require incredibly libpod-invasive changes.  Do the least-worse thing and
simply confirm that consecutive generated names are different.

Signed-off-by: Chris Evich <cevich@redhat.com>
2023-04-26 14:55:03 -04:00
Toshiki Sonoda d640461ced e2e: skip journald test if journald is unavailable
If journald is unavailable, journald logging driver tests
should be skipped.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2023-04-21 11:16:18 +09:00
Paul Holzinger 525c27fe1d
test/e2e: fix SkipIfNotActive()
If a unit is not active the exit code from systemctl is 3. Thus this
test always failed because it checked the error.

Fix this by checking the exit code and remove the unnecessary output
parsing.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-20 16:26:55 +02:00
Toshiki Sonoda da83364eb0 e2e: quadlet uses PODMAN env for podman binary path
Adapts to pass the test even if
podman binary path is not `/usr/local/bin/podman`.

[NO NEW TESTS NEEDED]

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2023-04-19 16:17:57 +09:00
Paul Holzinger dc9a65e348
test/e2e: use custom network config dir where needed
Since commit f250560a80 the play kube command uses its own network.
this is racy be design because we create the network followed by
creating/running pod/containers. This means in the meantime another
prune or reset process could wipe out the network config because we have
to share the network config directory by design in the test.

The problem is we only have one host netns which is shared between
tests. If the network config dir is not shared we cannot make conflict
checks for interface names and ip address. This results in different
tests trying to use the same interface and/or ip address which will
cause runtime failures in CNI and netavark.

The only solution I see is to make sure only the reset/prune tests are
using a custom network dir. This makes sure they do not wipe configs
that are otherwise required by other parallel running tests.

Fixes #17946

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-06 16:16:50 +02:00
Ed Santiago ce8a3a0c1e e2e: GinkgoParallelNode() -> ...Process()
...to silence runtime warning:

   GinkgoParallelNode is deprecated and will be removed in Ginkgo V2.
   Please use GinkgoParallelProcess instead.

Ref: https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md#renamed-ginkgoparallelnode

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-04-05 09:44:23 -06:00
Matt Heon 39fd9aa084 Add SQLite job to CI
Signed-off-by: Matt Heon <mheon@redhat.com>
2023-03-15 14:44:47 -04:00
Giuseppe Scrivano fb4f6f95c5
test: reenable idmap test
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-03-11 12:15:38 +01:00
Chris Evich 197529f084
Skip tests which fail with CGv1 & runc
* Skip play-kube test when runc is in use #17436
* Skip uid/gidmapping idmapped-volume test #17433

Signed-off-by: Chris Evich <cevich@redhat.com>
2023-02-22 10:35:03 -05:00