Skip to content

Make E2E test timeouts configurable via environment variables #28

@justin808

Description

@justin808

Description

Currently, E2E test timeout values are hardcoded as class constants. This works well for local development but may need adjustment in different environments (CI, slower machines, Docker containers, etc.).

Proposed Changes

Make timeout values configurable via environment variables with sensible defaults:

class E2eTestRunner
  # Port availability polling configuration
  DEFAULT_PORT = ENV.fetch('E2E_TEST_PORT', 3000).to_i
  PORT_CHECK_MAX_ATTEMPTS = ENV.fetch('E2E_PORT_CHECK_MAX_ATTEMPTS', 10).to_i
  PORT_CHECK_INTERVAL = ENV.fetch('E2E_PORT_CHECK_INTERVAL', 0.5).to_f
  
  # ...
end

class ServerManager
  DEFAULT_PORT = ENV.fetch('E2E_TEST_PORT', 3000).to_i
  MAX_STARTUP_ATTEMPTS = ENV.fetch('E2E_SERVER_MAX_STARTUP_ATTEMPTS', 60).to_i
  STARTUP_CHECK_INTERVAL = ENV.fetch('E2E_SERVER_CHECK_INTERVAL', 1).to_i
  INITIAL_STARTUP_DELAY = ENV.fetch('E2E_SERVER_INITIAL_DELAY', 2).to_i
  HTTP_OPEN_TIMEOUT = ENV.fetch('E2E_HTTP_OPEN_TIMEOUT', 2).to_i
  HTTP_READ_TIMEOUT = ENV.fetch('E2E_HTTP_READ_TIMEOUT', 2).to_i
  
  # ...
end

CI Configuration Example:

# .github/workflows/ci.yml
env:
  E2E_SERVER_MAX_STARTUP_ATTEMPTS: 120  # CI servers may be slower
  E2E_HTTP_OPEN_TIMEOUT: 5              # Allow more time for cold starts
  E2E_HTTP_READ_TIMEOUT: 5

Benefits:

  • Flexibility: Adjust timeouts without code changes
  • CI Optimization: Different values for different environments
  • Debugging: Increase timeouts temporarily to diagnose issues
  • Performance: Decrease timeouts in fast environments
  • Documentation: Environment variables serve as configuration documentation

Implementation Considerations:

  • Maintain backward compatibility with existing defaults
  • Add validation for reasonable value ranges (prevent negative timeouts)
  • Document all environment variables in README or docs
  • Consider adding a warning when using non-default values
  • Test that environment variables are properly read

Related

Priority

Medium - Would significantly improve CI/CD flexibility and debugging capabilities.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions