summaryrefslogtreecommitdiff
path: root/test/e2e/generate_kube_test.go
Commit message (Collapse)AuthorAge
* e2e tests: use Should(Exit()) and ExitWithError()Ed Santiago2021-07-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Adds support to preserve auto update labels in generate and play kubeEduardo Vega2021-05-06
| | | | | | In the case of generate kube the auto-update labels will be converted into kube annotations and for play kube they will be converted back to labels since that's what podman understands Signed-off-by: Eduardo Vega <edvegavalerio@gmail.com>
* Fixes generate kube incorrect when bind-mounting "/" and "/root"zhangguanzhang2021-04-26
| | | | Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
* Add support for play/generate kube volumesEduardo Vega2021-04-09
| | | | Signed-off-by: Eduardo Vega <edvegavalerio@gmail.com>
* Support multi doc yaml for generate/play kubeEduardo Vega2021-03-25
| | | | Signed-off-by: Eduardo Vega <edvegavalerio@gmail.com>
* Generate Kubernetes PersistentVolumeClaims from named volumesJordan Williams2021-03-19
| | | | | | | | | | | | Fixes #5788 This commit adds support for named volumes in podman-generate-kube. Named volumes are output in the YAML as PersistentVolumeClaims. To avoid naming conflicts, the volume name is suffixed with "-pvc". This commit adds a corresponding suffix for host path mounts. Host path volumes are suffixed with "-host". Signed-off-by: Jordan Williams <jordan@jwillikers.com>
* Switch all builds to pull-neverDaniel J Walsh2021-03-16
| | | | | | Fixes: https://github.com/containers/buildah/issues/2779 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Allow users to generate a kubernetes yaml off non running containersDaniel J Walsh2021-03-08
| | | | | | | | | | | | | | | Currently if you attempt to create a kube.yaml file off of a non running container where the container runs as a specific User, the creation fails because the storage container is not mounted. Podman is supposed to read the /etc/passwd entry inside of the container but since the container is not mounted, the c.State.Mountpoint == "". Podman incorrectly attempts to read /etc/passwd on the host, and fails if the specified user is not in the hosts /etc/passwd. This PR mounts the storage container, if it was not mounted so the read succeeds. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* bump go module to v3Valentin Rothberg2021-02-22
| | | | | | | | | 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>
* generate kube: support --privilegedValentin Rothberg2021-02-09
| | | | | | | | | | | Do not play with capabilities for privileged containers where all capabilities will be set implicitly. Also, avoid the device check when running privileged since all of /dev/* will be mounted in any case. Fixes: #8897 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Merge pull request #9220 from vrothberg/fix-9211OpenShift Merge Robot2021-02-04
|\ | | | | generate kube: handle entrypoint
| * generate kube: handle entrypointValentin Rothberg2021-02-04
| | | | | | | | | | | | | | | | | | | | The spec of a Kube Container has a `Command` and `Args`. While both are slices, the `Command` is the counterpart of the entrypoint of a libpod container. Kube is also happily accepting the arguments to as following items in the slice but it's cleaner to move those to `Args`. Fixes: #9211 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* | Report StatusConflict on Pod opt partial failuresJhon Honce2021-02-02
|/ | | | | | | | | | | | | | | - 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>
* podman generate kube ignores --network=hostMilivoje Legenovic2021-01-30
| | | | Signed-off-by: Milivoje Legenovic <m.legenovic@gmail.com>
* Honor custom DNS in play|generate kubebaude2021-01-29
| | | | | | | | | | | | | | | | | | when creating kubernetes yaml from containers and pods, we should honor any custom dns settings the user provided. in the case of generate kube, these would be provided by --dns, --dns-search, and --dns-opt. if multiple containers are involved in the generate, the options will be cumulative and unique with the exception of dns-opt. when replaying a kube file that has kubernetes dns information, we now also add that information to the pod creation. the options for dnspolicy is not enabled as there seemed to be no direct correlation between kubernetes and podman. Fixes: #9132 Signed-off-by: baude <bbaude@redhat.com>
* Disable incompatible rootless + CGroupsV1 testsChris Evich2020-12-15
| | | | | | | | | | These tests simply will not work under these conditions. Note: Recently updated F32 (prior-fedora) and Ubuntu 20.04 (prior-ubuntu) VMs always use CGroupsV1 with runc. F33 and Ubuntu 20.10 were updated to always use CGroupsV2 with crun. Signed-off-by: Chris Evich <cevich@redhat.com>
* generate kube on multiple containersbaude2020-12-07
| | | | | | | | | | add the ability to add multiple containers into a single k8s pod instead of just one. also fixed some bugs in the resulting yaml where an empty service description was being added on error causing the k8s validation to fail. Signed-off-by: baude <bbaude@redhat.com>
* use lookaside storage for remote testsbaude2020-11-16
| | | | | | | | | | in an effort to speed up the remote testing, we should be using lookaside storage to avoid pull images as well as importing multiple images into the RW store. one test was removed and added into system test by Ed in #8325 Signed-off-by: baude <bbaude@redhat.com>
* Add support for resource cpu limit to generate kubeAndy Librian2020-10-09
| | | | | | fixes #7855 Signed-off-by: Andy Librian <andylibrian@gmail.com>
* Add support for resource memory limit to generate kubeAndy Librian2020-10-04
| | | | | | addresses #7855 Signed-off-by: Andy Librian <andylibrian@gmail.com>
* handle the play kube and generate kube for with restartPolicyzhangguanzhang2020-09-18
| | | | Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
* play/generate: support shareProcessNamespacePeter Hunt2020-09-10
| | | | | | | | | this is an option that allows a user to specify whether to share PID namespace in the pod for play kube and generate kube associated test added Signed-off-by: Peter Hunt <pehunt@redhat.com>
* fix podman generate kube with HostAliaseszhangguanzhang2020-08-27
| | | | Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
* Switch all references to github.com/containers/libpod -> podmanDaniel J Walsh2020-07-28
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Enable a bunch of remote testsDaniel J Walsh2020-07-21
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Re-enable a generate kube test that failed on UbuntuMatthew Heon2020-07-20
| | | | | | | | The fix was a new runc version, which we may have sucked in. Fixes #6506 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* Change buildtag for remoteclient to remote for testingDaniel J Walsh2020-07-06
| | | | Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* move go module to v2Valentin Rothberg2020-07-06
| | | | | | | | | | | | | | | 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>
* Merge pull request #6256 from theunrealgeek/play_kube_deploymentOpenShift Merge Robot2020-06-11
|\ | | | | Support k8s Deployment in play kube
| * Fix podman generate tests that relied on play kubetheunrealgeek2020-06-02
| | | | | | | | Signed-off-by: Aditya Kamath <theunrealgeek@gmail.com>
* | Enable Ubuntu tests in CIBrent Baude2020-06-08
|/ | | | | | Add updates required for ubuntu and run integration tests Signed-off-by: Brent Baude <bbaude@redhat.com>
* spec: fix order for setting rlimitsGiuseppe Scrivano2020-05-11
| | | | | | | also make sure that the limits we set for rootless are not higher than what we'd set for root containers. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* enable rootless integration testingBrent Baude2020-05-10
| | | | Signed-off-by: Brent Baude <bbaude@redhat.com>
* add {generate,play} kubeValentin Rothberg2020-05-06
| | | | | | | | | | | | | | | | | | | Add the `podman generate kube` and `podman play kube` command. The code has largely been copied from Podman v1 but restructured to not leak the K8s core API into the (remote) client. Both commands are added in the same commit to allow for enabling the tests at the same time. Move some exports from `cmd/podman/common` to the appropriate places in the backend to avoid circular dependencies. Move definitions of label annotations to `libpod/define` and set the security-opt labels in the frontend to make kube tests pass. Implement rest endpoints, bindings and the tunnel interface. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
* Force integration tests to passBrent Baude2020-04-21
| | | | | | Failing tests are now skipped and we should work from this. Signed-off-by: Brent Baude <bbaude@redhat.com>
* fix security-opt generate kubeQi Wang2020-03-03
| | | | | | | fix #4950 add selinux options from --security-opt of the container to generate kube result Signed-off-by: Qi Wang <qiwan@redhat.com>
* Add support for RunAsUser and RunAsGroupDaniel J Walsh2019-11-06
| | | | | | | | | | Currently podman generate kube does not generate the correct RunAsUser and RunAsGroup options in the yaml file. This patch fixes this. This patch also make `podman play kube` use the RunAdUser and RunAsGroup options if they are specified in the yaml file. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* Refactor tests when checking for error exit codesJhon Honce2019-10-16
| | | | | | | 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>
* Add test for generate kube with volumesPeter Hunt2019-07-02
| | | | Signed-off-by: Peter Hunt <pehunt@redhat.com>
* Update 'generate kube' tests to verify YAMLMatthew Heon2019-06-25
| | | | Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* Use a different method to retrieve YAML output in testsMatthew Heon2019-06-25
| | | | | | | | | OutputToString() was mangling newlines, which made YAML parsers very, very angry. But not angry enough to actually error, that would be too easy. Just angry enough to silently not decode anything. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* Fix testsMatthew Heon2019-06-24
| | | | Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* Change Marshal -> Unmarshal in generate kube testsMatthew Heon2019-06-24
| | | | | | | We need to verify that valid YAML was produced - Marshal will just pack the generated YAML even further. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* Add test for generate kube on a pod with portsMatthew Heon2019-06-24
| | | | Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* Add --filename option to generate kubeMatthew Heon2019-06-11
| | | | | | | | This allows writing output directly to a file, instead of STDOUT. Makes things easier for some scripting tasks. Like the unit tests for 'play kube'. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* Add a test for 'podman play kube' to prevent regressionMatthew Heon2019-06-10
| | | | Signed-off-by: Matthew Heon <matthew.heon@pm.me>
* use imagecaches for local testsbaude2019-05-29
| | | | | | | | | 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>
* podman: enable kube for rootlessGiuseppe Scrivano2019-04-05
| | | | | | Closes: https://github.com/containers/libpod/issues/2852 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* Enable rootless integration testsbaude2019-03-19
| | | | Signed-off-by: baude <bbaude@redhat.com>
* ginkgo status improvementsbaude2019-03-08
| | | | | | | 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>