Commit Graph

112 Commits

Author SHA1 Message Date
Paul Holzinger f93fcf7dee
bump go to 1.22
Many dependencies started using go 1.22 which means we have to follow in
order to update.

Disable the now depracted exportloopref linter as it was replaced by
copyloopvar as go fixed the loop copy problem in 1.22[1]

Another new chnage in go 1.22 is the for loop syntax over ints, the
intrange linter chacks for this but there a lot of loops that have to be
converted so I didn't do it here and disable th elinter for now, th eold
syntax is still fine.

[1] https://go.dev/blog/loopvar-preview

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-09-03 15:14:15 +02:00
Paul Holzinger 666d839157
golangci-lint: make windows linting happy
It qemu cannot be compiled anyway so make sure we do not try to compile
parts where the typechecker complains about on windows.
Also all the e2e test files are only used on linux as well.
pkg/machine/wsl also reports some error but to many for me to fix them
now. One minor problem was fixed in pkg/machine/machine_windows.go.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:29 +02:00
Radostin Stoyanov 8be9ec7216 e2e: test container restore in pod by name
Add a test to verify that restoring a container in a Pod works when
the `container restore --pod` option is used with Pod *name* (this
functionality was previously limited to support only full Pod ID).

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2024-06-21 05:52:40 +01:00
Ed Santiago 82f9811a8d ExitWithError() - a few that I missed
Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-05-13 13:59:17 -06:00
Ed Santiago 2d9159821a e2e: redefine ExitWithError() to require exit code
...and an optional error-message string, to be checked
against stderr.

This is a starting point and baby-steps progress toward #18188.
There are 249 ExitWithError() checks in test/e2e. It will take
weeks to fix them all. This commit enables new functionality:

    Expect(ExitWithError(125, "expected substring"))

...while also allowing the current empty-args form. Once
all 249 empty-args uses are modernized, the matcher code
will be cleaned up.

I expect it will take several months of light effort to get
all e2e tests transitioned to the new form. I am choosing to
do so in pieces, for (relative) ease of review. This PR:

  1) makes the initial changes described above; and
  2) updates a small subset of e2e _test.go files such that:
     a) ExitWithError() is given an exit code and error string; and
     b) Exit(Nonzero) is changed to ExitWithError(Nonzero, "string")
        (when possible)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-04-10 06:35:52 -06:00
Ed Santiago 945995be10 e2e: fix potential race in file-locks test
Two test flakes in the past week. Looks like the usual race
between "run -d" and "assume the container is ready". I don't
know if this will resolve them, but it's still a good idea.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-03-05 07:55:06 -07:00
Matt Heon 3ca2213607 Add a helper for stopping pods and containers in E2E
This removes a lot of boilerplate, but also ensures that every
stop test that is not directly testing podman stop or podman pod
stop uses `-t0` for quick, error-free stopping.

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-15 09:35:55 -05:00
Matt Heon 72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

[1] https://github.com/KSubedi/gomove

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
Ed Santiago c90e9dad7a e2e: reenable warning checks on Debian
Back when we introduced ExitCleanly(), we couldn't use it
on Debian because of too many runc bugs. Now, early 2024:

 - #11784 has been closed-wontfix, so add a runc special-case
   in the specific test that triggers it.

 - #11785 seems to have gone away? Treat it as fixed.

 - #19552 is languishing, so let's just close-wontfix it too and
   add another runc special case.

 - and, one new rootless-cgroupsV1 exception for a warning msg
   that snuck in recently.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-01-07 18:00:54 -07:00
Radostin Stoyanov 9b17d6cb06
vendor: update checkpointctl to v1.1.0
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2023-09-12 08:41:02 +01:00
Ed Santiago 65bddfcd25 e2e: use ExitCleanly() in checkpoint tests
Ongoing steps toward RUN-1907: replace Exit(0) with ExitCleanly()

Clean command-line replace, with one manual reversion (commented)

