Commit graph

61 commits

Author SHA1 Message Date
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 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
Valentin Rothberg 6c030cd573 fix a number of godot issues
Still an unknown number remains but I am running out of patience.
Adding dots is not the best use of my time.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg 0f12b6fe55 linter: enable nilerr
A number of cases looked suspicious, so I marked them with `FIXME`s to
leave some breadcrumbs.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01: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
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
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 8eb0be0a29 a few more manual BeTrue cleanups
Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-30 10:13:16 -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
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
Valentin Rothberg 5dded6fae7 bump go module to v3
We missed bumping the go module, so let's do it now :)

* Automated go code with github.com/sirkon/go-imports-rename
* Manually via `vgrep podman/v2` the rest

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-22 09:03:51 +01: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
Daniel J Walsh 526f01cdf5
Fix up errors found by codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-11 06:14:25 -04: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
Daniel J Walsh a5e37ad280
Switch all references to github.com/containers/libpod -> podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-28 08:23:45 -04:00
Valentin Rothberg 8489dc4345 move go module to v2
With the advent of Podman 2.0.0 we crossed the magical barrier of go
modules.  While we were able to continue importing all packages inside
of the project, the project could not be vendored anymore from the
outside.

Move the go module to new major version and change all imports to
`github.com/containers/libpod/v2`.  The renaming of the imports
was done via `gomove` [1].

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

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 15:50:12 +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
Daniel J Walsh 4093b2c011
Add codespell to validate spelling mistakes in code.
Fix all errors found by codespell

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-11 06:32:19 -05:00
Jhon Honce 60d0be17fc Refactor tests when checking for error exit codes
Rather than checking for non-zero, we need to check for >0 to
distinguish between timeouts and error exit codes.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-10-16 08:10:07 -07:00
OpenShift Merge Robot 01a802e546
Merge pull request #4118 from cevich/fix_sig_proxy
Move noCache logic lower in stack
2019-09-27 23:21:25 -07:00
Jhon Honce f4723beac6 Change ginkgo Wait() to Eventually() test
Changing the test in WaitWithDefaultTimeout() to use Eventually() and
gexec.Exit(). Using ExitCode() before command has really exited returns
a -1, which can cause issues for tests testing for podman to return
non-zero values.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-09-26 14:11:54 -07:00
Chris Evich 437d9d2cde
Move noCache logic lower in stack
One or more tests are not taking advantage of the local image cache.
This has been observed to cause a testing flake in at least one
`--sigproxy` test which uses `PodmanTestIntegration.PodmanPID()`.
It has a rather short timeout of 15-seconds, which isn't always
enough time to pull down a remote image.

Fix this by reloacing the `noCache` logic from
`PodmanTest.PodmanAsUserBase()` down the stack into
`PodmanTestIntegration.makeOptions()`.  This also eliminates the need to
also check if a remote-client is being used - since it uses a different
function.

Also reverse the parameter order in `PodmanTest.PodmanBase` so that
everywhere is consistently `noEvents` then `noCache`.

Signed-off-by: Chris Evich <cevich@redhat.com>
2019-09-26 10:56:24 -04:00
Matthew Heon 318438fcb3 Do not use an events backend when restoring images
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-07-31 17:28:42 -04:00
Giuseppe Scrivano 292a48cab4
cmd, docs, test: fix some typos
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-18 10:52:19 +02:00
baude f610a485c1 use imagecaches for local tests
when doing localized tests (not varlink), we can use secondary image
stores as read-only image caches.  this cuts down on test time
significantly because each test does not need to restore the images from
a tarball anymore.

Signed-off-by: baude <bbaude@redhat.com>
2019-05-29 15:12:05 -05:00