Commit Graph

67 Commits

Author SHA1 Message Date
Miloslav Trmač f17590b2bd Pass all of PodmanExecOptions to various [mM]akeOptions functions
This will make it easier to structure the API, at the cost
of making it a bit more opaque about which parts of PodmanExecOptions
are implemented where.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-01-23 00:03:52 +01:00
Miloslav Trmač f2d552f5db Turn PodmanAsUserBase into PodmanExecBaseWithOptions
... replacing the many parameters with a struct with named fields.

This makes the meaning of parameters more explicit, and more importantly
it makes it easier to just edit _one_ of the parameters without requiring
specialized wrappers for every single case.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-01-23 00:03:42 +01:00
shenpengfeng 9abc17f1e1 chore: fix some function names in comment
Signed-off-by: shenpengfeng <xinhangzhou@icloud.com>
2024-10-29 17:57:31 +08:00
Paul Holzinger cd2a4c7cac
test/e2e: remove kernel version check
We need something newer than 4.14 anyway now for most Podman functions.
This is breaking liniting on windows as the function doesn't work there.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:29 +02:00
Paul Holzinger be2212804b
test/e2e: improve command timeout handling
Basically commit ada4e1a8c1 for e2e tests. The timeout does not kill the
process so if it is stucked it hangs forever. So make sure we kill it
via SIGABRT.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-08 16:27:23 +02:00
Ed Santiago eaf60c7fe7 e2e tests: use /var/tmp, not $TMPDIR, as workdirs
TMPDIR is typically /tmp which is typically(*) a tmpfs.

This PR ignores $TMPDIR when $CI is defined, forcing all
e2e tests to set up one central working directory in /var/tmp
instead.

Also, lots of cleanup.

 (*) For many years, up to and still including the time of
     this PR, /tmp on Fedora CI VMs is actually NOT tmpfs,
     it is just / (root). This is nonstandard and undesirable.
     Efforts are underway to remove this special case.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-04-26 14:29:56 -06: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
Ed Santiago 99f93d55c4 e2e: fix two toolbox flakes
1. toolbox UID/GID allocation: pick numbers < 1500. Otherwise
   we run the risk of colliding with the Cirrus rootless user.