And -- duh! -- skip the stderr check on Debian!

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-07 20:20:28 -06:00
Chris Evich 95ceacefbf
Re-enable checkpoint test on Debian SID
An unhelpful comment doesn't give any clues why this test was originally
skipped on Ubuntu.  In any case, now that CI uses Debian SID, re-enable
the test hoping that it now functions.

Signed-off-by: Chris Evich <cevich@redhat.com>
2023-08-08 14:34:25 -04:00
Ed Santiago 0b7157e3b3 CI: e2e: reenable containerized checkpoint tests
And lo, a miracle occurred. Containerized checkpoint tests are
no longer hanging. Reenable them.

(Followup miracle: tests are still passing, after a year of not
running!)

Closes: #15015

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-07-31 06:58:09 -06: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
Paul Holzinger ab502fc5c4
criu: return error when checking for min version
There is weird issue #18856 which causes the version check to fail.
Return the underlying error in these cases so we can see it and debug
it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-06-12 15:29:21 +02:00
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 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 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
Paul Holzinger 1f45c715df
test/e2e: fix incorrect usage of CreateTempDirInTempDir()
Creating a new diretory results in the test leaking it when it is not
removed via a defer call. All tests have already access to
`podmanTest.TempDir` which will be automatically removed in the
`AfterEach()` block.

While some test were fine other forgot the defer call. To keep the test
consitent and prevent other from making the same mistake convert all
users to `podmanTest.TempDir`. `CreateTempDirInTempDir()` is only used
for the `podmanTest.Setup()` call.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-20 16:26:55 +02:00
Toshiki Sonoda 38d5319f16 e2e: reduce dependency on /tmp for e2e tests
- Use filepath.Join(podmanTest.TempDir, "any") instead of "/tmp/any"

- Add generatePolicyFile() to avoid the hardcording of "keyPath": "tmp/key.gpg"

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2023-01-26 22:20:15 +09:00
Ed Santiago ca91cf416f Let's see if #14653 is fixed or not
Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-01-19 12:20:56 -07:00
Paul Holzinger 2ddf1c5cbd
ginkgo tests: apply ginkgolinter fixes
I found the ginkgolinter[1] by accident, this looks for not optimal
matching and suggest how to do it better.

Overall these fixes seem to be all correct and they will give much
better error messages when something fails.
Check out the repo to see what the linter reports.

[1] https://github.com/nunnatsa/ginkgolinter

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-11-25 14:41:43 +01:00
Erik Sjölund a1b32866cc Fix language. Mostly spelling a -> an
Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2022-11-20 19:41:06 +01:00
Prajwal S N b8e03ab44d
deps: bump go-criu to v6
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2022-11-01 13:57:24 +05:30
cdoern 2478e32ca3 fix restore API endpoint
restore endpoint was totally ignoring --pod, it was missing from the schema and from query handling
on the api handlers side. add support for it here.

resolves #15018

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
2022-09-22 15:11:19 -04:00
Toshiki Sonoda d63e49a26a remote: checkpoint --export prints a rawInput or an error on remote
This commit fixes `container checkpoint --export`
to print a rawInput or an error.

Fixes: #15743

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-09-16 16:46:14 +09:00
Daniel J Walsh 25f6fc9c6a
I believe that these tests will now run with crun.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-09 15:41:33 -04:00
Toshiki Sonoda 2685c8dc43 Output messages display rawInput
`init`, `checkpint/restore` and `cleanup` command now display
output messages which is rawInput instead of a container ID.

Example:
```
$ podman init <container name>
<container name>

$ podman init <short container ID>
<short container ID>
```

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-08-02 18:28:37 +09:00
Toshiki Sonoda e4992fb818 Fix: Restore a container which name is equal to a image name
If there is a match for both container and image, we restore the container.

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

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-07-27 09:44:48 +09:00
Ed Santiago 94e0a364a8 Semiperiodoc cleanup of obsolete FIXMEs
Some refer to issues that are closed. Remove them.

