Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #716 from drewfish/perf-func
Browse files Browse the repository at this point in the history
fixed a couple of functional tests
  • Loading branch information
drewfish committed Nov 7, 2012
2 parents 397ff48 + a17ff08 commit 3f7a108
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
21 changes: 18 additions & 3 deletions tests/func/common/testconfiginappfilecompserver.js
Expand Up @@ -12,10 +12,25 @@ YUI({
suite.add(new Y.Test.Case({

"test configinappfilecompserver": function() {
Y.Assert.areEqual('ac.config.get\(\) -', Y.one('#completeConfig').get('innerHTML').match(/ac.config.get\(\) -/gi));
Y.Assert.areEqual('\{\"key1\":\"This is the value from the default.yaml for key1\",\"key2\":\"This is the value from the default.yaml for key2\",\"commonKey1\":\"Value of commonKey1 in application.yaml\",\"defaultArray\":\[\"defaultArrayValue1\",\"defaultArrayValue2\"\],\"nestedConfig\":\{\"subConfig1\":\"SubConfig from defaults.yaml\",\"subConfig2\":\{\"subsubConfig1\":\"SubSubConfig1 from defaults.yaml\",\"subsubConfig2\":\"SubSubConfig2 from defaults.yaml\"\}\},\"config1\":\"This is the config for config1 in application.yaml\",\"configArray1\":\[\"configArray1Value1\",\"configArray1Value2\",\"configArray1Value3\"\],\"config2\":\{\"config2Key1\":\"config2Key1 value from application.yaml\",\"config2Key2\":\{\"config2Key2Key1\":\"It gets complicated here- config2Key2Key1 value in application.yaml\",\"config2Key2Key2\":\"config2Key2Key2 value in application.yaml\"\},\"config2Key3Array1\":\[\"config2Key3Array1Value1\",\"config2Key3Array1Value2\",\"config2Key3Array1Value3\"\]\}', Y.one('#completeConfig').get('innerHTML').match(/\{\"key1\":\"This is the value from the default.yaml for key1\",\"key2\":\"This is the value from the default.yaml for key2\",\"commonKey1\":\"Value of commonKey1 in application.yaml\",\"defaultArray\":\[\"defaultArrayValue1\",\"defaultArrayValue2\"\],\"nestedConfig\":\{\"subConfig1\":\"SubConfig from defaults.yaml\",\"subConfig2\":\{\"subsubConfig1\":\"SubSubConfig1 from defaults.yaml\",\"subsubConfig2\":\"SubSubConfig2 from defaults.yaml\"\}\},\"config1\":\"This is the config for config1 in application.yaml\",\"configArray1\":\[\"configArray1Value1\",\"configArray1Value2\",\"configArray1Value3\"\],\"config2\":\{\"config2Key1\":\"config2Key1 value from application.yaml\",\"config2Key2\":\{\"config2Key2Key1\":\"It gets complicated here- config2Key2Key1 value in application.yaml\",\"config2Key2Key2\":\"config2Key2Key2 value in application.yaml\"\},\"config2Key3Array1\":\[\"config2Key3Array1Value1\",\"config2Key3Array1Value2\",\"config2Key3Array1Value3\"\]\}/gi));
Y.Assert.areEqual('ac.config.get\(\) -', Y.one('#completeConfig').get('innerHTML').match(/ac.config.get\(\) -/gi));
var matches = Y.one('#completeConfig').get('innerHTML').match(/({.+})/);
var json;
try {
json = JSON.parse(matches[1]);
} catch(e) {
}
Y.Assert.isObject(json);
Y.Assert.areEqual(8, Object.keys(json).length);
Y.Assert.areSame('Value of commonKey1 in application.yaml', json.commonKey1);
Y.Assert.areSame('This is the config for config1 in application.yaml', json.config1);
Y.Assert.areSame('This is the value from the default.yaml for key1', json.key1);
Y.Assert.areSame('This is the value from the default.yaml for key2', json.key2);
Y.Assert.areSame('["configArray1Value1","configArray1Value2","configArray1Value3"]', JSON.stringify(json.configArray1))
Y.Assert.areSame('["defaultArrayValue1","defaultArrayValue2"]', JSON.stringify(json.defaultArray));
Y.Assert.areSame('{"config2Key1":"config2Key1 value from application.yaml","config2Key2":{"config2Key2Key1":"It gets complicated here- config2Key2Key1 value in application.yaml","config2Key2Key2":"config2Key2Key2 value in application.yaml"},"config2Key3Array1":["config2Key3Array1Value1","config2Key3Array1Value2","config2Key3Array1Value3"]}', JSON.stringify(json.config2));
Y.Assert.areSame('{"subConfig1":"SubConfig from defaults.yaml","subConfig2":{"subsubConfig1":"SubSubConfig1 from defaults.yaml","subsubConfig2":"SubSubConfig2 from defaults.yaml"}}', JSON.stringify(json.nestedConfig));
}

}));
Y.Test.Runner.add(suite);
});
});
4 changes: 1 addition & 3 deletions tests/func/common/testmojitproxybroadcaststaticlisten2.js
Expand Up @@ -40,6 +40,4 @@ YUI({
}));

Y.Test.Runner.add(suite);
}

});
});
40 changes: 31 additions & 9 deletions tests/run.js
Expand Up @@ -20,12 +20,14 @@ program.command('test')
.option('-d, --no-deploy', 'Don\'t deploy the apps')
.option('-s, --no-selenium', 'Don\'t run arrow_selenium')
.option('-a, --no-arrow', 'Don\'t run arrow_server')
.option('--debugApps', 'show STDOUT and STDERR from apps')
.option('--logLevel <value>', 'Arrow logLevel')
.option('--testName <value>', 'Arrow testName')
.option('--descriptor <value>', 'which descriptor to run. filename (or glob) relative to --path')
.option('--group <value>', 'Arrow group')
.option('--driver <value>', 'Arrow driver')
.option('--browser <value>', 'Arrow browser')
.option('--path <value>', 'Path to find the tests')
.option('--path <value>', 'Path to find the tests. defaults to ./func or ./unit')
.action(test);

program.command('build')
Expand Down Expand Up @@ -173,9 +175,8 @@ function deploy (cmd, callback) {
apps = appsConfig.applications;

for (var i=0; i<apps.length; i++) {
(function () {
var app = apps[i],
port = app.port ? parseInt(app.port) : null,
(function (app) {
var port = app.port ? parseInt(app.port, 10) : null,
type = app.type || 'mojito';

if ('mojito' === type) {
Expand All @@ -186,21 +187,21 @@ function deploy (cmd, callback) {
var test = mytests[j],
port = test.port ? parseInt(test.port) : null;
appSeries.push(function (callback) {
runMojitoApp(cmd.funcPath + '/applications', app.path, port, test.param, callback);
runMojitoApp(cmd, cmd.funcPath + '/applications', app.path, port, test.param, callback);
});
})();
}
} else if (app.enabled === "true" && app.path && port) {
appSeries.push(function (callback) {
runMojitoApp(cmd.funcPath + '/applications', app.path, port, app.param, callback);
runMojitoApp(cmd, cmd.funcPath + '/applications', app.path, port, app.param, callback);
});
}
} else if ('static' === type) {
appSeries.push(function (callback) {
runStaticApp(cmd.funcPath + '/applications', app.path, port, app.param, callback);
});
}
})();
})(apps[i]);
}
async.series(appSeries, callback);
}
Expand All @@ -222,9 +223,10 @@ function runFuncTests (cmd, callback) {
} catch (e) {}
wrench.mkdirSyncRecursive(arrowReportDir);

var descriptor = cmd.descriptor || '**/*_descriptor.json';
var commandArgs = [
cwd + "/../node_modules/yahoo-arrow/index.js",
cmd.funcPath + "/**/*_descriptor.json",
cmd.funcPath + '/' + descriptor,
"--report=true",
"--reportFolder=" + arrowReportDir
];
Expand Down Expand Up @@ -305,14 +307,34 @@ function runCommand (path, command, argv, callback) {
return cmd;
}

function runMojitoApp (basePath, path, port, params, callback) {
function runMojitoApp (cliOptions, basePath, path, port, params, callback) {
/* useful when debugging
var OK = {
4081: true,
};
if (! OK[port]) {
console.error('------------------------------- SKIPPING APP ON PORT ' + port);
callback();
return;
}
*/

params = params || '';
console.log('Starting ' + path + ' at port ' + port + ' with params ' + (params || 'empty'));
var p = runCommand(basePath + '/' + path, cwd + "/../bin/mojito", ["start", port, "--context", params], function () {});
pids.push(p.pid);
pidNames[p.pid] = libpath.basename(path) + ':' + port + (params ? '?' + params : '');
// Give each app a second to start
setTimeout(function () { callback(null) }, 1000);

if (cliOptions.debugApps) {
p.stdout.on('data', function(data) {
console.error('---DEBUG ' + port + ' STDOUT--- ' + data.toString());
});
p.stderr.on('data', function(data) {
console.error('---DEBUG ' + port + ' STDERR--- ' + data.toString());
});
}
}

function runStaticApp (basePath, path, port, params, callback) {
Expand Down

0 comments on commit 3f7a108

Please sign in to comment.