Skip to content

e2e test concurrency fixes#913

Merged
spacebear21 merged 4 commits intopayjoin:masterfrom
nothingmuch:e2e-concurrency-fixes
Aug 4, 2025
Merged

e2e test concurrency fixes#913
spacebear21 merged 4 commits intopayjoin:masterfrom
nothingmuch:e2e-concurrency-fixes

Conversation

@nothingmuch
Copy link
Collaborator

This PR addresses two race conditions in the e2e tests:

Free Port Assignment

Each test tried to bind a free port, and then remembered the number passing it in to the --port option of payjoin-cli. There is a brief window where the port is unbound, allowing the same number to be given to both tests concurrently.

Instead the payjoin-cli can be given --port 0, binding a free port on its own, and will now use this port when generating a payjoin URI.

Self Signed Certificate Isolation

The self signed certificate was written to e.g. /tmp/localhost.der, so concurrent cargo test runs as well as concurrent tests within a test run overwrote each others certificate.

This issue was mostly hidden by the redis test container delaying startup for the v2 test, typically long enough for the v1 test's server and clients to be be initialized consistently.

When binding a socket address with port 0, the OS will allocate a free
port. The --port CLI argument supports doing this, but the bound port
number was not used in any way.

This change checks that if --port 0 is specified, --pj-endpoint does not
specify a port, and sets the port to the assigned to the listener by the
OS before generating payjoin payment URI.
@nothingmuch nothingmuch requested a review from spacebear21 August 2, 2025 21:57
@nothingmuch nothingmuch force-pushed the e2e-concurrency-fixes branch from 763d377 to c8441f2 Compare August 2, 2025 22:02
@nothingmuch nothingmuch force-pushed the e2e-concurrency-fixes branch 2 times, most recently from b4f1f62 to 04f6c09 Compare August 2, 2025 22:07
Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 04f6c09, some minor code suggestions below.

This solves a very annoying issue I was vaguely aware of but could never get to the bottom of. Thank you muchly

This change adds --root-certificate and --certificate-key CLI options,
primarily intended for testing.

This avoids reading from /tmp/localhost.der as e2e tests previously did,
which technically requires `--test-threads 1` to work reliably (in
practice this was rarely an issue to to latency in starting the redis
test container)
@nothingmuch nothingmuch force-pushed the e2e-concurrency-fixes branch from 04f6c09 to e3f1cdc Compare August 4, 2025 14:04
Co-authored-by: spacebear <git@spacebear.dev>
Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 666b816

@spacebear21 spacebear21 merged commit e9ba669 into payjoin:master Aug 4, 2025
10 checks passed
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 16698166812

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 78 of 104 (75.0%) changed or added relevant lines in 5 files are covered.
  • 33 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.06%) to 85.965%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/v2/ohttp.rs 8 9 88.89%
payjoin-cli/src/app/v1.rs 25 29 86.21%
payjoin-cli/src/app/config.rs 12 17 70.59%
payjoin-cli/src/app/v2/mod.rs 22 38 57.89%
Files with Coverage Reduction New Missed Lines %
payjoin-cli/src/app/mod.rs 2 94.12%
payjoin-cli/src/app/v1.rs 31 77.0%
Totals Coverage Status
Change from base Build 16682297890: -0.06%
Covered Lines: 8030
Relevant Lines: 9341

💛 - Coveralls

@coveralls
Copy link
Collaborator

coveralls commented Aug 4, 2025

Pull Request Test Coverage Report for Build 16725717260

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 84 of 110 (76.36%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 85.961%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/mod.rs 12 13 92.31%
payjoin-cli/src/app/v2/ohttp.rs 8 9 88.89%
payjoin-cli/src/app/v1.rs 30 33 90.91%
payjoin-cli/src/app/config.rs 12 17 70.59%
payjoin-cli/src/app/v2/mod.rs 22 38 57.89%
Totals Coverage Status
Change from base Build 16682297890: -0.06%
Covered Lines: 8021
Relevant Lines: 9331

💛 - Coveralls

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 16698130213

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 78 of 104 (75.0%) changed or added relevant lines in 5 files are covered.
  • 33 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.06%) to 85.965%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/v2/ohttp.rs 8 9 88.89%
payjoin-cli/src/app/v1.rs 25 29 86.21%
payjoin-cli/src/app/config.rs 12 17 70.59%
payjoin-cli/src/app/v2/mod.rs 22 38 57.89%
Files with Coverage Reduction New Missed Lines %
payjoin-cli/src/app/mod.rs 2 94.12%
payjoin-cli/src/app/v1.rs 31 77.0%
Totals Coverage Status
Change from base Build 16682297890: -0.06%
Covered Lines: 8030
Relevant Lines: 9341

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants