Commit Graph

12 Commits

Author SHA1 Message Date
David Gibson d418391ce6 test, pasta: Ignore deprecated addresses in tests
The default_addr shell function in test/system/helpers.network is used to
get the host's default address, which is used in a number of pasta
networking tests.  However, in certain circumstances it can incorrectly
pick a deprecated address as the primary address.  Correct it to exclude
those.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2024-05-22 17:36:33 +10:00
Ed Santiago d27313ad10 systests: conditionalize slirp4netns tests
As of podman 5.0, slirp4netns is a soft dependency. It might
not be installed on a host (and, in gating tests, is not).
Deal with it.

Use podman itself, not 'which', to tell us if slirp4netns
is available. We don't want to duplicate podman's path-check
logic. Since this check is expensive, cache the result.

(Change the has_pasta check similarly)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-04-03 05:49:21 -06:00
Stefano Brivio 23433ec7bd test/system: Add support for multipath routes in pasta networking tests
In some environments, such as the one described in
https://github.com/containers/podman/issues/20927, the default route
is given as nexthop gateways. That is, it's a multipath routes with
multiple gateways.

That means that pasta(1), after commit 6c7623d07bbd ("netlink: Add
support to fetch default gateway from multipath routes"), can start
and use a default gateway from that route.

Just like in pasta(1), in these tests, the default route indicates
which upstream interface we should pick. If we ignore multipath
routes, IPv6 addresses and gateway addresses themselves won't be
available, so, while pasta is now able to configure the container,
IPv6 tests will expect to find no address and no gateway, hence fail
due to the mismatch.

Try to get routes, including gateway addresses and interface names,
from nexthop objects, in case the selection of a regular default
route yields no results.

Link: https://github.com/containers/podman/issues/20927
Closes: #20927
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2024-03-18 14:29:38 +01:00
Matt Heon 4c1c4c082a Vendor latest c/common and fix tests
This vendors the latest c/common version, including making Pasta
the default rootless network provider. That broke a number of
tests, which have been fixed as part of this PR.

Also includes a change to network stats logic, which simplifies
the code a bit and makes it actually work with Pasta.

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-29 12:16:51 -05:00
Ed Santiago 9e3363c5e3 CI: systest: safer random_rfc1918_subnet
Our aarch64 CI system uses 172.31.0.0/20. Because I was (and am)
lazy, my random_rfc1918_subnet() helper was only checking /24.
This causes flakes.

Solution is to actually do it right: binary arithmetic, prefix
matching. This is effectively impossible in bash, so, use a
hairy perl helper and add copious tests.

Fixes: #18693

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-10-26 09:19:32 -06:00
Ed Santiago c0fb8fe594 CI: try to fix more networking flakes
There's a whole slew of networking-related flakes whose common
element seems to be improper use of curl. Fix those by:

  * add --retry --retry-connrefused; and/or
  * add -S ("show errors". Plain -s silences everything!); and/or
  * test exit status from curl; and/or
  * add wait_for_port after "podman run -d", to avoid races
  * log commands, to make debugging easier

Important note: wait_for_port() was not working with rootless
podman ports. Trivial proof:

  $ podman run -d --name foo -p 8192:80 \
      quay.io/libpod/testimage:20221018 \
      /bin/busybox-extras httpd -f -p 80
  $ grep :2000 /proc/net/tcp
  [no results]

Solution: use ss tool; it seems to handle this just fine.
There may be a better solution.

Oh, also, add -t1 to a podman restart, to shave 18s from test run.

Fixes: #20335 and, I think, a handful of others

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-10-25 07:24:16 -06:00
Ed Santiago c32cfb1d01 systests: random_free_port: fix EADDRINUSE flake
Fixes infrequent but annoying flake in which system tests
call random_free_port(), get a nice-looking port, then
fail with "bind: address already in use".

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-06 06:10:40 -06:00
Ed Santiago f877d7dcd0 Replace egrep/fgrep with grep -E/-F
There are days when I really, really, really hate GNU. Remember
when someone decided that 'head -1' would no longer work, and
that it was OK to break an infinite number of legacy production
scripts? Someone now decided that egrep/fgrep are deprecated,
and our CI logs (especially pr-should-include-tests) are now
filled with hundreds of warning lines, making it difficult
to find actual errors.

I expect that those warnings will be removed quickly after
furious community backlash, just like the 'head -1' fiasco
was quietly reverted, but ITM the warnings are annoying
so I capitulate.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-05-03 07:32:42 -06:00
Paul Holzinger eed389508e
test/system: fix wait_for_port() to wait for bind
The goal of the wait_for_port() function is to return when the port is
bound. This is to make sure we wait for application startup time.
This can be seen in some comments of the callers.

Commit 7e3d04fb caused this regression while reworking the logic to read
ports from /proc. I doesn't seem to cause problems in CI, properly
because the function returns before the port is bound.
I have not seen any flakes related to this but I only see the ones on
PRs where I rerun tests so it is best to wait for Ed to take a look.

Also fixes the broken ipv4_to_procfs() which only passes one argument to
__ipv4_to_procfs(), this results in the ipv4 not beeing inverted.
Therefore all bind checks against a direct ipv4 did not work.
This function accepts only an ipv4 but one caller passes localhost
which is invalid.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-03-14 14:24:04 +01:00
Stefano Brivio cb8c9af5d3 test/system: Add, use tcp_port_probe() to check for listeners rather than binds
_test_skopeo_credential_sharing() used port_is_free() to check if a
port has no active listeners. With the new implementation, this is
not equivalent anymore: a port might be in TIME_WAIT, so it's not
free, but the listener might be long gone.

Add tcp_port_probe() to check if there's an active listener on a
given port, and use it in _test_skopeo_credential_sharing().

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2022-11-08 00:16:36 +01:00
Stefano Brivio 348c3f2833 test/system: Add tests for pasta(1) connectivity
These tests should cover all the basic networking functionality with
pasta(1). Namely, they check:

- IPv4 and IPv6 addressing and routing settings

- TCP and UDP port forwarding over IPv4 and IPv6

- data transfers and ICMP/ICMPv6 echo requests

- the (exceedingly simple) lifecycle handling

These tests need some new helpers, to obtain IPv4 and IPv4 addresses
and routes, as well as MTU and interface names. Those use jq(1) for
parsing.

Some availability checks are implemented as well, to skip tests if
pasta(1) is not available, or if IPv4 and IPv6 are not usable.

To get consistent outcomes across distributions, and to enable
uncomplicated termination for UDP tests based on zero-sized packets,
use socat(1), which, unlike netcat, doesn't suffer from option
inconsistencies depending on flavours (traditional, BSD, NMAP) and
versions.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2022-11-08 00:16:36 +01:00
Stefano Brivio b3cf836841 test/system: Move network-related helpers to helpers.network.bash
The main helpers.bash file is rather bloated and it's difficult to
find stuff there. Move networking functions to their own helper
file.

While at it, apply a consistent style, and rearrange logically
related functions into sections.

Suggested-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2022-11-08 00:16:36 +01:00