SFDO-Tooling / CumulusCI

Python framework for building portable automation for Salesforce projects

Home Page:http://cumulusci.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error running `run_tests` task

cdelmoral opened this issue · comments

Describe the bug

When running a lot of apex tests in parallel some tests may fail with the following error:

Could not run tests on class <ApexClassId> because: connection was cancelled here

Sometimes when this happens the ApexTestResult.MethodName will be empty, as can be seen in the following screenshots:

Screenshot 2023-06-02 at 22 06 17

Screenshot 2023-06-02 at 22 05 55

I'm not sure if this happens for a specific reason, but I wasn't able to consistently get an empty ApexTestResult.MethodName back.

In any case, this makes the following line throw an exception: testrunner.py#L417, since the test results are tracked by MethodName testrunner.py#L346-L348.

Possible solutions could be:

  1. Handle the None cases when sorting the list of method names
  2. Not adding test results to the dictionary when MethodName is None
  3. Add a filter to this query to only query results with a MethodName defined

Let me know if there is a preference, happy to get a pull request started.

Reproduction steps

  1. Run a lot of apex tests in parallel using the task run_tests, so that some of them fail with Could not run tests on class <ApexClassId> because: connection was cancelled here
  2. If one of the failed ApexTestResult has an empty MethodName, continue, otherwise start from the beginning

Expected behavior:

  • Test results are displayed correctly and the task run_tests finishes without throwing an exception

Actual behavior:

  • Processing the test results throws an exception

Your CumulusCI and Python versions

$ cci version
CumulusCI version: 3.75.1 (~/.pyenv/versions/3.9.13/bin/cci)
Python version: 3.9.13 (~/.pyenv/versions/3.9.13/bin/python3.9)

Operating System

macOS Ventura 13.2.1

Windows environment

No response

CumulusCI installation method

None

Error Gist

No response

Additional information

No response