feat(taskscheduler): allow to use custom scheduler for shards#4836
feat(taskscheduler): allow to use custom scheduler for shards#4836ReactiveThings wants to merge 2 commits intoangular:masterfrom
Conversation
|
@ReactiveThings could you give me a little bit on how to fix this? I've waiting for this for months so Im going to try to fix it to pass the tests 🙂 |
|
@psypersky I have fixed tslint issue but it looks like it is not enough. Test "slow asynchronous events waits for http calls" fails for every new pull request. We need to wait until somebody will fix it. |
|
@ReactiveThings Any idea when this feature will be merged? I badly need this feature in my project to speed up the protractor test cases. The performance overhead of starting a new instance of the browser for each spec file offsets the time benefit provided by concurrent execution. |
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
2251389 to
8b93568
Compare
|
CLAs look good, thanks! |
1 similar comment
|
CLAs look good, thanks! |
|
@ReactiveThings @psypersky - Any movement on this? I am badly waiting for this . |
|
Any idea when this feature will be merged? |
|
When will this be merged? Waiting on this for long. |
|
Would love to get this feature in, any headway on it? I reviewed the code and it looks good. |
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
1 similar comment
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
When shardTestFiles is true, specs will be sharded by file. (i.e. every test file is executed in separated browser instance). This behavior can now be customized by providing custom shard scheduler function which allows to run multiple specs in one browser instance. For example we can run same amount of specs in each browser instance.
5c530fa to
ef8b815
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
1 similar comment
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
When will this be merged? |
|
Where are we with this PR? |
|
Why can't feature merge? |
|
I couldn't wait for this PR to be merged. So, based on elements provided by @ReactiveThings I created a patch in my project (start from the code of the
const configParser = require('protractor/built/configParser');
const TaskSchedulerModule = require('protractor/built/taskScheduler');
class CustomTaskScheduler extends TaskSchedulerModule.TaskScheduler {
constructor(config) {
// PATCH : prevents multiCapabilities to be handle twice
super({ ...config, multiCapabilities: [] });
let excludes = configParser.ConfigParser.resolveFilePatterns(config.exclude, true, config.configDir);
let allSpecs = configParser.ConfigParser.resolveFilePatterns(
configParser.ConfigParser.getSpecs(config),
false,
config.configDir
).filter(path => {
return excludes.indexOf(path) < 0;
});
let taskQueues = [];
config.multiCapabilities.forEach(capabilities => {
let capabilitiesSpecs = allSpecs;
if (capabilities.specs) {
let capabilitiesSpecificSpecs = configParser.ConfigParser.resolveFilePatterns(
capabilities.specs,
false,
config.configDir
);
capabilitiesSpecs = capabilitiesSpecs.concat(capabilitiesSpecificSpecs);
}
if (capabilities.exclude) {
let capabilitiesSpecExcludes = configParser.ConfigParser.resolveFilePatterns(
capabilities.exclude,
true,
config.configDir
);
capabilitiesSpecs = capabilitiesSpecs.filter(path => {
return capabilitiesSpecExcludes.indexOf(path) < 0;
});
}
//
// PATCH ----------------------------------------------------------------
//
// let specLists = [];
// If we shard, we return an array of one element arrays, each containing
// the spec file. If we don't shard, we return an one element array
// containing an array of all the spec files
// if (capabilities.shardTestFiles) {
// capabilitiesSpecs.forEach(spec => {
// specLists.push([spec]);
// });
// } else {
// specLists.push(capabilitiesSpecs);
// }
let shardScheduler = capabilities.shardTestFiles;
if (typeof shardScheduler !== 'function') {
// If we shard, we return an array of one element arrays, each containing
// the spec file. If we don't shard, we return an one element array
// containing an array of all the spec files
shardScheduler = function(specs, capabilities) {
if (capabilities.shardTestFiles) {
return specs.map(spec => [spec]);
}
return [specs];
};
}
const specLists = shardScheduler(capabilitiesSpecs, capabilities);
// End PATCH ------------------------------------------------------------
capabilities.count = capabilities.count || 1;
for (let i = 0; i < capabilities.count; ++i) {
taskQueues.push(new TaskSchedulerModule.TaskQueue(capabilities, specLists));
}
});
super.taskQueues = taskQueues;
super.rotationIndex = 0; // Helps suggestions to rotate amongst capabilities
}
}
// Replace TaskScheduler class in protractor module
TaskSchedulerModule.TaskScheduler = CustomTaskScheduler;
exports.shardScheduler = function shardScheduler(specs, capabilities) {
const numberOfShards = capabilities.maxInstances;
if (numberOfShards > 1) {
const bucketSize = Math.ceil(specs.length / numberOfShards);
const shards = [];
let start = 0;
while (start < specs.length) {
let end = start + bucketSize;
if (end > specs.length) {
end = specs.length;
}
shards.push(specs.slice(start, end));
start = end;
}
return shards;
}
return [specs];
};Then const { shardScheduler } = require('<your path to patch>/custom-task-scheduler');And set |
When shardTestFiles is true, specs will be sharded by file. (i.e. every test file is executed in separated browser instance).
This behavior can now be customized by providing custom shard scheduler function which allows to run multiple specs in one browser instance. For example we can run same amount of specs in each browser instance.