Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support automatic splitting tests across nodes #351

Open
JanTvrdik opened this issue Feb 9, 2017 · 1 comment
Open

Support automatic splitting tests across nodes #351

JanTvrdik opened this issue Feb 9, 2017 · 1 comment

Comments

@JanTvrdik
Copy link
Contributor

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.

@JanTvrdik
Copy link
Contributor Author

Alternative (and quite possibly better approach) is to add new CLI option to print tests names to stdout and let them be processed by another tool.

For example Circle CI does provide picard tool to split the tests. So the final command would look sth like

tester --find-tests ./tests | picard | xargs tester -c ./tests/php.ini

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

No branches or pull requests

1 participant