Skip to content

WIP: Enable shared clients on testsuite level #1285

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

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

danceratopz
Copy link
Member

@danceratopz danceratopz commented May 12, 2025

This PR adds support for "shared clients", a new type of client that allows the client's instance (container) to be reused across multiple tests within a test suite. The aim is to preserve client state between tests in order to allow multiple EL tests to be executed against a single running client container to avoid client start-up time and speed-up testing.

Backend

  • Added shared client API in hivesim/hive.go with methods: StartSharedClient and GetSharedClientInfo.
  • Implemented suite-level client management in hivesim/testapi.go with AddSharedClient and GetSharedClient.
  • Created necessary data structures in hivesim/data.go for tracking shared client state.
  • Added log management for shared clients, allowing logs to be segmented on a per-test basis.
  • Ensured proper cleanup of shared client containers when a test suite ends.
  • Added line number calculation for log segments to use for client log UI display

Frontend

  • Updated the test report UI to display links to shared client logs
  • Added support for line-based log highlighting instead of byte offsets -> Entire log is displayed but link highlights and scrolls to the log segement of interest.

Testing

  • Added dedicated unit tests in shared_client_test.go that cover all major functionality:
    • TestStartSharedClient: Tests client creation at the suite level
    • TestAddSharedClient: Tests client registration and retrieval in tests
    • TestSharedClientLogOffset: Tests log position tracking
    • TestSharedClientLogExtraction: Tests log segmentation
    • TestGetClientLogOffset: Tests the log offset API

danceratopz and others added 9 commits July 2, 2025 18:57
This commit implements shared client functionality to improve resource
efficiency by allowing clients to be reused across multiple tests in a
test suite. Key features include:

- New API endpoints for shared client management
- Data structures for tracking shared client state
- Log segment extraction for proper test result attribution
- Integration with hiveview for log display
- Documentation updates for all new methods and types
Added comprehensive unit tests for shared client functionality, including:
- TestStartSharedClient - Tests the StartSharedClient method
- TestAddSharedClient - Tests shared client registration in suites
- TestSharedClientLogOffset - Tests log offset tracking
- TestSharedClientLogExtraction - Tests log extraction
- TestGetClientLogOffset - Tests the GetClientLogOffset function

Also added ExecSharedClient method to Simulation type to support executing commands in shared clients
…stances

When multiple clients of the same type exist in a suite, auto-registration now selects the most recently created client instead of skipping registration entirely. This ensures that tests properly register with a shared client even when multiple instances of the same client type are running.
Add line number tracking to shared client log segments to enable proper highlighting in the UI. Adds a line counting algorithm to convert byte positions to line numbers and enhances related data structures.
Updates the UI to properly display log links for shared clients with line range highlighting. Enhances client detection logic to work with multiple client instances of the same type, and improves the log viewer to properly highlight line ranges.
}

// ClientLogSegment represents a segment of a client log file
type ClientLogSegment struct {
Copy link
Member

Choose a reason for hiding this comment

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

I tried to make sense of all the logging situation but I could not quite figure it out.

IMO I think it's not really functional at this point and we should just remove it from this PR and add it in a follow-up PR.

hivesim/data.go Outdated
Comment on lines 27 to 30
type LogOffset struct {
Start int64 `json:"start"` // Byte offset where this section begins
End int64 `json:"end"` // Byte offset where this section ends
}
Copy link
Member

Choose a reason for hiding this comment

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

This slipped, it's no longer necessary I think.

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