This repository has been archived by the owner on Jan 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Gruntfile.js
127 lines (104 loc) · 3.41 KB
/
Gruntfile.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
'use strict';
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.initConfig({
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'*.js',
'.eastrc',
'lib/**/*.js',
'migrations/**/*.js',
'bin/*',
'test/**/*.js',
],
},
mochaTest: {
test: {
options: {
reporter: 'spec',
// Force colors for the output of mutliTest
colors: true,
// Increase the default timeout from 2 seconds to 4 seconds. We'll
// see if this helps with sporadic issues in the CI environment.
timeout: 4000,
},
src: ['test/**/*.js']
},
},
});
grunt.registerTask('default', [
'test',
]);
grunt.registerTask('test', [
'jshint',
'mochaTest',
]);
// Run the full test suite 20 times. Only print the output when errors are
// encountered. This is to try to make it easier to track down sporadic test
// issues that only happen occasionally.
grunt.registerTask('multiTest', 'Run all the tests multiple times', function() {
var done = this.async();
var async = require('async'),
exec = require('child_process').exec,
fs = require('fs');
async.timesSeries(20, function(index, next) {
var runNum = index + 1;
process.stdout.write('Run ' + runNum + ' ');
var progress = setInterval(function() {
process.stdout.write('.');
}, 5000);
var startTime = process.hrtime();
var logPath = '/tmp/api-umbrella-multi-test.log';
exec('./node_modules/.bin/grunt > ' + logPath + ' 2>&1', function(error) {
clearInterval(progress);
var duration = process.hrtime(startTime);
console.info(' ' + duration[0] + 's');
if(error) {
console.info('Run ' + runNum + ' encountered an error: ', error);
console.info(fs.readFileSync(logPath).toString());
}
next(error);
});
}, function(error) {
if(error) {
console.info('Error during multiple runs: ', error);
}
done(error);
});
});
grunt.registerTask('multiLongConnectionDrops', 'Run all the tests multiple times', function() {
var done = this.async();
var async = require('async'),
exec = require('child_process').exec,
fs = require('fs');
async.timesSeries(20, function(index, next) {
var runNum = index + 1;
process.stdout.write('Run ' + runNum + ' ');
var progress = setInterval(function() {
process.stdout.write('.');
}, 5000);
var startTime = process.hrtime();
process.env.CONNECTION_DROPS_DURATION = 10 * 60;
var logPath = '/tmp/api-umbrella-multi-long-connection-drops.log';
exec('./node_modules/.bin/mocha test/integration/dns.js -g "handles ip changes without dropping any connections" > ' + logPath + ' 2>&1', function(error) {
clearInterval(progress);
var duration = process.hrtime(startTime);
console.info(' ' + duration[0] + 's');
if(error) {
console.info('Run ' + runNum + ' encountered an error: ', error);
console.info(fs.readFileSync(logPath).toString());
}
next(error);
});
}, function(error) {
if(error) {
console.info('Error during multiple runs: ', error);
}
done(error);
});
});
};