Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
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

Description

@ben-yocum

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.

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