Some are runc bugs that will never be fixed. Say so, and remove
the FIXME.

One (bps/iops) should probably be fixed. File an issue for it, and
update comment to include the issue# so my find-obsolete-skips script
can track it.

And one (rootless mount with a "kernel bug?" comment) is still
not fixed. Leave the skip, but add a comment documenting the symptom.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-07-25 13:08:35 -06:00
Ed Santiago 0a160fed77 Bump VMs, to Ubuntu 2204 with cgroups v1
...and enable the at-test-time confirmation, the one that
double-checks that if CI requests runc we actually use runc.
This exposed a nasty surprise in our setup: there are steps to
define $OCI_RUNTIME, but that's actually a total fakeout!
OCI_RUNTIME is used only in e2e tests, it has no effect
whatsoever on actual podman itself as invoked via command
line such as in system tests. Solution: use containers.conf

Given how fragile all this runtime stuff is, I've also added
new tests (e2e and system) that will check $CI_DESIRED_RUNTIME.

Image source: https://github.com/containers/automation_images/pull/146

Since we haven't actually been testing with runc, we need
to fix a few tests:

  - handle an error-message change (make it work in both crun and runc)
  - skip one system test, "survive service stop", that doesn't
    work with runc and I don't think we care.

...and skip a bunch, filing issues for each:

  - #15013 pod create --share-parent
  - #15014 timeout in dd
  - #15015 checkpoint tests time out under $CONTAINER
  - #15017 networking timeout with registry
  - #15018 restore --pod gripes about missing --pod
  - #15025 run --uidmap broken
  - #15027 pod inspect cgrouppath broken
  - ...and a bunch more ("podman pause") that probably don't
    even merit filing an issue.

Also, use /dev/urandom in one test (was: /dev/random) because
the test is timing out and /dev/urandom does not block. (But
the test is still timing out anyway, even with this change)

Also, as part of the VM switch we are now using go 1.18 (up
from 1.17) and this broke the gitlab tests. Thanks to @Luap99
for a quick fix.

Also, slight tweak to #15021: include the timeout value, and
reword message so command string is at end.

Also, fixed a misspelling in a test name.

Fixes: #14833

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-07-21 20:08:32 -06:00
Ed Santiago 4fd5fb97a0 e2e tests: cleanup: capitalize CONSTANTS
A number of standard image names were lower-case, leading to
confusion in code such as:

    registry := podman(... , "-n", "registry", registry, ...)
    ^--- variable                              ^---- constant

