Skip to content

Support automatic splitting tests across nodes #351

@JanTvrdik

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.

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