CartoDB-SQL-API/test/acceptance/batch/job-timing-test.js

115 lines
3.8 KiB
JavaScript
Raw Normal View History

2018-10-24 21:42:33 +08:00
'use strict';
require('../../helper');
var BatchTestClient = require('../../support/batch-test-client');
var JobStatus = require('../../../lib/batch/job-status');
describe('Batch API query timing', function () {
2019-12-24 01:19:08 +08:00
before(function () {
this.batchTestClient = new BatchTestClient();
});
2019-12-24 01:19:08 +08:00
after(function (done) {
this.batchTestClient.drain(done);
});
it('should report start and end time for each query with fallback queries' +
'and expose started_at and ended_at for all queries with fallback mechanism', function (done) {
var expectedQuery = {
query: [{
query: 'SELECT * FROM untitle_table_4 limit 1',
onerror: 'SELECT * FROM untitle_table_4 limit 2',
status: 'done',
fallback_status: 'skipped'
}, {
query: 'SELECT * FROM untitle_table_4 limit 3',
onerror: 'SELECT * FROM untitle_table_4 limit 4',
status: 'done',
fallback_status: 'skipped'
}],
onerror: 'SELECT * FROM untitle_table_4 limit 5'
};
var payload = {
2019-12-24 01:19:08 +08:00
query: {
query: [
{
2019-12-24 01:19:08 +08:00
query: 'SELECT * FROM untitle_table_4 limit 1',
onerror: 'SELECT * FROM untitle_table_4 limit 2'
},
{
2019-12-24 01:19:08 +08:00
query: 'SELECT * FROM untitle_table_4 limit 3',
onerror: 'SELECT * FROM untitle_table_4 limit 4'
}
],
2019-12-24 01:19:08 +08:00
onerror: 'SELECT * FROM untitle_table_4 limit 5'
}
};
2019-12-24 01:19:08 +08:00
this.batchTestClient.createJob(payload, function (err, jobResult) {
if (err) {
return done(err);
}
jobResult.getStatus(function (err) {
if (err) {
return done(err);
}
jobResult.validateExpectedResponse(expectedQuery);
done();
});
});
});
it('should report start and end time for each query also for failing queries' +
'and expose started_at and ended_at for all queries with fallback mechanism (failed)', function (done) {
var expectedQuery = {
query: [{
query: 'SELECT * FROM untitle_table_4 limit 1',
onerror: 'SELECT * FROM untitle_table_4 limit 2',
status: 'done',
fallback_status: 'skipped'
}, {
query: 'SELECT * FROM untitle_table_4 limit 3 failed',
onerror: 'SELECT * FROM untitle_table_4 limit 4',
status: 'failed',
fallback_status: 'done'
}],
onerror: 'SELECT * FROM untitle_table_4 limit 5'
};
var payload = {
2019-12-24 01:19:08 +08:00
query: {
query: [
{
2019-12-24 01:19:08 +08:00
query: 'SELECT * FROM untitle_table_4 limit 1',
onerror: 'SELECT * FROM untitle_table_4 limit 2'
},
{
2019-12-24 01:19:08 +08:00
query: 'SELECT * FROM untitle_table_4 limit 3 failed',
onerror: 'SELECT * FROM untitle_table_4 limit 4'
}
],
2019-12-24 01:19:08 +08:00
onerror: 'SELECT * FROM untitle_table_4 limit 5'
}
};
2019-12-24 01:19:08 +08:00
this.batchTestClient.createJob(payload, function (err, jobResult) {
if (err) {
return done(err);
}
jobResult.getStatus(JobStatus.FAILED, function (err) {
if (err) {
return done(err);
}
jobResult.validateExpectedResponse(expectedQuery);
done();
});
});
});
});