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

Adapt TheFlintstonesTest to IPv6 testing environments #183

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

imonteroperez
Copy link
Contributor

Highlights

  • This PR adapts the execution of TheFlintstonesTest for IPv6 testing environments
  • It makes feasible to use the overrided DNS as dns://[0:0:0:0:0:0:0:1]:32780

Testing done

  • Tested via PCT under IPv4 and IPv6 environments and working as expected.

Submitter checklist

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.

code appears to make some incorrect assumptions, and instead should switch on the type if InetAddress it obtains, or just not even bother and use the API

@@ -98,7 +98,11 @@ public void overrideDNS() throws Exception {
// see hudson.plugins.active_directory.ActiveDirectoryDomain.createDNSLookupContext()
// getHost returns a hostname not IPaddress...
// use our DNS to resolve that to an IP address.
String DNS_URLs = "dns://"+InetAddress.getByName(docker.getHost()).getHostAddress()+":"+docker.getDNSPort();
String hostAddress = InetAddress.getByName(docker.getHost()).getHostAddress();
if (Boolean.getBoolean("java.net.preferIPv6Addresses")) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this would break on IPv6 only hosts?
as you are getting an InetAddress, you can already know if you have a v4 or v6 address and react accordingly and do not use the system property.

e.g.

InetAddress inAddr = InetAddress.getByName(docker.getHost());
if (inAddr instanceof Inet6Address) {
 //...
 } else {
  /....
}

now if you want to do something based on a preference, you should be asking for all addresses (getAllByName()), and looking for the one according to the preference - but there may not be one... But YAGNI

or just stop building URLs by hand... and embrace the APIs
new URI("dns", null, docker.getHost()).getHostAddress(), docker.getDNSPort(), null, null, null).toASCIIString();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 7690fd7

@jtnord jtnord merged commit 7a4fb4c into jenkinsci:master Feb 14, 2024
0 of 2 checks passed
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.

2 participants