forked from gwicke/testreduce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CassandraBackend.js
77 lines (66 loc) · 2.14 KB
/
CassandraBackend.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var util = require('util'),
events = require('events'),
cass = require('node-cassandra-cql'),
consistencies = cass.types.consistencies,
uuid = require('node-uuid'),
async = require('async');
// Constructor
function CassandraBackend(name, config, callback) {
var self = this;
this.name = name;
this.config = config;
// convert consistencies from string to the numeric constants
var confConsistencies = config.backend.options.consistencies;
this.consistencies = {
read: consistencies[confConsistencies.read],
write: consistencies[confConsistencies.write]
};
self.client = new cass.Client(config.backend.options);
var reconnectCB = function(err) {
if (err) {
// keep trying each 500ms
console.error('pool connection error, scheduling retry!');
setTimeout(self.client.connect.bind(self.client, reconnectCB), 500);
}
};
this.client.on('connection', reconnectCB);
this.client.connect();
var numFailures = config.numFailures;
// Queues that we use for
self.runningQueue = new Array();
self.testQueue = new Array();
// Load all the tests from Cassandra - do this when we see a new commit hash
//this.client.on('log', function(level, message) {
// console.log('log event: %s -- %j', level, message);
//});
callback();
}
/**
* Get the next title to test
*
* @param commit object {
* hash: <git hash string>
* timestamp: <git commit timestamp date object>
* }
* @param cb function (err, test) with test being an object that serializes to
* JSON, for example [ 'enwiki', 'some title', 12345 ]
*/
CassandraBackend.prototype.getTest = function (commit, cb) {
cb([ 'enwiki', 'some title', 12345 ]);
};
/**
* Add a result to storage
*
* @param test string representing what test we're running
* @param commit object {
* hash: <git hash string>
* timestamp: <git commit timestamp date object>
* }
* @param result string (JUnit XML typically)
* @param cb callback (err) err or null
*/
CassandraBackend.prototype.addResult = function(test, commit, result, cb) {
}
// Node.js module exports. This defines what
// require('./CassandraBackend.js'); evaluates to.
module.exports = CassandraBackend;