Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to write the listening port to a file #174

Merged
merged 13 commits into from
Mar 8, 2022

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Nov 18, 2021

The context for this pull request are test flakes observed both in RealJenkinsRule based tests, as well as running ATH with multiple controllers launched.

In both cases, a random port was generated then passed to winstone. The problem is that by the time Jetty tries to bind this port, it could become used by another instance.

This is taking another aproach:

  • pass --httpPort=0 to winstone, let Jetty allocate a random free port
  • pass the system property winstone.portFileName. In that case, winstone will write the used port in that file.

This file can then be used by RealJenkinsRule or the ATH to obtain the actual port to use to access the instance.

To test this change

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@jglick
Copy link
Member

jglick commented Nov 18, 2021

This file can then be used by RealJenkinsRule

Unfortunately no, it cannot: jenkinsci/jenkins-test-harness#347 (comment)

Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

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

looks good but there is a discrepancy around charsets that the file is written in.

src/main/java/winstone/Launcher.java Outdated Show resolved Hide resolved
src/main/java/winstone/Launcher.java Outdated Show resolved Hide resolved
Copy link
Member

@olamy olamy left a comment

Choose a reason for hiding this comment

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

I would prefer a command line option (Option class) but yeah not sure this will be used a lot :) )

@Vlatombe
Copy link
Member Author

Vlatombe commented Nov 19, 2021

not sure this will be used a lot

Yes, I thought this would only be used for testing. I can turn it into an option if you prefer, but for now I wanted to see whether the whole thing was viable.

@olamy
Copy link
Member

olamy commented Nov 19, 2021

not sure this will be used a lot

Yes, I thought this would only be used for testing. I can turn it into an option if you prefer, but for now I wanted to see whether the whole thing was viable.

no worries all good

@olamy
Copy link
Member

olamy commented Nov 20, 2021

@Vlatombe looks to be ready or still a draft?

Co-authored-by: Jesse Glick <jglick@cloudbees.com>
@Vlatombe
Copy link
Member Author

looks to be ready or still a draft?

I want to ensure all downstream usages can be converted reasonably before considering this is ready to merge.

@Vlatombe
Copy link
Member Author

Vlatombe commented Mar 7, 2022

Refreshed this work as unfortunately jenkinsci/jenkins-test-harness#347 is not enough to prevent port collisions.

@Vlatombe Vlatombe marked this pull request as ready for review March 7, 2022 09:22
@Vlatombe Vlatombe requested review from jglick, olamy and jtnord March 7, 2022 09:22
src/main/java/winstone/Launcher.java Outdated Show resolved Hide resolved
src/test/java/winstone/HttpConnectorFactoryTest.java Outdated Show resolved Hide resolved
src/test/java/winstone/HttpConnectorFactoryTest.java Outdated Show resolved Hide resolved
@Vlatombe Vlatombe requested a review from jglick March 8, 2022 09:16
@Vlatombe Vlatombe merged commit ef3a4b9 into jenkinsci:master Mar 8, 2022
@Vlatombe Vlatombe deleted the writePortToFile branch March 8, 2022 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants