46 Commits

Author SHA1 Message Date
ccb7da52c1 e2e: ExitCleanly(): manual special cases
Commit 2 of 2: individual special-case handling of tests
which did not pass under ExitCleanly(), one or more of:

 - add "-q" to commit & push commands
 - add ErrorToString() checks
 - remove unnecessary ErrorToString() checks

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-27 16:04:59 -06:00
611db19b31 e2e: ExitCleanly(): the final fron^Wcommit
Final push on RUN-1907. Commit 1 of 2.

This is the final set of test/e2e/*_test.go files to be
converted from Exit(0) to ExitCleanly().

This commit is a mix of automated string-replace with
manual revert-back: tests that did not pass with ExitCleanly()
are reverted back to Exit(0), so they will not show up as
diffs in this commit. When possible, I address those in
my next commit.

My goal was to make this commit a don't-bother-reviewing one
that will also pass tests (so as not to break git-bisect).
The next commit is the important one to review.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-27 16:04:59 -06:00
fc5aa9c9ca test/e2e: use GinkgoT().TempDir() over MkdirTemp()
Using GinkgoT().TempDir() will automatically result in the directy to be
cleaned up when the test is done. This should help to prevent leaking
files and we do not need to error check every time.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-05 10:40:26 +02:00
aa453c4f11 make lint: re-enable ginkgolinter
To make sure the e2e tests are kept in order.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 15:09:34 +02:00
5b2d963c44 test/e2e: add regression testing for comma-containing labels
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
2023-05-25 22:56:27 +02:00
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
3050a64373 e2e test cleanup
- fix a typo that was resulting in a test being a NOP, and
   add actual testing to it.

 - fix two Expects() with incorrectly-ordered actual/expects

 - remove leading whitespace from an It() test name

 - To(BeTrue()) is evil. Wherever possible, replace it with
   useful string or field checks. When not possible, use
   the annotation field to indicate what failed. I got
   carried away here, #sorrynotsorry

 - remove unused system-test code

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-05-02 08:36:26 -06:00
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
445815036f update to ginkgo v2
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:35 +02:00
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
58869dcc30 e2e tests: fix restart race
It's so easy to forget that "podman start" is nonblocking.
So podman create, start, restart has a race where "restart"
can run before the container actually starts.

Solution: start --attach. Thanks to @vrothberg for noticing that.

There are still a handful of other suspicious-looking restarts
in this test, but all involve "top" which of course has to be
detached. Since those don't have any flakes that I know of, I
choose to ignore them.

Fixes: #16505

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-11-15 07:44:52 -07:00
f304a1757c Fix typo about e2e tests name
* podman stop --all -> podman kill --all
* podman pause --filter -> podman restart --filter

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-09-30 13:28:16 +09:00
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
9553f3bafa Run codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-25 16:32:31 -04:00
0dbbb1cb3f Add restart --cidfile, --filter
--cidfile : Read container ID from the specified file and restart the container.
--filter : restart the filtered container.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-08-12 09:22:53 +09:00
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
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
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
547fff2703 e2e tests: use Should(Exit()) and ExitWithError()
e2e test failures are rife with messages like:

   Expected 1 to equal 0

These make me cry. They're anti-helpful, requiring the reader
to dive into the source code to figure out what those numbers
mean.

Solution: Go tests have a '.Should(Exit(NNN))' mechanism. I
don't know if it spits out a better diagnostic (I have no way
to run e2e tests on my laptop), but I have to fantasize that
it will, and given the state of our flakes I assume that at
least one test will fail and give me the opportunity to see
what the error message looks like.

THIS IS NOT REVIEWABLE CODE. There is no way for a human
to review it. Don't bother. Maybe look at a few random
ones for sanity. If you want to really review, here is
a reproducer of what I did:

   cd test/e2e
   ! positive assertions. The second is the same as the first,
   ! with the addition of (unnecessary) parentheses because
   ! some invocations were written that way. The third is BeZero().
   perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(Equal\((\d+)\)\)/Expect($1).Should(Exit($2))/' *_test.go
   perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(\(Equal\((\d+)\)\)\)/Expect($1).Should(Exit($2))/' *_test.go
   perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(BeZero\(\)\)/Expect($1).Should(Exit(0))/' *_test.go

   ! Same as above, but handles three non-numeric exit codes
   ! in run_exit_test.go
   perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(Equal\((\S+)\)\)/Expect($1).Should(Exit($2))/' *_test.go

   ! negative assertions. Difference is the spelling of 'To(Not)',
   ! 'ToNot', and 'NotTo'. I assume those are all the same.
   perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.To\(Not\(Equal\((0)\)\)\)/Expect($1).To(ExitWithError())/' *_test.go
   perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.ToNot\(Equal\((0)\)\)/Expect($1).To(ExitWithError())/' *_test.go
   perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.NotTo\(Equal\((0)\)\)/Expect($1).To(ExitWithError())/' *_test.go
   ! negative, old use of BeZero()
   perl -pi -e 's/Expect\((\S+)\.ExitCode\(\)\)\.ToNot\(BeZero\(\)\)/Expect($1).Should(ExitWithError())/' *_test.go

Run those on a clean copy of main branch (at the same branch
point as my PR, of course), then diff against a checked-out
copy of my PR. There should be no differences. Then all you
have to review is that my replacements above are sane.

UPDATE: nope, that's not enough, you also need to add gomega/gexec
to the files that don't have it:

   perl -pi -e '$_ .= "$1/gexec\"\n" if m!^(.*/onsi/gomega)"!' $(grep -L gomega/gexec $(git log -1 --stat | awk '$1 ~ /test\/e2e\// { print $1}'))

UPDATE 2: hand-edit run_volume_test.go

UPDATE 3: sigh, add WaitWithDefaultTimeout() to a couple of places

UPDATE 4: skip a test due to bug #10935 (race condition)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-07-15 05:06:33 -06:00
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
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
073f76c132 Switch podman stop/kill/wait handlers to use abi
Change API Handlers to use the same functions that the
local podman uses.

At the same time:

 implement remote API for --all and --ignore flags for podman stop
 implement remote API for --all flags for podman stop

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-29 14:04:44 -05:00
0cff5ad0a3 Fxes /etc/hosts duplicated every time after container restarted in a pod
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2021-01-13 19:03:35 +08:00
15345ce4c3 podman create doesn't support creating detached containers
Detached containers and detach keys are only created with the podman run, i
exec, and start commands.  We do not store the detach key sequence or the
detach flags in the database, nor does Docker. The current code was ignoreing
these fields but documenting that they can be used.

Fix podman create man page and --help output to no longer indicate that
--detach and --detach-keys works.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-21 21:00:50 -04:00
a277b7eb0b Examine all SkipIfRemote functions
Remove ones that are not needed.
Document those that should be there.
Document those that should be fixed.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-22 16:55:37 -04:00
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
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
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
a7b3310db5 enable integration tests for restart
enable integrations tests for container restart.  fixed bug where --running was not being honored.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-27 09:08:27 -05:00
5c968b7693 Force integration tests to pass
Failing tests are now skipped and we should work from this.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-21 13:48:50 -05:00
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
18d66136c1 podman remote-client restart containers
add the ability to restart containers with the remote-client

Signed-off-by: baude <bbaude@redhat.com>
2019-04-24 13:30:18 -05:00
d5546008ab ginkgo status improvements
a series of improvements to our ginkgo test framework so we can
get better ideas of whats going on when run in CI

Signed-off-by: baude <bbaude@redhat.com>
2019-03-08 13:28:33 -06:00
4c618875f6 Add tests to make sure podman container and podman image commands work
We have little to no testing to make sure we don't break podman image and
podman container commands that wrap traditional commands.

This PR adds tests for each of the commands.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-03-02 07:15:26 -05:00
25a3923b61 Migrate to cobra CLI
We intend to migrate to the cobra cli from urfave/cli because the
project is more well maintained.  There are also some technical reasons
as well which extend into our remote client work.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-08 10:26:43 -06:00
b30a56c156 Run integrations test with remote-client
Add the ability to run the integration (ginkgo) suite using
the remote client.

Only the images_test.go file is run right now; all the rest are
isolated with a // +build !remotelinux.  As more content is
developed for the remote client, we can unblock the files and
just block single tests as needed.

Signed-off-by: baude <bbaude@redhat.com>
2019-01-14 14:51:32 -06:00
74bcfc2f96 Separate common used test functions and structs to test/utils
Put common used test functions and structs to a separated package.
So we can use them for more testsuites.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
2018-11-16 10:49:00 +08:00
2011782d9d Make restart parallel and add --all
When attempting to restart many containers, we can benefit from making
the restarts parallel.  For convenience, two new options are added:

--all attempts to restart all containers
--run-only when used with --all will attempt to restart only running containers

Signed-off-by: baude <bbaude@redhat.com>
2018-11-01 13:14:12 -05:00
433cbd5254 Show duration for each ginkgo test and test speed improvements
Because our tests are getting so long, we want to be able to audit which tests are taking
the longest to complete.  This may indicate a bad test, bad CI, bad code, etc and therefore
should be auditable.

Also, make speed improvements to tests by making sure we only unpack caches images that
actually get used.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1178
Approved by: mheon
2018-07-28 22:51:08 +00:00
04b58bc80c Add restart test with timeout
Test the --timeout flag with a container which can not be stopped with
SIGSTOP. This means the container should can not be stopped and will be
killed then restart with timeout value. Test steps:
  Start a container with STOPSIGNAL=SIGKILL
  Restart it with --timeout set to 2s
  Check the restart command will finished more than 2s and less than
  10s(the default timeout)

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
2018-04-23 17:34:26 +08:00
18c98375a0 Improve restart latest container test
Remove the --latest from the restart running container test, and
add a separated case with following steps:
  start two container in order: test1, test2
  restart container with --latest
  check the start time for test1 and test2

And the results should be test1 is not restarted and test2 is restarted.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
2018-04-23 17:34:21 +08:00
3a220be5bb Add start time check for restart test
Check the start time changed after restart the container.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
2018-04-23 17:14:22 +08:00
2f533888a5 Fix E2E tests
Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #503
Approved by: rhatdan
2018-03-16 13:55:49 +00:00
358f84ad39 Fix E2E tests
Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #503
Approved by: rhatdan
2018-03-16 13:55:49 +00:00
05fb5a0aa7 Fix nit in restart E2E tests
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #503
Approved by: rhatdan
2018-03-16 13:55:49 +00:00
540a441234 Add tests for restart
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #503
Approved by: rhatdan
2018-03-16 13:55:49 +00:00