Skip to content

Add hdfs-fixture port placeholder#140042

Closed
mhl-b wants to merge 2 commits intoelastic:mainfrom
mhl-b:hdfs-fixture-port-placeholder
Closed

Add hdfs-fixture port placeholder#140042
mhl-b wants to merge 2 commits intoelastic:mainfrom
mhl-b:hdfs-fixture-port-placeholder

Conversation

@mhl-b
Copy link
Contributor

@mhl-b mhl-b commented Dec 29, 2025

There is a substantial time gap between finding free port and binding it in HDFS fixture, that can lead to java.net.BindException: Address already in use. This PR binds free port until HDFS fixture is ready to start. https://gradle-enterprise.elastic.co/s/inqfl34rgjszo/failures#1

@mhl-b mhl-b requested review from breskeby and smalyshev December 29, 2025 21:00
@mhl-b mhl-b added >test Issues or PRs that are addressing/adding tests Team:Data Management (obsolete) DO NOT USE. This team no longer exists. :Distributed/HDFS HDFS repository issues labels Dec 29, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

MiniDFSNNTopology namenodeTopology = new MiniDFSNNTopology().addNameservice(nameservice);
builder.nnTopology(namenodeTopology);
}
portPlaceholder.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this gets closed on all possible code paths? What if something throws an exception before it gets here?

Also this is still kinda sketchy, it's still possible that something gets the port in between this line and the point where HDFS grabs the port.

Also this is wrapped in a retry loop, see startMinHdfs(), but if something fails after this line then the retry won't have an open portPlaceholder to use. I think we should instead seek a fresh free port on each attempt.

Copy link
Contributor Author

@mhl-b mhl-b Dec 29, 2025

Choose a reason for hiding this comment

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

Acquiring port on retry loop sounds right. But org.elasticsearch.test.fixtures.hdfs.HdfsFixture#getPort() might be called before HDFS setup, so we need either setup HDFS sooner or put a blocker on the port.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you are fine with port placeholder, I can fix missing socket closure on the exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also this is still kinda sketchy

Yeah, it's a step from broken to less broken, but still broken.

Copy link
Contributor Author

@mhl-b mhl-b Dec 29, 2025

Choose a reason for hiding this comment

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

Also, there are only 8 places so far where we create a new fixture, we can manually pick ports.

Copy link
Contributor

Choose a reason for hiding this comment

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

But org.elasticsearch.test.fixtures.hdfs.HdfsFixture#getPort() might be called before HDFS setup

I see, yes that's a problem for the usages in the YAML tests. This is right at the boundary of what one might reasonably achieve with a YAML test, and I don't think these tests particularly matter for other test runners (the main point of YAML tests) so IMO we should address this by migrating them to a ESRestTestCase suite in which we can control the fixture startup order.

If you are fine with port placeholder, I can fix missing socket closure on the exception.

If we allow for retries to acquire a different port, do we need this placeholder to try and reserve the port for longer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me try to refactor to a ESRestTestCase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made progress today, ported half of the YAML tests to the RestTests. Shouldn't take long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll close this PR in favour of moving YAML to Rest PR #140142

@mhl-b mhl-b removed the request for review from breskeby December 31, 2025 06:48
@mhl-b
Copy link
Contributor Author

mhl-b commented Jan 12, 2026

closing in favour of #140142

@mhl-b mhl-b closed this Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/HDFS HDFS repository issues Team:Data Management (obsolete) DO NOT USE. This team no longer exists. >test Issues or PRs that are addressing/adding tests v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants