parallel circle ci testing of clientTest.js (#373) (#449)

parallel testing with circle ci, solve #373
This commit is contained in:
Romain Beaumont 2017-05-10 02:49:13 +02:00 committed by GitHub
parent b4c80d325e
commit 20dd0710f2
6 changed files with 50 additions and 4 deletions

View File

@ -8,3 +8,7 @@ machine:
dependencies:
pre:
- mkdir minecraft-server
test:
override:
- npm test:
parallel: true

View File

@ -11,7 +11,14 @@ var testDataWrite = [
// TODO: add more packets for better quality data
];
mc.supportedVersions.forEach(function(supportedVersion){
const {firstVersion,lastVersion}=require("./common/parallel");
console.log({firstVersion,lastVersion});
mc.supportedVersions.forEach(function(supportedVersion,i){
if(!(i>=firstVersion && i<=lastVersion))
return;
var mcData=require("minecraft-data")(supportedVersion);
var version=mcData.version;
describe("benchmark "+version.minecraftVersion,function(){

View File

@ -7,11 +7,15 @@ var MC_SERVER_PATH = path.join(__dirname, 'server');
var Wrap = require('minecraft-wrap').Wrap;
const {firstVersion,lastVersion}=require("./common/parallel");
var download = require('minecraft-wrap').download;
mc.supportedVersions.forEach(function(supportedVersion,i) {
if(!(i>=firstVersion && i<=lastVersion))
return;
mc.supportedVersions.forEach(function(supportedVersion) {
var PORT=Math.round(30000+Math.random()*20000);
var mcData = require("minecraft-data")(supportedVersion);
var version = mcData.version;

22
test/common/parallel.js Normal file
View File

@ -0,0 +1,22 @@
const nodeIndex=parseInt(process.env.CIRCLE_NODE_INDEX);
const nodeTotal=parseInt(process.env.CIRCLE_NODE_TOTAL);
const parallel=process.env.CIRCLE_NODE_INDEX!==undefined && process.env.CIRCLE_NODE_TOTAL!==undefined;
const mc = require("../../");
// expected values :
// (0,4,10) -> (0,2)
// (1,4,10) -> (3,5)
// (2,4,10) -> (6,8)
// (3,4,10) -> (9,9)
function testedRange(nodeIndex,nodeTotal,numberOfVersions) {
const nbFirsts=Math.ceil(numberOfVersions/nodeTotal);
if(nodeIndex==(nodeTotal-1))
return {firstVersion:nbFirsts*nodeIndex,lastVersion:numberOfVersions-1};
return {firstVersion:nodeIndex*nbFirsts,lastVersion:(nodeIndex+1)*nbFirsts-1};
}
console.log({nodeIndex,nodeTotal,versions:mc.supportedVersions.length});
const {firstVersion,lastVersion}=parallel ? testedRange(nodeIndex,nodeTotal,mc.supportedVersions.length) : {firstVersion:0,lastVersion:mc.supportedVersions.length-1};
module.exports={firstVersion,lastVersion};

View File

@ -142,8 +142,12 @@ function getValue(_type, packet) {
throw new Error("No value for type " + fieldInfo.type);
}
const {firstVersion,lastVersion}=require("./common/parallel");
mc.supportedVersions.forEach(function(supportedVersion,i){
if(!(i>=firstVersion && i<=lastVersion))
return;
mc.supportedVersions.forEach(function(supportedVersion){
var PORT=Math.round(30000+Math.random()*20000);
var mcData=require("minecraft-data")(supportedVersion);
var version=mcData.version;

View File

@ -1,7 +1,12 @@
var mc = require('../');
var assert = require('power-assert');
mc.supportedVersions.forEach(function(supportedVersion){
const {firstVersion,lastVersion}=require("./common/parallel");
mc.supportedVersions.forEach(function(supportedVersion,i){
if(!(i>=firstVersion && i<=lastVersion))
return;
var PORT=Math.round(30000+Math.random()*20000);
var mcData=require("minecraft-data")(supportedVersion);
var version=mcData.version;