Fix a number of those to be capitalized and with _IMAGE suffix:

    registry := podman(...,                    REGISTRY_IMAGE

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-07-05 15:36:08 -06:00
Zeyad Yasser 79a38a2c6a
Add test for restore runtime verification using non-default runtime
Runtime verification test for container checkpoint with export
used the default runtime for test which causes test to always
pass. Problem rises when using non-default runtime, then doing
a restore. This test forcse using a non-default runtime during
container creation.

Edge case:
	1. Default runtime is crun
	2. Container is created with runc
	3. Checkpoint without setting --runtime into archive
	4. Restore without setting --runtime from archive

It should be expected that podman identifies runtime from the
checkpoint archive.

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2022-06-28 16:14:47 +02:00
Ed Santiago a4ae22df86 Workaround for bug 14653 (checkpoint flake)
Since it may be a while before we get a true fix: add a
workaround for podman-remote checkpoint tests, in which
we pause until the 'run --rm' container is truly truly gone.

I've tried to make it as easy as possible to clean up
the workaround code once the bug is fixed.

Oh, also, remove "-it" from a podman-run. It makes no sense
and only results in nasty orange warning messages.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-06-23 15:03:46 -06:00
Paul Holzinger 205c8c071e
fix podman container restore without CreateNetNS
When a container does not use the default podman netns, for example
--network none or --network ns:/path a restore would fail because the
specgen check validates that c.config.StaticMAC is nil but the
unmarshaller sets it to an empty slice.

While we could make the check use len() > 0 I feel like it is more
common to check with != nil for ip and mac addresses.
Adding omitempty tag makes the json marshal/unmarshal work correctly.
This should not cause any issues.

Fixes #14389

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-31 16:49:40 +02:00
Paul Holzinger 69c479b16e
enable errcheck linter
The errcheck linter makes sure that errors are always check and not
ignored by accident. It spotted a lot of unchecked errors, mostly in the
tests but also some real problem in the code.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-29 14:06:38 +02:00
Ed Santiago b3f38c31b2 Ginkgo: use HaveField() for better error checking
This is a very late followup to my ginkgo-improving work of 2021.
It has been stuck since December because it requires gomega 1.17,
which we've just enabled.

This commit is simply a copy-paste of a command I saved in
my TODO list many months ago:

     sed -i -e 's/Expect(\([^ ]\+\)\.\([a-zA-Z0-9]\+\))\.To(Equal(/Expect(\1).To(HaveField(\"\2\", /' test/e2e/*_test.go

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-04-28 05:41:53 -06:00
Paul Holzinger 2a8e435671
enable staticcheck linter
Fix many problems reported by the staticcheck linter, including many
real bugs!

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 12:51:29 +02:00
Valentin Rothberg 06dd9136a2 fix a number of errcheck issues
Numerous issues remain, especially in tests/e2e.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:15:28 +01:00
Adrian Reber 4b90542d5b
Fix checkpoint/restore pod tests
Checkpoint/restore pod tests are not running with an older runc and now
that runc 1.1.0 appears in the repositories it was detected that the
tests were failing. This was not detected in CI as CI was not using runc
1.1.0 yet.

Signed-off-by: Adrian Reber <areber@redhat.com>
2022-02-11 15:11:48 +00:00
Valentin Rothberg bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00
Adrian Reber d669dbfb9f
Error out early if system does not support pre-copy checkpointing
CRIU's pre-copy migration support relies on the soft dirty page tracking
in the Linux kernel:

 https://www.kernel.org/doc/Documentation/vm/soft-dirty.txt

This functionality is not implemented for all architectures and it can
also be turned off in the kernel.

CRIU can check if the combination of architecture/kernel/CRIU supports
the soft dirty page tracking and exports this feature checking
functionality in go-criu.

This commit adds an early check if the user selects pre-copy
checkpointing to error out if the system does not support it.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-12-23 09:51:38 +00:00
Radostin Stoyanov 207823eb05
e2e: Add dev/shm checkpoint/restore test
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-12-23 05:47:33 +00:00
Adrian Reber 28018ce604
Test for checkpoint specific inspect fields
This extends one of the checkpoint/restore tests to see if the
newly introduced checkpoint specific fields in 'inspect' work as
intended.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-12-17 10:02:35 +00:00
Ed Santiago c0a8814fb4 Use HaveLen(x) instead of Expect(len(y)).To(Equal(x))
sed -i -e 's/Expect(len(\(.*\)))\.To(Equal(\(.*\)))/Expect(\1).To(HaveLen(\2))/' test/e2e/*.go

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-12-02 07:54:53 -07:00
Ed Santiago 9ce7ade8c8 e2e: yet more cleanup of BeTrue/BeFalse
Thanks to Paul for teaching me about HaveKey()

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-30 15:19:57 -07:00
Ed Santiago 12787963b0 e2e tests: more cleanup of BeTrue()s
Write a BeValidJSON() matcher, and replace IsJSONOutputValid():

  sed -i -e 's/Expect(\(.*\)\.IsJSONOutputValid()).To(BeTrue())/Expect(\1.OutputToString())\.To(BeValidJSON())/' test/e2e/*_test.go

(Plus a few manual tweaks)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-30 09:51:06 -07:00
Ed Santiago b63d696405 e2e tests: enable golint
...and fix problems found therewith.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-29 08:30:00 -07:00