Skip to content

Implement a custom test runner for buck test #145

@vmagro

Description

@vmagro

buck test has provisions for running with a custom test runner (see https://buck.build/files-and-dirs/buckconfig.html#test.external_runner)

Benefits

A custom test runner would give us a lot of control over how tests are run

  • failing tests could be retried
  • consistently-failing tests can be marked as disabled (can be stored in a text file in the repo)
  • test parallelism can be controlled (eg 1 process per test case, up to $(nproc) at a time)

Implementation details

  • The buck config docs linked above describe the input that buck itself provides.
  • The test runner would need to parse the buck-provided JSON file, and then have a switch based on the type to determine how to execute the test.
  • The test runner should support pretty html output like we have today (e8bf770)
    • this can be done by either implementing an output format understood by the workflow we use now https://github.com/dorny/test-reporter#supported-formats (jest-junit is probably the best documented)
    • alternatively, you can just re-implement the functionality of that test reporter to create a status check with the github api and render some html however you want
  • Automatic disabler (the test state machine) can be implemented as a periodically scheduled GitHub Action that looks at the past N days of test workflow runs and marks tests that have failed 3 times in a row (or some other threshold) as disabled (it can either submit a PR to a text file in the repo, or use a DB in AWS to track state)

Desired features

Features can be added in stages, the bare minimum for the first revision is a test runner that implements Python unit tests, and outputs a single pass/fail for the test target based on the return code obtained from just running the pex.

  1. Parse buck test json, run each target and produce an output entry for the entire test target based on the returncode
  2. Parse the individual test target output to produce output entries for each individual test case
  3. List tests out of the test target binaries before running and run them in parallel
  4. cli flag to retry failed tests (this can be passed to the runner through buck test as described in the docs)
  5. Runner should not execute disabled test cases unless given a special --run-disabled flag
  6. GitHub Actions workflow to read old test result artifacts and submit a PR / write to an AWS DB to mark consistently failing tests as disabled

Metadata

Metadata

Assignees

No one assigned

    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