Re: TAP test started using meson, can get a tcp port already used by another test.

From: Andres Freund <andres(at)anarazel(dot)de>
To: Zharkov Roman <r(dot)zharkov(at)postgrespro(dot)ru>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: TAP test started using meson, can get a tcp port already used by another test.
Date: 2025-02-21 15:50:14
Message-ID: tmq7i6yo77xpzbvtiengfxowekjjci5ovghdvg63unsqrmj6v6@tdr45u6epwcl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2025-02-21 15:58:45 +0700, Zharkov Roman wrote:
> We running TAP tests which operates with a lot of instances. And some of
> these tests randomly fail due "address already in use". It turned out that
> the meson does not set environment variable MESON_BUILD_ROOT when running
> the test() function [0].

I don't think meson ever set MESON_BUILD_ROOT during tests, so afaict the
portlock logic just just never worked with meson?

> As a result each test uses its own "portlock" directory [1]. The small TAP
> test 001_portlock_env_test.pl shows the test environment variables. As we
> can see MESON_BUILD_ROOT is really undefined.

I'm rather baffled this hasn't caused more problems...

I have recently seen a CI failure that looked like it likely was caused by
this. It was in a back branch, and I thought that was the explanation, due to
the portlock logic not yet existing. But the portlock logic is old enough, so
it likely was this.

But I would have expected many more errors.

> Can we explicitly set the MESON_BUILD_ROOT environment variable when running
> a test? With included patch for the src/tools/testwrap file, each instance
> gets an unique TCP port.

I don't like that, feels like a "namespace violation" to set a MESON_*
variable, why not set the top_builddir or a dedicated variable?

And I don't think it should be done in testwrap, but to test_env in the
top-level meson.build.

Something like the attached?

Greetings,

Andres Freund

Attachment Content-Type Size
meson-portlock.diff text/x-diff 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-02-21 15:55:03 Re: generic plans and "initial" pruning
Previous Message Greg Sabino Mullane 2025-02-21 15:48:28 Re: Redact user password on pg_stat_statements