From da602eeda06381ffc0735eafe68f83195b7ef4a4 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 14 Apr 2016 17:25:08 +0200 Subject: [PATCH] Use inline execution in camshaft instead of a database service stub --- lib/cartodb/backends/analysis.js | 13 +++++------ test/acceptance/analysis/analysis-layers.js | 2 +- test/support/test-client.js | 24 +-------------------- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/lib/cartodb/backends/analysis.js b/lib/cartodb/backends/analysis.js index 2133e772..dc06a8ac 100644 --- a/lib/cartodb/backends/analysis.js +++ b/lib/cartodb/backends/analysis.js @@ -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); }; diff --git a/test/acceptance/analysis/analysis-layers.js b/test/acceptance/analysis/analysis-layers.js index d56a2aa9..ffcc5fa3 100644 --- a/test/acceptance/analysis/analysis-layers.js +++ b/test/acceptance/analysis/analysis-layers.js @@ -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 diff --git a/test/support/test-client.js b/test/support/test-client.js index 7372ac82..1da653a7 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -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) {