Use inline execution in camshaft instead of a database service stub

This commit is contained in:
Raul Ochoa 2016-04-14 17:25:08 +02:00
parent a26025b259
commit da602eeda0
3 changed files with 9 additions and 30 deletions

View File

@ -2,15 +2,16 @@ var camshaft = require('camshaft');
function AnalysisBackend(options) {
var batchConfig = options.batch || {};
this.batchEndpoint = batchConfig.endpoint || 'http://127.0.0.1:8080/api/v1/sql/job';
var databaseService = batchConfig.databaseService || null;
this.analysisFactory = (databaseService === null) ? camshaft : new camshaft(databaseService);
batchConfig.endpoint = batchConfig.endpoint || 'http://127.0.0.1:8080/api/v1/sql/job';
batchConfig.inlineExecution = batchConfig.inlineExecution || false;
this.batchConfig = batchConfig;
}
module.exports = AnalysisBackend;
AnalysisBackend.prototype.create = function(analysisConfiguration, analysisDefinition, callback) {
analysisConfiguration.batch.endpoint = this.batchEndpoint;
this.analysisFactory.create(analysisConfiguration, analysisDefinition, callback);
analysisConfiguration.batch.endpoint = this.batchConfig.endpoint;
analysisConfiguration.batch.inlineExecution = this.batchConfig.inlineExecution;
camshaft.create(analysisConfiguration, analysisDefinition, callback);
};

View File

@ -161,7 +161,7 @@ describe('analysis-layers', function() {
});
});
it.skip('should fail for non-authenticated requests that has a node other than "source"', function(done) {
it('should fail for non-authenticated requests that has a node other than "source"', function(done) {
var useCase = useCases[1];
// No API key here

View File

@ -12,29 +12,7 @@ var helper = require('./test_helper');
var CartodbWindshaft = require('../../lib/cartodb/server');
var serverOptions = require('../../lib/cartodb/server_options');
function createServiceStub(result) {
return function(__, callback) {
return callback(null, result);
};
}
function AnalysisDatabaseServiceStub(/*dbParams, batchParams*/) {
// this.dbParams = dbParams;
// this.batchParams = batchParams;
}
AnalysisDatabaseServiceStub.prototype = {
run: createServiceStub({}),
getSchema: createServiceStub([]),
getColumnNames: createServiceStub([]),
getLastUpdatedTimeFromAffectedTables: createServiceStub([]),
setUpdatedAtForSources: createServiceStub([]),
registerAnalysisInCatalog: createServiceStub([]),
queueAnalysisOperations: createServiceStub([]),
trackAnalysis: createServiceStub([]),
enqueue: createServiceStub({})
};
serverOptions.analysis.batch.databaseService = AnalysisDatabaseServiceStub;
serverOptions.analysis.batch.inlineExecution = true;
var server = new CartodbWindshaft(serverOptions);
function TestClient(mapConfig, apiKey) {