Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Unable to run in parallel with Protractor 6 and shardTestFiles: true #5232

Closed
ben-yocum opened this issue May 7, 2019 · 5 comments
Closed

Comments

@ben-yocum
Copy link

Bug report

  • Node Version: 10.15.3
  • Protractor Version: 6.0.0
  • Angular Version: 6.1.8
  • Browser(s): Chrome 74
  • Operating System and Version Windows 10

Configuration file:

const path = process.cwd();
module.exports = {
	seleniumAddress: 'http://localhost:4444/wd/hub',
	framework: 'custom',
	frameworkPath: require.resolve('protractor-cucumber-framework'),

	specs: [ `${path}/features/**/*.feature` ],

	capabilities: {
		browserName: 'chrome',
		'chromeOptions': {
			'args': ['--headless', '--disable-gpu', '--disable-extensions', '--no-sandbox']
		},
		shardTestFiles: true,
		maxInstances: 2
	},
};

This configuration will fail to execute two tests in parallel. I have tracked down the bug in the Protractor source code.

The problem is in launcher.ts.

protractor/lib/launcher.ts

Lines 247 to 251 in 4f74a4e

const maxConcurrentTasks = scheduler.maxConcurrentTasks();
for (let i = 0; i < maxConcurrentTasks; ++i) {
await createNextTaskRunner();
}
logger.info('Running ' + scheduler.countActiveTasks() + ' instances of WebDriver');

The await causes the library to wait for each task to complete before spinning up a new one. This prevents more than a single test from being executed in parallel. I found that this fixed the issue:

  const maxConcurrentTasks = scheduler.maxConcurrentTasks();
  const taskArray = [];
  for (let i = 0; i < maxConcurrentTasks; ++i) {
    taskArray.push(createNextTaskRunner());
  }
  await Promise.all(taskArray);
  logger.info('Running ' + scheduler.countActiveTasks() + ' instances of WebDriver');

I do not believe this is an acceptable production solution, but I am not certain how to properly fix the bug. Let me know if you need more information or a more-complete minimal test case.

@vsravuri
Copy link

vsravuri commented May 7, 2019

Could be similar to #5145

@vsravuri
Copy link

vsravuri commented May 7, 2019

Both multiCapabilities & shardTestFiles doesn't work in Protractor 6.0.0

@ben-yocum
Copy link
Author

Yep, looks like the same problem. Do you think I should close this issue as a duplicate?

@vsravuri
Copy link

vsravuri commented May 7, 2019

I added follow up note on #5145

@cnishina
Copy link
Contributor

cnishina commented May 7, 2019

Duplicate #5145

Closing issue.

@cnishina cnishina closed this as completed May 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants