Skip to content

Support automatic splitting tests across nodes #351

Description

@JanTvrdik

For example Circle CI can provide CIRCLE_NODE_INDEX and CIRCLE_NODE_TOTAL env. variables. Naive implementation of splitting can look like this.

class Runner
{
	...
	public function run()
	{
		...
		$nodeIndex = (int) getenv('CIRCLE_NODE_INDEX');
		$nodeTotal = (int) getenv('CIRCLE_NODE_TOTAL');
		if ($nodeTotal) {
			$this->jobs = array_values(array_filter(
				$this->jobs,
				function (int $jobIndex) use ($nodeIndex, $nodeTotal) {
					return ($jobIndex % $nodeTotal) === $nodeIndex;
				},
				ARRAY_FILTER_USE_KEY
			));
		}

Better implementation should automatically balance the tests based on the time it took to execute them in previous run.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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