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

OF-2559: Use Netty for LocalIncomingServerSessionTest #2232

Merged
merged 7 commits into from
Aug 29, 2023

Conversation

guusdk
Copy link
Member

@guusdk guusdk commented Aug 3, 2023

Prior to this commit, the unit test for LocalIncomingServerSession used the old, pre-Netty code. With this commit, the Netty code is being used instead.

Insteead of the old blocking code, the test now uses a (Netty-backed) ConnectionListener directly. To identify the LocalIncomingServderSession instance that is to be created, a streamID value is used, which is collected by the dummy server peer implementation for that purpose.

@guusdk
Copy link
Member Author

guusdk commented Aug 3, 2023

I'm slighly concerned by the removal of the now-unused ConnectionConfigurationAnswer method in the test fixture. Shouldn't that be needed?

For me locally, all these tests are green when this PR is combined with the changes from #2229, #2230 and #2231.

Copy link
Collaborator

@AlexGidman AlexGidman left a comment

Choose a reason for hiding this comment

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

Changes make sense: tests not passing without other changes mentioned so should probably wait until they have also been merged.

Can we delete SocketAcceptThread, BlockingAcceptingMode, SocketAcceptingMode, and ServerSocketReader now? It looks like these are all no longer used.

Some elements of the former implementation (SocketConnection etc) are still used for ServerDialback and other features of Openfire (perhaps these can be ticketed in OF Jira?)

@guusdk guusdk force-pushed the OF-2559_Use-Netty-for-S2S-unittest branch from 8fcee2e to 7e0c1d4 Compare August 4, 2023 09:28
@guusdk
Copy link
Member Author

guusdk commented Aug 4, 2023

I very much want the old networking code to be removed, but didn't want to do it as part of this PR. As per @AlexGidman's suggestion, I have raised a new JIRA ticket for the removal effort: https://igniterealtime.atlassian.net/browse/OF-2635

The review suggestions were applied, and this PR has been rebased on the latest main.

@guusdk guusdk force-pushed the OF-2559_Use-Netty-for-S2S-unittest branch from fbdd25c to 6065103 Compare August 4, 2023 19:31
@guusdk
Copy link
Member Author

guusdk commented Aug 4, 2023

My optimizations seem to have improved the LocalIncomingServerSessionTest (unexpectedly), but have also made the LocalOutgoingServerSessionTest fail its 13'th test - but only if it is run as part of multiple tests. I'm guessing that I've somehow made tests interdependant (which is bad).

Prior to this commit, the unit test for LocalIncomingServerSession used the old, pre-Netty code. With this commit, the Netty code is being used instead.

Insteead of the old blocking code, the test now uses a (Netty-backed) ConnectionListener directly. To identify the LocalIncomingServderSession instance that is to be created, a streamID value is used, which is collected by the dummy server peer implementation for that purpose.
By calculating a 'valid' identity store (with a 'valid' certificate), each test no longer needs to recompute these instances.

Profiling indicates that this saves roughly 66% of the CPU time spent in the LocalIncomingServerSessionTest
By re-using a ByteBuffer, instead of re-allocating a new byte[] for each read, the amount of memory allocations is changes from thousands of gigabytes to hundreds of megabytes.
As the unit test is being executed on a local network connection, we can reduce the session initialise timeout considerably. This makes tests that depend on that timeout execute in 20% of the time, which is a considerable runtime improvement.
@guusdk guusdk force-pushed the OF-2559_Use-Netty-for-S2S-unittest branch from 6065103 to 5486250 Compare August 28, 2023 13:47
This prevents stack overflow when the getters use the toString implementation (for example, for debug logging).
@guusdk guusdk force-pushed the OF-2559_Use-Netty-for-S2S-unittest branch from 4ede455 to eaa329c Compare August 28, 2023 17:55
Make sure to set 'authenticated' only after the internal state of 'session' itself is updated, to avoid race conditions.
@guusdk
Copy link
Member Author

guusdk commented Aug 28, 2023

Ah, I suspect that the new tests were failing off and on again from a race condition, not because session state was carried over. The race condition is fixed in commit 8f2f4f2

@guusdk guusdk force-pushed the OF-2559_Use-Netty-for-S2S-unittest branch from 15c4a76 to e4289f2 Compare August 29, 2023 13:53
@guusdk
Copy link
Member Author

guusdk commented Aug 29, 2023

This PR is running into issues that are likely addressed in another PR: #2226. That PR is running into issues fixed by this PR.

To resolve this chicken/egg problem, I'm going to merge this PR, and rebase the other PR.

@guusdk guusdk merged commit e5d8866 into igniterealtime:main Aug 29, 2023
4 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.

3 participants