Skip to content

Conversation

@Zargess
Copy link
Collaborator

@Zargess Zargess commented Jul 15, 2025

Server

Testability

Made the Server class more testable by storing created worker threads, and made it possible to extract worker threads as well as ConversationHandler and ConversationHandler thread.

Daemons

Made created worker threads into daemons to make sure they are stopped when the main thread of the Fagi Server is stopped.

Testing the Server class

The Server class is now tested with 100% test coverage.

Issues

PI test is flaky around setDaemon(true) on threads. This will be ignored for now.

Data

Made it possible to get the value of nextConversationId to help test loading of Conversations when starting the Server.

PI test configuration

Upgraded junit5PluginVersion from 1.2.1 to 1.2.2

@Zargess Zargess requested a review from miniwolf July 15, 2025 20:13
@Zargess Zargess force-pushed the dev/zargess/server-tests branch from 7bd86b5 to cb7c198 Compare July 15, 2025 20:14
@Zargess Zargess changed the base branch from develop to dev/zargess/outputworker-tests July 16, 2025 13:29
Base automatically changed from dev/zargess/outputworker-tests to develop July 16, 2025 14:35
@Zargess Zargess force-pushed the dev/zargess/server-tests branch from cb7c198 to 1095490 Compare July 16, 2025 14:37
Changes introduced to make the Server class more testable

## IsRunningStrategy

Interfaces renamed to make it more general, to be used by both Worker and Server. It is also moved out of the worker package to make it for more general use.

### CheckFieldServerRunningStrategy

Made a strategy for the Server class that checks the Server#isRunning method to return if the server is running.

## Server Socket

Made the main method give ServerSocket to the start method of Server to make it easier to test.

## Storing threads

As the Server creates several threads during execution, fields have been created to store these threads, to check if they were created. Could later be used to clean up running threads before the Fagi Server stops.
The worker threads, created by the Server, was not set as daemons, meaning they would survive the closure of the fagi server. This is now fixed, such that the threads are set as daemons.
## Testing the Server class

The Server class is now tested with 100% test coverage.

### Issues

PI test is flaky around setDaemon(true) on threads. This will be ignored for now.

## Moved utility function

The Server class had a utility function to find public ip v4. This has been moved to a utility class in shared.

## RunOnceStrategy

The implementation of IsRunningStrategy that runs once in tests has been renamed from WorkerRunOnceStrategy to RunOnceStrategy. This has been done as tests of the Server class now also utilises it.

## Data

Made it possible to get the value of nextConversationId to help test loading of Conversations when starting the Server.

 ## PI test configuration

 Upgraded junit5PluginVersion from 1.2.1 to 1.2.2
@Zargess Zargess force-pushed the dev/zargess/server-tests branch from 1095490 to f4a4741 Compare August 10, 2025 12:12
@Zargess Zargess changed the title Dev/zargess/server tests Server tests Aug 10, 2025
@Zargess Zargess changed the title Server tests Server class tests Aug 10, 2025
Copy link
Owner

@miniwolf miniwolf left a comment

Choose a reason for hiding this comment

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

LGTM

@Zargess Zargess merged commit b6e3ea7 into develop Sep 16, 2025
3 checks passed
@Zargess Zargess deleted the dev/zargess/server-tests branch September 16, 2025 14:58
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