Skip to content

Add tests for dns unreachable and fix hang#28

Merged
chibenwa merged 6 commits into
apache:masterfrom
epinter:fix-loop
Feb 6, 2025
Merged

Add tests for dns unreachable and fix hang#28
chibenwa merged 6 commits into
apache:masterfrom
epinter:fix-loop

Conversation

@epinter
Copy link
Copy Markdown
Contributor

@epinter epinter commented Jan 22, 2025

This PR adds tests to reproduce DNS unreachable condition which causes a hang when async executor is in use, works flawlessly with sync.

@epinter epinter marked this pull request as draft January 22, 2025 16:30
@epinter epinter marked this pull request as ready for review January 22, 2025 16:53
@epinter
Copy link
Copy Markdown
Contributor Author

epinter commented Jan 22, 2025

Test running in Jenkins is really returning "none" ? Anybody knows why ? Mine returns "temperror", running on linux.

14:05:46.066 [ERROR] o.a.j.j.i.SPF - null
java.net.PortUnreachableException: null
	at java.base/sun.nio.ch.DatagramDispatcher.read0(Native Method)
	at java.base/sun.nio.ch.DatagramDispatcher.read(DatagramDispatcher.java:43)
	at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:245)
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:223)
	at java.base/sun.nio.ch.DatagramChannelImpl.read(DatagramChannelImpl.java:610)
	at org.xbill.DNS.NioUdpClient$Transaction.processReadyKey(NioUdpClient.java:122)
	at org.xbill.DNS.NioClient.processReadyKeys(NioClient.java:182)
	at org.xbill.DNS.NioClient.runSelector(NioClient.java:134)
	at java.base/java.lang.Thread.run(Thread.java:829)
temperror

Received-SPF: temperror (spfCheck: Error in retrieving data from DNS) client-ip=207.54.72.202; envelope-from=do_not_reply@reyifglerifwukfvbdjhrkbvebvekvfulervkerkeruerbeb.de; helo=reyifglerifwukfvbdjhrkbvebvekvfulervkerkeruerbeb.de;

Jenkins output:

org.junit.ComparisonFailure: expected:<[temperror]> but was:<[none]>
	at org.apache.james.jspf.SynchronousSPFExecutorIntegrationTest.shouldReturnTempErrorOnPortUnreachable(SynchronousSPFExecutorIntegrationTest.java:96)
Setting default resolver
none

Received-SPF: none (spfCheck: 207.54.72.202 is neither permitted nor denied by domain of reyifglerifwukfvbdjhrkbvebvekvfulervkerkeruerbeb.de) client-ip=207.54.72.202; envelope-from=do_not_reply@reyifglerifwukfvbdjhrkbvebvekvfulervkerkeruerbeb.de; helo=reyifglerifwukfvbdjhrkbvebvekvfulervkerkeruerbeb.de;

NVM: It was the cache

@epinter
Copy link
Copy Markdown
Contributor Author

epinter commented Jan 22, 2025

I've found another hang, but It's hard to create a test and depend on real DNS. I will open another PR for you to review the solution, because I will add a class to simulate a real DNS.

@epinter epinter changed the title Add tests for dns unreachable and fix infinite loop Add tests for dns unreachable and fix hang Jan 23, 2025
Copy link
Copy Markdown
Contributor

@chibenwa chibenwa left a comment

Choose a reason for hiding this comment

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

Thanks for the GREAT contribution, it looks awesome!

Comment on lines +99 to +101
System.out.println(result.getResult());
System.out.println(result.getExplanation());
System.out.println(result.getHeader());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can get rid of those System.out.println ?

Comment on lines +100 to +102
System.out.println(result.getResult());
System.out.println(result.getExplanation());
System.out.println(result.getHeader());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Idem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In some tests like these, the details helps sometimes. Do you prefer I replace all these println with logger instead of remove them ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could replace those with assertions so that the test reader get it in the source code of the test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right. I will replace with assert the most relevant, and remove others.

@chibenwa
Copy link
Copy Markdown
Contributor

(on a side note I would like to really thank you for your contributions to JSPF. Your help is much appreciated.
Feel free to contact me on btellier@apache.org, I'd be happy to discuss your use cases, and discuss your contributions to JSPF).

@epinter
Copy link
Copy Markdown
Contributor Author

epinter commented Jan 23, 2025

(on a side note I would like to really thank you for your contributions to JSPF. Your help is much appreciated. Feel free to contact me on btellier@apache.org, I'd be happy to discuss your use cases, and discuss your contributions to JSPF).

Thank you :)
I'm a user of the library, and while I see I can contribute with something I will. It's a way to recognize all the work you and your team put in software like this.

The tests with hostname without dot are beign ignored.
When a PortUnreachableException or SocketException happens, a temperror
should be returned.
This NPE happens when a PortUnreachableException (that doesn't have a
message) is received in the exceptionally block, but other exceptions
without a message also can trigger this bug. Also added the null check
for e.getCause(), just in case.
Situations like a port unreachable should be considered a temperror by
async executor, like the sync does.
@epinter
Copy link
Copy Markdown
Contributor Author

epinter commented Jan 24, 2025

Sorry for the force-push after the approval, but the commit "Fix tests hostname so they are not skipped" had an error, I didn't want it to be merged and have to create another fix after...

Copy link
Copy Markdown
Contributor

@chibenwa chibenwa left a comment

Choose a reason for hiding this comment

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

No worry, the change set is rather small and still easy to understand (good commit history).

@epinter
Copy link
Copy Markdown
Contributor Author

epinter commented Feb 6, 2025

Hi !
Do you know when the PR will be merged ? I have 2 more bugs I found on Async Executor, but I want to send another PR because I don't know if you will approve the method I used to test.

@chibenwa
Copy link
Copy Markdown
Contributor

chibenwa commented Feb 6, 2025

Hello,
Sorry it pretty much went out of the radar...
I guess I did not merged it straight away to let others a chance to review.

I have 2 more bugs I found on Async Executor, but I want to send another PR because I don't know if you will approve the method I used to test.

Please go ahead!

@chibenwa chibenwa merged commit 862496e into apache:master Feb 6, 2025
@epinter
Copy link
Copy Markdown
Contributor Author

epinter commented Feb 6, 2025

Hello, Sorry it pretty much went out of the radar... I guess I did not merged it straight away to let others a chance to review.

I have 2 more bugs I found on Async Executor, but I want to send another PR because I don't know if you will approve the method I used to test.

Please go ahead!

No problem. Thanks !

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