Skip to content

Conversation

@kpavlov
Copy link
Contributor

@kpavlov kpavlov commented Jan 11, 2026

Refactor integration test infrastructure, fix and enable tests with ts-client

  • Refactor TypeScript integration test infrastructure to support parallel execution and real I/O operations.
  • Extract reusable TypeScriptClient component
  • Migrate some tests from runTest to runBlocking for tests that spawn actual processes and communicate over real network connections.

Key Changes

  • Extract TypeScriptClient class for managing TS client processes

  • Move client scripts to integration-test/src/jvmTest/typescript/client/

  • Migrate typescript: myClient.ts(2) → sse-client.ts, stdio-client.ts

  • Automate TypeScript dependency installation in static initializer

  • Enable JUnit parallel execution (dynamic strategy, concurrent mode) with test timeout of 2 minutes

  • Replace mutableListOf with ConcurrentLinkedQueue for thread-safe notification handling

  • Migrate integration tests from runTest to runBlocking
    Rationale: Integration tests that spawn real TypeScript processes, establish actual
    HTTP/SSE connections, and manage server lifecycles require real-time I/O behavior. The runTest framework's virtual time is designed for fast unit tests with simulated timing, not for integration scenarios where external processes and network communication must occur in real time. Parallel execution requires thread-safe data structures (ConcurrentLinkedQueue)
    to safely collect notifications from multiple concurrent test instances.

  • Add EmbeddedServer.actualPort() extension to get bound port

  • Standardize kotlin.time.Duration usage across test utilities

  • Update processUtils.stopProcess() to accept Duration parameter

  • Replace RuntimeException checks with idiomatic check() calls

  • Revert --rerun-tasks flag to Gradle workflows for reliable builds

Motivation and Context

Integration tests with typescript client are now broken. Enabling parallel test execution will force writing thread-safe independent tests and will highlight problems faster.

How Has This Been Tested?

CI

Breaking Changes

Types of changes

  • CI Update
  • Test Fix

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Follow up for #477

…ts-client

- Refactor TypeScript integration test infrastructure to support parallel execution and real I/O operations.
- Extract reusable TypeScriptClient component
- Migrate some tests from `runTest` to `runBlocking` for tests that spawn actual processes and communicate over real network connections.

  ## Key Changes
  ### TypeScript Client Abstraction
  - Extract TypeScriptClient class for managing TS client processes

  - Move client scripts to integration-test/src/jvmTest/typescript/client/
  - Add npm scripts: client:stdio and client:sse

  ### Parallel Test Execution
  - Enable JUnit parallel execution (dynamic strategy, concurrent mode)
  - Replace `mutableListOf` with `ConcurrentLinkedQueue` for thread-safe notification handling
  - Add @execution(CONCURRENT) annotation to TsEdgeCasesTestSse
  - Set default test timeout to 2 minutes in junit-platform.properties

  ### Test Infrastructure Simplification

  - Eliminate sdkDir parameter and dependency injection across tests
  - Automate TypeScript dependency installation in static initializer

  ### Real I/O Support
  - Migrate integration tests from runTest to runBlocking(Dispatchers.IO)
  - Remove withContext wrappers for cleaner code structure
  - Use runBlocking for tests with real HTTP, SSE, and process I/O
  Rationale: Virtual time in runTest is inappropriate for integration
    tests requiring real network timing and external process coordination

  ### Utilities & Extensions
  - Add `EmbeddedServer.actualPort()` extension to get bound port
  - Standardize kotlin.time.Duration usage across test utilities
  - Update processUtils.stopProcess() to accept Duration parameter
  - Replace RuntimeException checks with idiomatic check() calls

  ### Test Reliability
  - Generate unique resource URIs using UUIDs for test isolation
  - Fix script references: myClient.ts → sse-client.ts, stdio-client.ts

  ### CI/CD
  - Add --rerun-tasks flag to Gradle workflows for reliable builds

  ## Rationale

  Integration tests that spawn real TypeScript processes, establish actual
  HTTP/SSE connections, and manage server lifecycles require real-time I/O
  behavior. The runTest framework's virtual time is designed for fast unit
  tests with simulated timing, not for integration scenarios where external
  processes and network communication must occur in real time.

  Parallel execution requires thread-safe data structures (ConcurrentLinkedQueue)
  to safely collect notifications from multiple concurrent test instances.
@kpavlov kpavlov added tests bugfix Something was fixed 🎉 refactoring Making things better labels Jan 11, 2026
@kpavlov kpavlov marked this pull request as ready for review January 11, 2026 07:35
@kpavlov kpavlov merged commit 6ad9bf2 into main Jan 11, 2026
17 checks passed
@kpavlov kpavlov deleted the kpavlov/fix-ts-client-tests branch January 11, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Something was fixed 🎉 refactoring Making things better tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants