Commit graph

54 commits

Author SHA1 Message Date
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
Yuhui Jiang b8641aec36
Add test cases to cover podman volume
Add test cases to cover below podman volume subcommand:
  create
  ls
  inspect
  rm
  prune

Signed-off-by: Yuhui Jiang <yujiang@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-27 13:16:04 -04:00
OpenShift Merge Robot 9d9c58ba64
Merge pull request #8065 from edsantiago/flake_tweaks
Tests: Fix common flakes, and improve apiv2 test log
2020-10-21 07:21:49 -04:00
Ed Santiago f5b3dc976c Tests: Fix common flakes, and improve apiv2 test log
- apiv2 - the 'ten /info requests' test is flaking often,
  taking ~8 seconds (our limit is 7, up from 5 a few weeks
  ago). Brent suggested that the first /info call might be
  expensive, because it needs to access storage. So, let's
  prime it by running one /info outside the timing loop.
  And, because even that continues to fail, bump it up
  to 10 seconds and file #8076 to track the slowdown.

- toolbox test - WaitForReady() has timed out, even on one
  occasion causing a run failure because it failed 3 times.
  Solution: bump up timeout from 2s to 5s. Not really great,
  but CI systems are underpowered, and it's not unreasonable
  that 2s might be too low.

- sdnotify test - add a 'podman wait' between stop & rm.
  This may prevent a "cannot rm container as it is running"
  race condition.

While working on this, Brent and I noticed a few ways that
test-apiv2 logging can be improved:

- test name: when request is POST, display the jsonified
  parameters, not the original input ones. This should
  make it much easier to reproduce failures.

- use curl's "--write-out" option to capture http code,
  content type, and request time. We were getting the
  first two via grep from logged headers; this is cleaner.
  And there was no other way to get timing. We now include
  the timing as X-Response-Time in the log file.

- abort on *any* curl error, not just 7 (cannot connect).
  Any error at all from curl is bad news.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-20 11:32:49 -06:00
baude eb91d66c4a refactor api compatibility container creation to specgen
when using the compatibility layer to create containers, it used code paths to the pkg/spec which is the old implementation of containers.  it is error prone and no longer being maintained.  rather that fixing things in spec, migrating to specgen usage seems to make the most sense.  furthermore, any fixes to the compat create will not need to be ported later.

Signed-off-by: baude <bbaude@redhat.com>
2020-10-20 12:06:59 -05:00
Ed Santiago 2a6a3f333b APIv2 tests: try again to fix them
CI discovered that a lot of networking tests are failing; my
fault, for not having run my tests as root on my laptop.
Disable those.

Also: bump up the ten-request time limit, from 5 to 7 seconds.
Looks like something keeps getting slower and slower, but I
guess there's not much we can do about it.

Also: when we get a mismatch response code (e.g. 500 when we
expect 200), dump the response body and skip any subsequent
response checks.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-12 13:57:59 -06:00
Ed Santiago b2e6e4829f APIv2 tests: get them passing again
In the new-Cirrus transition, APIv2 tests were inadvertently
disabled. As expected when tests get disabled, they break.

This commit fixes some failing tests, and comments out others
(with big FIXMEs) because I have neither the expertise nor
time to figure out the real problems.

The big change to test-apiv2 is due to a recently-added
test that looks for an '=' sign in json output. My '=' vs '~'
detector completely barfed on that, and there's just no
way to make it work in a bash 'case' statement. So, switch
to an 'if' with 'expr'.

And, unrelated, fix a longstanding (harmless) bug that was
issuing spurious "expected" messages to the test log; those
should've been going to the full results log.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-12 08:45:39 -06:00
Edward Shen eb11e12f35 Add more APIv2 tests for images: push, tag, untag, rmi and image tree.
Signed-off-by: Edward Shen <weshen@redhat.com>
2020-10-09 22:19:04 -04:00
OpenShift Merge Robot fa01b838a6
Merge pull request #7891 from rhatdan/rm
This PR allows users to remove external containers directly
2020-10-09 10:55:15 -04:00
Daniel J Walsh fea78d5530
This PR allows users to remove external containers directly
Currenly if a user specifies the name or ID of an external storage
container, we report an error to them.

buildah from scratch
working-container-2
podman rm working-container-2
Error: no container with name or ID working-container-2 found: no such container

Since the user specified the correct name and the container is in storage we
force them to specify --storage to remove it. This is a bad experience for the
user.

This change will just remove the container from storage.  If the container
is known by libpod, it will remove the container from libpod as well.

The podman rm --storage option has been deprecated, and removed from docs.

Also cleaned documented options that are not available to podman-remote.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-09 06:06:08 -04:00
baude 78a06c2802 add compatibility endpoint for exporting multiple images
with the recent inclusion of dealing with multiple images in a tar archive, we can now add a compatibility endpoint that was missing images/get?names=one,two.

Fixes: #7950

Signed-off-by: baude <bbaude@redhat.com>
2020-10-08 11:55:47 -05:00
zhangguanzhang adde67c74f fix apiv2 /containers/$name/json return wrong value in .Config.StopSignal
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-10-06 11:15:25 +08:00
Valentin Rothberg 6a291942c2 compat: images/create: fix tag parsing
The `tag` parameter of the compat `images/create` endpoint can be both,
a tag and a digest.  Fix parsing of the parameter to detect digests and
use the appropriate `@` separator.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-10-02 17:24:37 +02:00
zhangguanzhang cde367c1c0 fix: The container created by APIV2 has an incorrect Env and WorkDir
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-10-01 05:13:01 +08:00
zhangguanzhang 873989f7a4 apiv2 container limit differ from docker-api
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-09-24 08:54:46 +08:00
Jhon Honce e06230c9d5 Restore 'id' stanza in pull results
id is the last image id from the set of id's returned via the images
stanza.

id may be deprecated in a future version of the API

Created test_rest_v2_0_0.py to reflect the bump in the API Version.

Fixes #7686

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-09-21 08:51:52 -07:00
Jhon Honce 8a8bae8299 Refactor API version values
* API-Version header now Major.Minor to support tools parsing this
   header
 * Libpod Version updated to 2.0.0 to reflect changes in API field
   values
 * API-Version and Libpod-API-Version headers are now included in all
   results

Fixes #7327

 * Header support tested against goland 2020.2 and
    https://www.jetbrains.com/help/idea/docker.html plugin

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-09-15 11:29:45 -07:00
OpenShift Merge Robot 3d33923374
Merge pull request #7536 from Luap99/api-network-filter
APIv2 Add network list filtering
2020-09-10 10:15:01 -04:00
OpenShift Merge Robot 1b2b068ce8
Merge pull request #7569 from zhangguanzhang/fix-apiv2-top-response-two-value
fix APIv2 pods top of non-exist pod gets two response value
2020-09-09 09:12:40 -04:00
zhangguanzhang a4ffed91da fix APIv2 pods top of non-exist pod gets two response value
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-09-09 18:50:17 +08:00
Paul Holzinger 5b8f3f2f1f APIv2 Add network list filtering
Add the filter option to the libpod endpoint.
Add support for the name filter on the docker endpoint.

Add apiv2 tests for the network list endpoints.
Enable podman network integration tests for remote.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-09-07 15:39:41 +02:00
Edward Shen 43ad9be7d8 APIv2 test: add more tests for containers
Signed-off-by: Edward Shen <weshen@redhat.com>
2020-09-01 04:00:39 -04:00
zhangguanzhang fa6ba68026 fix apiv2 will create containers with incorrect commands
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-24 23:07:30 +08:00
zhangguanzhang fb4977b936 fix /libpod/pods/json returns null when there are no pods
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-21 17:48:14 +08:00
Sascha Grunert ba9f18e2b8
Use bash binary from env instead of /bin/bash for scripts
It's not possible to run any of the scripts on distributions which do
have `bash` not in `/bin`. This is being fixed by using `/usr/bin/env
bash` instead.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-17 10:42:23 +02:00
zhangguanzhang d45bd6e29a Add parameter verification for api creation network
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-12 09:38:16 +08:00
zhangguanzhang 45b100d21c API returns 500 in case network is not found instead of 404
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-02 22:21:28 +08:00
Jhon Honce cff727d488 Add versioned _ping endpoint
Fixes #7008

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-07-31 10:19:23 -07: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 724a09e40e test/apiv2: add a simple events test
Add a simple test to exercise the events API without the "filters"
parameter.  Prevents regressing on #7078.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-27 11:51:48 +02:00
Ed Santiago d3f9f09892 APIv2 tests: fix race condition causing CI flake
A newly-added test in #6835 was flaking in CI with:

   not ok 143 [20-containers] DELETE libpod/containers/SHA
   500 cannot remove container <sha> as it is running - running or paused containers cannot be removed without force: container state improper

Root cause: DELETE being run immediately after container start.
Although the container is short-lived, it does take time to
run and exit.

Solution: wait for container to exit (should be quick) before
deleting. This gives us a new test for the /wait endpoint.

Also: tweaked some comments for readability, removed unnecessary
container ps, added actual container status checks, and added
actual message checks to another test that was merely checking
exit status.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-07-14 16:09:58 -06:00
zhangguanzhang 2086e22624 fix API: Create container with an invalid configuration
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-07-09 10:26:04 +08:00
Korhonen Sami (Samlink) 610118d9bf Add support for Filter query parameter to list images api
Docker api version 1.24 uses a query parameter named Filter
for filtering images by names. In more recent versions of
api name filter is in filters query parameter with other
filters

This patch adds a mapping that translates Filter query
parameter to Filters={"reference": [""]}

Signed-off-by: Sami Korhonen <skorhone@gmail.com>
2020-07-07 13:05:16 +03:00
Alex Jia eea96235f3 test.apiv2: add testing for container initializing
Signed-off-by: Alex Jia <chuanchang.jia@gmail.com>
2020-07-01 12:50:05 +00:00
Ed Santiago ca00067deb APIv2 tests: usability: better test logging
test-apiv2 has two basic comparisons of returned JSON:
equality and likeness ('=' and '~'). When logging failures,
the test runner shows both actual and expected values. When
logging success, for '=' there's no need to show both actual
and expected. But for '~', it can be helpful (for verifying
test correctness) to show the actual returned value.

To be specific:

   old: ok ... .MemTotal~[0-9]\+
   new: ok ... .MemTotal ('33509068800') ~ [0-9]\+

   old: ok ... .[0].State~\(exited\|stopped\)
   new: ok ... .[0].State ('exited') ~ \(exited\|stopped\)

The main benefit is that a developer or end user can
easily see precisely what was returned; this can help
confirm that the test is working as intended, and/or
help fine-tune how the test is written.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-30 09:42:02 -06:00
Valentin Rothberg 2abcd4f1de libpod/containers/json: alias last -> limit
Support both `last` and `limit` for in the containers listing endpoint.
We intended to use `limit` which is also mentioned in the docs, but the
implementation ended up using `last` as the http parameter; likely being
caused by the CLI using `--last`.  To avoid any regression, we decided
for supporting both and aliasing `last`.

Fixes: #6413
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-22 16:55:48 +02:00
Yiqiao Pu d072de6efc APIv2 tests: Add some tests for podman pods
Add some tests for podman pods subcommand:
  restart
  rm
  start
  stas
  stop
  top
  unpause

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
2020-06-16 11:53:48 +08:00
Ed Santiago 2d5a2a7640 BATS and APIv2: more tests and tweaks
- (minor): apiv2 tests: check for full ID

   Observation made while reviewing #6461: tests were checking
   only for a 12-character container/image ID in return value.
   It's actually 64, and we should test for that. This should
   also minimize confusion in a future maintainer.

 - podman pause/unpause: new test

   Runs a 'date/sleep' loop, pauses container, sleeps 3s,
   restarts, then confirms that there's a 3- to 6-second
   gap in the logs for the container.

 - podman healthcheck: new test

   run a container with healthcheck, test both healthy
   and unhealthy conditions

 - podman pod: check '{{.Pod}}' field in podman ps

   Hey, as long as we have a pod with two running
   containers, might as well confirm that 'podman ps'
   returns the expected pod ID.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-03 16:13:33 -06:00
Alex Jia 382342a0b0 test.apiv2: add test cases for committing an image from a container
Testing query parameters: container, repo, tag, comment, author, changes
and pause.

Signed-off-by: Alex Jia <chuanchang.jia@gmail.com>
2020-06-03 05:33:56 +00:00
Jhon Honce 5626c2163b V2 verify JSON output is consistent and doesn't drift
$ cd test/apiv2
$ python -m unittest -v test_rest_v1_0_0.TestApi

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-05-28 16:20:29 -07:00
Alex Jia 7e03d277f7 test.apiv2: add testing for image and deal with API returning binary
Add testing for displaying image history and exporting image

Deal with API returning binary (Content-Type =~ 'octet').
When so, set $output to the output of 'file'.

Bug fix: in 't' helper, declare loop var $i as local
to avoid contaminating caller

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Alex Jia <chuanchang.jia@gmail.com>
2020-05-28 10:00:13 +00:00
Daniel J Walsh e41089244b
Attempt to turn on build_without_cgo tests
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-22 12:56:19 -04:00
Jhon Honce f9c392f50a V2 API Version Support
* Update blang/semver to allow ParseTolerant() support
* Provide helper functions for API handlers to obtain client's 'version'
  path variable focused on API endpoint tree: libpod vs. compat
* Introduce new errors:
  * version not given in path, endpoints may determine if this is a hard
    error (ErrVersionNotGiven)
  * given version not supported (ErrVersionNotSupported), only a soft
    error if the handler is going to hijack the connection
* Added unit tests for version parsing
* bindings check version on connect:
  * client <= Server API version connection is continued
  * client >= Server API version connection fails

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-05-20 10:21:30 -07:00
Brent Baude 517bc28360 system tests must pass
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-28 15:17:00 -05:00
Brent Baude ba430bfe5e podman v2 remove bloat v2
rid ourseleves of libpod references in v2 client

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-16 12:04:46 -05:00
Ed Santiago 55eea9127a logformat: handle apiv2 results, add anchor links
apiv2 tests emit TAP-compliant output; recognize it and
highlight it the same way we do BATS tests.

Add anchor links to TAP output, so other tools (e.g.
cirrus-flake-summarize) can link to particular lines

And, remove a "-f" from "wait" in test-apiv2; looks
like there's some version of bash used in some CI VM
that doesn't grok it.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-08 12:10:24 -06:00
Ed Santiago 46e434e2cb API v2 tests: usability improvements
* Allow for descriptive comment in 't' invocations, making it
  easier to distinguish similar requests
* Include test file basename (eg 40-pods) in 'ok/not ok' line
* Always symlink $TMPDIR/test-apiv2.log to latest YYMMDDetc file
* Include test result ('ok', 'not ok') in said log
* When curl results are JSON, filter them through jq into log

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-03-27 12:25:59 -06:00
Brent Baude e56d529561 podmanv2 pod create using podspecgen
using the factory approach similar to container, we now create pods based on a pod spec generator.  wired up the podmanv2 pod create command, podcreatewithspec binding, simple binding test, and apiv2 endpoint.

also included some code refactoring as it introduced as easy circular import.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-03-27 09:04:10 -05:00
Brent Baude c5ce210f7d podmanv2 pod subcommands
add pod kill, pause, restart, rm, start, stop, and unpause

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-03-26 14:14:05 -05:00
Ed Santiago 88cd648816 APIv2 tests: add tests for stop
...and allow status 'stopped' in addition to 'exited'.

Fixes: #5336

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-03-03 06:40:27 -07:00