2. WaitContainerReady(): check the results of the last "podman logs"
   before timing out. Otherwise, the user will see "READY" followed
   immediately by "Container is not ready".
   (global bug, not just toolbox, but that's where I discovered it).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-07-05 06:52:13 -06: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 445815036f
update to ginkgo v2
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:35 +02: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
gupttaru 3bb9ed4f09 Adding encryption decryption feature
Signed-off-by: Tarun1 Gupta <gupttaru@deshaw.com>
2022-11-24 04:53:59 -05:00
Chris Evich d968f3fe09
Replace deprecated ioutil
Package `io/ioutil` was deprecated in golang 1.16, preventing podman from
building under Fedora 37.  Fortunately, functionality identical
replacements are provided by the packages `io` and `os`.  Replace all
usage of all `io/ioutil` symbols with appropriate substitutions
according to the golang docs.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-09-20 15:34:27 -04:00
Miloslav Trmač 5a5624f818 Update the registry server we test against from 2.6 to 2.8
... primarily so that it can support OCI artifacts.

2.8 already seems to exist in the repo.

This requires changing WaitContainerReady to also check
stderr (ultimately because docker/distribution was
updated to a more recent sirupsen/logrus, which logs
by default to stderr instead of stdout).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-07-30 17:24:31 +02:00
Paul Holzinger 290116bf81
integration test: fix network backend option with remote
I honestly do not understand all this extra option parsing here but
there is really no reason to exclude  the option for remote, all the
other global options are also set there.

This fixes a problem with mixed cni/netavark use because the option was
unset.

Fixes #15017

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-07-22 15:29:18 +02: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
Paul Holzinger 3a016c6e49
e2e: show command and output when a timeout happens
To make debugging easier we should see the command and its output when a
failure happens.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-07-21 14:43:00 +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
Paul Holzinger 51fbf3da9e
enable gocritic linter
The linter ensures a common code style.
- use switch/case instead of else if
- use if instead of switch/case for single case statement
- add space between comment and text
- detect the use of defer with os.Exit()
- use short form var += "..." instead of var = var + "..."
- detect problems with append()
```
newSlice := append(orgSlice, val)
```
  This could lead to nasty bugs because the orgSlice will be changed in
  place if it has enough capacity too hold the new elements. Thus we
  newSlice might not be a copy.

Of course most of the changes are just cosmetic and do not cause any
logic errors but I think it is a good idea to enforce a common style.
This should help maintainability.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-26 18:12:22 +02:00
Paul Holzinger 5b4af0584d
replace golint with revive linter
golint, scopelint and interfacer are deprecated. golint is replaced by
revive. This linter is better because it will also check for our error
style: `error strings should not be capitalized or end with punctuation or a newline`

scopelint is replaced by exportloopref (already endabled)
interfacer has no replacement but I do not think this linter is
important.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 15:12:33 +02: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
Chris Evich c67d6a52c4
Fix using --network-backend on podman-remote
When this option was added to the e2e tests, there was no CI Automation
support for running remote tests w/ netavark.  When added, many
e2e test errors/failures are generated due to this option not being
valid for the remote client.  Fix this in the tests by conditionally
adding the option if the test is running the remote client.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-04-21 14:29:44 -04:00
Valentin Rothberg 0162f678c0 benchmarking Podman: proof of concept
Add a proof of concept for benchmarking Podman.  The benchmarks are
implemented by means of the end-to-end test suite but hidden behind
a `benchmarks` build tag.  Running `make localbenchmarks` will run
`test/e2e` with the specific build tag and set ginkgo's "focus" to
the specific "Podman Benchmark Suite" to only run this spec and skip
all others.

ginkgo will print a report before terminating listing the CPU and memory
stats for each benchmark.  New benchmarks can easily be added via the
`newBenchmark` function that also supports adding an `init()` function
to each benchmark which allows for performing certain setups for the
specific benchmark.  For instance, benchmarking `podman start` requires
creating a container beforehand.

Podman may be called more than once in the main function of a benchmark
but note that the displayed memory consumption is then a sum of all
Podman invocations.  The memory consumption is collected via
`/usr/bin/time`.

A benchmark's report is split into CPU and memory as displayed below:

```
[CPU] podman images:
  Fastest Time: 0.146s
  Slowest Time: 0.187s
  Average Time: 0.180s ± 0.015s
[MEM] podman images:
  Smallest: 41892.0KB
   Largest: 42792.0KB
   Average: 42380.7KB ± 286.4KB
```

Note that the benchmarks are not wired into the CI yet.  They are meant
as a proof of concept.  More benchmarks and the plumbing into CI will
happen in a later change.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-04-20 11:31:28 +02:00
Jhon Honce f8c2df87cb Add build test for .containerignore tar file
Ensure a directory added to .containerignore on client is not included
in tar sent to remote podman API service

* Clean up podman invocations to not include duplicate --remote and
  --url flags
* Use pkill vs. pgrep when cleaning up podman API service in tests
* Add exit code when logging error when testing

Closes #13535

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2022-03-31 08:48:54 -07:00
Valentin Rothberg f72a678f2a linter: enable errchkjson
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Jhon Honce 1387b5bd8a Add test for BZ #2052697
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2022-03-16 11:27:07 -07:00
Brent Baude 7d3ad6081f netavark e2e tests
enabled e2e tests for netavark

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-02-02 13:03:45 -06:00
Miloslav Trmač f6a3eddd2c Don't initialize the global RNG with GinkgoRandomSeed() in e2e tests
- It probably doesn't actually make a difference: in experiments,
  the github.com/containers/storage/pkg/stringid RNG initialization
  has been happening later
- This makes the RNG caller-controlled (which we don't benefit from),
  but also the same on all nodes of multi-process Ginkgo execution.
  So, if it works at all, it may make collisions of random ID values
  more likely, and our tests are not robust against that. So don't
  go out of our way to make collisions more likely.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-01-03 12:31:47 +01:00
Miloslav Trmač 90e74e794c Avoid collisions on RemoteSocket paths
Add lock files and re-generate the UUID if we
are not a known-unique user of the socket path.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-01-03 12:31:47 +01:00
Ed Santiago 65109494bc remove ARTIFACT_DIR and ArtifactPath
...they're not actually used for anything

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-12-01 14:06:22 -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
Ed Santiago c03b6b54fd Semiperiodic cleanup of obsolete Skip()s
Found by my find-obsolete-skips script. Let's see which, if any,
of these skipped tests can be reenabled.

Some Skips are "this will never work", not "this is expected to
work one day". Update the message on those to reflect that.

Some were real bugs in the test framework. Fix those.

And, joy of joys, some work today. Remove those skips.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-19 08:49:57 -07:00
Jhon Honce e907f095b2 test connection add
* Fix connection JSON encoding
* Add custom ginkgo matchers for connection testing
* Cleanup code

Fixes #11984

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-11-08 09:20:58 -07:00
Giuseppe Scrivano 0234b153cc
test: run --cgroups=split in new cgroup
the --cgroups=split test changes the current cgroup as it creates a
sub-cgroup.  This can cause a race condition in tests that are reading
the current cgroup.

Closes: https://github.com/containers/podman/issues/11191

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-04 13:16:17 +01:00
Jhon Honce 8453c8ce63 Support --format tables in ps output
- Added tests to help ensure there is no future regressions
- Added WaitWithTimeout(int) rather than calling
  WaitWithDefaultTimeout() multiple times
- Exposed DefaultWaitTimeout to allow test to use a multiplier

Fixes #2221

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-09-20 13:51:27 -07:00
Daniel J Walsh 05eb06f568 Turn on journald and k8s file logging tests
Signed-off-by: Ashley Cui <acui@redhat.com>
2021-02-19 16:11:41 -05:00
Jhon Honce 7e4d696d94 Report StatusConflict on Pod opt partial failures
- When one or more containers in the Pod reports an error on an operation
report StatusConflict and report the error(s)

- jsoniter type encoding used to marshal error as string using error.Error()

- Update test framework to allow setting any flag when creating pods

- Fix test_resize() result check

Fixes #8865

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-02-02 12:44:08 -07:00
Josh Soref 4fa1fce930 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-22 13:34:31 -05:00
Jhon Honce ce474788fd Restore json format for fields as well as whole structs
* Add template func to inspect template processing
* Added test using repro from #8444

Fixes #8444

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-12-07 15:39:43 -07:00
Daniel J Walsh 1f91521d24
Fix typo in tests
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-12-01 15:08:26 -05:00
Jhon Honce d60a0ddcc1 Restore --format table header support
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-10-29 10:14:08 -07:00
Ed Santiago 20e104351d move from docker.io
Followon to #7965 (mirror registry). mirror.gcr.io doesn't
cache all the images we need, and I can't find a way to
add to its cache, so let's just use quay.io for those
images that it can't serve.

Tools used:
  skopeo copy --all docker://docker.io/library/alpine:3.10.2 \
                    docker://quay.io/libpod/alpine:3.10.2

...and also:

    docker.io/library/alpine:3.2
    docker.io/library/busybox:latest
    docker.io/library/busybox:glibc
    docker.io/library/busybox:1.30.1
    docker.io/library/redis:alpine
    docker.io/libpod/alpine-with-bogus-seccomp:label
    docker.io/libpod/alpine-with-seccomp:label
    docker.io/libpod/alpine_healthcheck:latest
    docker.io/libpod/badhealthcheck:latest

Since most of those were new quay.io/libpod images, they required
going in through the quay.io GUI, image, settings, Make Public.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-28 13:16:37 -06:00
OpenShift Merge Robot 95e2e15a3f
Merge pull request #7216 from 5eraph/master
support outbound-addr
2020-08-09 07:45:20 -04:00
5eraph e6a5a56aa6 changes to support outbound-addr
Fixes #6064

Signed-off-by: Bohumil Cervenka <5eraph@protonmail.com>
2020-08-07 19:34:45 +02:00
Jhon Honce 98da2fa806 Refactor parsing to not require --remote to be first
Use cobra.Command.FParseErrWhitelist to no longer require --remote to be
the first argument in flags when using CLI

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-05 10:19:44 -07:00
Sascha Grunert fef3e2da6a
Remove some unnecessary []byte to string conversions
Some calls to `Sprintf("%s")` can be avoided by using direct string
type assertions.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-03 09:13:04 +02:00
Jhon Honce cbca625328 V2 Add support for ssh authentication methods
* podman --remote ssh://<user>:<password>@<host>:<port><path>
* podman --remote ssh://<user>:<password>@<host>:<port><path> \
  --identity <path> --passphrase <phrase>
* ssh-add <key>
  podman --remote ssh://<user>@<host><path>
* Fix `podman help` to run even if podman missing components
* Prompt for passphrase on stdin IFF key is protected and passphrase
  not given via any other configuration

* cobra flags do not support optional value flags therefore refactored
  --remote to be a boolean and --url will now contain the URI to Podman
  service

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-06-03 09:54:39 -07:00
Brent Baude 8ec08a426e v2 enable remote integration tests
enable remote integration tests

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-05-19 14:26:19 -05:00
Jhon Honce a9cc13448e V2 Restore images list tests
* Fix history --quiet formatting
* Fix image inspect --format=json
* Fix image list --sort

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-04-29 08:24:56 -07:00
Giuseppe Scrivano d3cfa7a23c
test: fix exec preserve-fds test
it specifies a fd is passed down but we are not really doing it, and
it triggers the wrong fd to be closed by Podman after the OCI runtime
invocation.

Closes: https://github.com/containers/libpod/issues/5769

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-09 10:17:42 +02:00