Skip to content

Conversation

maurice2k
Copy link
Owner

This commit introduces a significant number of improvements to the ab-proxy tool:

  1. Go Version Compatibility:

    • Ensured the project builds and runs correctly with Go 1.22.2.
    • Updated go.mod to specify go 1.22.2.
    • Dependencies were verified to be compatible, and go.sum was updated.
  2. Refactoring for Testability:

    • The main application logic in ab-proxy.go was refactored.
    • Core benchmarking functionality was moved into a runBenchmark function.
    • Global state for options, statistics, and error collection was encapsulated into structs (Options, Stats, ErrorCollector), making the code more modular and testable.
  3. Unit Tests:

    • Added extensive unit tests in ab_proxy_test.go.
    • These tests cover argument parsing, default value handling, header preparation, proxy configuration logic, URL validation, and the ErrorCollector functionality.
  4. Integration Tests:

    • Introduced mock HTTP target and HTTP proxy servers (mockservers_test.go) to simulate real-world scenarios.
    • Added a comprehensive suite of integration tests in ab_proxy_integration_test.go.
    • These tests execute ab-proxy as a subprocess and verify its behavior against the mock servers, covering:
      • Basic GET requests and statistics reporting.
      • Custom User-Agent and header propagation.
      • Client-side timeout functionality.
      • HTTP proxying.
      • Handling of target server errors (e.g., HTTP 500).
      • Error reporting for connection failures (e.g., connection refused) using --show-errors.
      • Functionality of multiple bursts and delays.
  5. Dockerization for Testing:

    • Added a Dockerfile that creates a containerized environment with Go 1.22.2.
    • The Dockerfile is configured to build the application and run all unit and integration tests.
    • All tests were confirmed to pass within this Docker environment.

These changes enhance the reliability and maintainability of ab-proxy by providing a strong testing foundation and ensuring compatibility with an updated Go version.

This commit introduces a significant number of improvements to the ab-proxy tool:

1.  Go Version Compatibility:
    *   Ensured the project builds and runs correctly with Go 1.22.2.
    *   Updated `go.mod` to specify `go 1.22.2`.
    *   Dependencies were verified to be compatible, and `go.sum` was updated.

2.  Refactoring for Testability:
    *   The main application logic in `ab-proxy.go` was refactored.
    *   Core benchmarking functionality was moved into a `runBenchmark` function.
    *   Global state for options, statistics, and error collection was encapsulated into structs (`Options`, `Stats`, `ErrorCollector`), making the code more modular and testable.

3.  Unit Tests:
    *   Added extensive unit tests in `ab_proxy_test.go`.
    *   These tests cover argument parsing, default value handling, header preparation, proxy configuration logic, URL validation, and the `ErrorCollector` functionality.

4.  Integration Tests:
    *   Introduced mock HTTP target and HTTP proxy servers (`mockservers_test.go`) to simulate real-world scenarios.
    *   Added a comprehensive suite of integration tests in `ab_proxy_integration_test.go`.
    *   These tests execute `ab-proxy` as a subprocess and verify its behavior against the mock servers, covering:
        *   Basic GET requests and statistics reporting.
        *   Custom User-Agent and header propagation.
        *   Client-side timeout functionality.
        *   HTTP proxying.
        *   Handling of target server errors (e.g., HTTP 500).
        *   Error reporting for connection failures (e.g., connection refused) using `--show-errors`.
        *   Functionality of multiple bursts and delays.

5.  Dockerization for Testing:
    *   Added a `Dockerfile` that creates a containerized environment with Go 1.22.2.
    *   The Dockerfile is configured to build the application and run all unit and integration tests.
    *   All tests were confirmed to pass within this Docker environment.

These changes enhance the reliability and maintainability of `ab-proxy` by providing a strong testing foundation and ensuring compatibility with an updated Go version.
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.

1 participant