10 Commits

Author SHA1 Message Date
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
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
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
cff727d488 Add versioned _ping endpoint
Fixes #7008

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-07-31 10:19:23 -07:00
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
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
5612089412 CI: add API v2 tests
API v2 has been quiet for a few days, and the test script is
actually passing. Let's take advantage of this opportunity
to get them running in CI.

Requires adding a check for cgroupsv2

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-03-02 13:19:42 -07:00
f25c595cb8 apiv2 tests: add more pod tests, timing check
Looks like /libpod/pods/create has been fixed to return an
actual pod ID. Extend those tests.

Also, update timeout in the server command: it's now seconds,
not milliseconds.

Also, update FIXME comments in /pods/prune . Still doesn't
work, but clarify what we're seeing.

Also, add a new test that runs ten /info requests and
barfs if it takes more than 5 seconds.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-25 06:42:27 -07:00
0af16eb15b API v2 tests: catch up to moving target
Lots has changed since I first checked this in:

 * Switch to new podman system service invocation
 * /containers API has changed drastically
 * /pods API has some fixes; check for them (e.g.
   container-exists is now 409 Conflict, not 500)
 * One test ('?invalidparam=x') still doesn't work;
   comment it out so we can get everything passing.

Also, some work on the test framework itself:

 * Cleaner port-open testing (the bash /dev/tcp check).
 * Add a 'podman' function to invoke local podman and
   log its output.

The above two allow us to:

 * Get rid of stderr special-casing

Furthermore:

 * t() no longer needs leading '.'; this allows jq
   features such as 'length' and perhaps other filters
 * special-case handling of 204 and 304: rfc2616 demands
   that they return no message body; assert that it is so.
 * new root & rootless helper functions (check server)
 * remove the "unlikely to work" message for rootless;
   it seems to be working fine
 * fix pod tests for rootless
   * BUT: add a bolder FIXME because the ID field seems wrong

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-11 14:31:12 -07:00
c2f50499c9 Tests for API v2
Initial framework for testing the version 2 (HTTP) API.
Includes a collection of tests for some of the existing
endpoints. Not all tests are currently passing.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-01-17 09:59:22 -07:00