Skip to content

Conversation

@jrepp
Copy link
Owner

@jrepp jrepp commented Nov 21, 2025

Summary

  • 36 tests covering HTTP API, WebSocket, and integration scenarios
  • All tests pass with no flakiness detected
  • Integration tests use real Redis and NATS backends
  • Validated across 3 consecutive test runs

Test Coverage

Unit Tests (27 tests)

Server API Tests (15): server_test.go

  • Test creation and initialization
  • HTTP endpoint handlers (start/stop/status/list)
  • JSON serialization and error responses
  • CORS middleware with OPTIONS support
  • Graceful shutdown with nil safety
  • Empty array handling

Executor Tests (12): executor_test.go

  • Test lifecycle management
  • Metrics collection and aggregation
  • WebSocket client management
  • Broadcasting with dead client removal
  • Context cancellation handling

Integration Tests (9 tests)

End-to-end scenarios: integration_test.go

  • Start/stop test lifecycle with real backends
  • WebSocket streaming with live metrics
  • Multiple concurrent WebSocket clients (3 simultaneous)
  • Concurrent tests with unique IDs (microsecond precision)
  • Server shutdown with active tests
  • Dashboard HTTP access
  • CORS headers validation
  • WebSocket reconnection handling
  • Error scenarios (invalid JSON, non-existent tests)

Bugs Fixed During Testing

  1. Test ID collision: Changed format from second to microsecond precision
  2. Nil pointer panic: Added nil check in Shutdown() method
  3. Empty array JSON: Initialize slices with make([]T, 0) instead of var
  4. CORS 405 errors: Added OPTIONS method to all routes
  5. Broadcast race condition: Changed RLock to Lock for client slice modification

Test Results

# Pass 1
PASS - 36 tests, 11.407s

# Pass 2  
PASS - 36 tests, 11.219s

# Pass 3
PASS - 36 tests, 11.246s

Flakiness: None detected across 3 consecutive runs

Test plan

  • Run with go test -v ./...
  • Integration tests require Redis (port 6379) and NATS (port 4222)
  • Use -short flag to skip integration tests
  • All tests pass consistently

Stack

@mergify mergify bot added go Pull requests that update go code size/xs labels Nov 21, 2025
@jrepp jrepp force-pushed the loadtest-server-impl branch from e122fb8 to 7779cc5 Compare November 21, 2025 22:22
@jrepp jrepp force-pushed the loadtest-server-tests branch from 09cb95e to 82aa55a Compare November 21, 2025 22:28
jrepp and others added 2 commits November 21, 2025 14:29
Implement 36 tests covering HTTP API, WebSocket functionality, and
integration scenarios with real Redis/NATS backends. Tests validate
concurrent execution, error handling, CORS, and graceful shutdown.

Coverage:
- 15 unit tests for HTTP API endpoints
- 12 unit tests for test executor and WebSocket
- 9 integration tests with live backends

All tests pass consistently with no flakiness detected across multiple runs.

User request: "implement tests and integration tests for the prism-loadtest binary to validate it's websocket connection and API is working through automated tests that validate the responses of the server under test"

Co-Authored-By: Claude <noreply@anthropic.com>
Changed test ID generation from microsecond to nanosecond timestamps
to prevent collisions when tests start concurrently. Added better error
handling and logging in concurrent test.

User request: "are all of these changes actually tested? let's move through the PRs and run local tests to validate the PR, then check the CI and respond to any code review"

Co-Authored-By: Claude <noreply@anthropic.com>
@jrepp jrepp force-pushed the loadtest-server-tests branch from 82aa55a to a11c7e2 Compare November 21, 2025 22:29
@mergify
Copy link

mergify bot commented Dec 5, 2025

This PR has been inactive for 14 days. Please update it or close it if it's no longer needed.

@mergify mergify bot added stale and removed stale labels Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants