Revert system test changes:

* Revert "Shutdown rippled before http server in json rpc test to avoid http server potentially receiving messages due to automatic ledger close interval."
* Revert "Update ripple-lib integration tests"

This reverts commit 83442825e5.
This commit is contained in:
Vinnie Falco
2014-02-04 13:56:37 -08:00
parent 0afbda0351
commit d0970397a6
8 changed files with 639 additions and 1449 deletions

View File

@@ -15,13 +15,13 @@
// Servers are created in tmp/server/$server
//
var child = require('child_process');
var fs = require('fs');
var path = require('path');
var util = require('util');
var child = require("child_process");
var fs = require("fs");
var path = require("path");
var util = require("util");
var assert = require('assert');
var EventEmitter = require('events').EventEmitter;
var nodeutils = require('./nodeutils');
var nodeutils = require("./nodeutils");
// Create a server object
function Server(name, config, verbose) {
@@ -34,7 +34,8 @@ function Server(name, config, verbose) {
var nodejs_version = process.version.match(/^v(\d+)+\.(\d+)\.(\d+)$/).slice(1,4);
var wanted_version = [ 0, 8, 18 ];
while (wanted_version.length && nodejs_version.length && nodejs_version[0] == wanted_version[0]) {
while (wanted_version.length && nodejs_version.length && nodejs_version[0] == wanted_version[0])
{
nodejs_version.shift();
wanted_version.shift();
}
@@ -46,8 +47,8 @@ function Server(name, config, verbose) {
: -1;
if (sgn < 0) {
console.log('\n*** Node.js version is too low.');
throw 'Nodejs version is too low.';
console.log("\n*** Node.js version is too low.");
throw "Nodejs version is too low.";
}
};
@@ -58,24 +59,23 @@ Server.from_config = function (name, config, verbose) {
};
Server.prototype.serverPath = function() {
return path.resolve('tmp/server', this.name);
return path.resolve("tmp/server", this.name);
};
Server.prototype.configPath = function() {
return path.join(this.serverPath(), 'rippled.cfg');
return path.join(this.serverPath(), "rippled.cfg");
};
// Write a server's rippled.cfg.
Server.prototype._writeConfig = function(done) {
var self = this;
function format(o) {
return util.format('[%s]\n%s\n', o, self.config[o]);
};
var config = Object.keys(this.config).map(format).join('');
fs.writeFile(this.configPath(), config, 'utf8', done);
fs.writeFile(
this.configPath(),
Object.keys(this.config).map(function(o) {
return util.format("[%s]\n%s\n", o, self.config[o]);
}).join(""),
'utf8', done);
};
// Spawn the server.
@@ -83,9 +83,9 @@ Server.prototype._serverSpawnSync = function() {
var self = this;
var args = [
'-a',
'-v',
'--conf=rippled.cfg'
"-a",
"-v",
"--conf=rippled.cfg"
];
var options = {
@@ -97,56 +97,42 @@ Server.prototype._serverSpawnSync = function() {
// Spawn in standalone mode for now.
this.child = child.spawn(this.config.rippled_path, args, options);
if (!this.quiet) {
console.log('server: start %s: %s --conf=%s',
if (!this.quiet)
console.log("server: start %s: %s --conf=%s",
this.child.pid,
this.config.rippled_path,
args.join(' '),
args.join(" "),
this.configPath());
}
var stderr = [ ];
var ended = false;
this.child.stderr.on('data', function(data) {
stderr.push(data);
});
this.child.stderr.on('end', function() {
ended = true;
});
var stderr = [];
self.child.stderr.on('data', function(buf) { stderr.push(buf); });
// By default, just log exits.
this.child.on('exit', function onExit(code, signal) {
if (!ended) {
return self.child.stderr.once('end', function() {
onExit(code, signal);
});
}
if (!self.quiet) {
console.log('server: spawn: server exited code=%s: signal=%s', code, signal);
}
this.child.on('exit', function(code, signal) {
if (!self.quiet) console.log("server: spawn: server exited code=%s: signal=%s", code, signal);
self.emit('exited');
// Dump server logs on an abnormal exit
if (self.quiet && !self.stopping) {
process.stdout.write('rippled stderr:\n');
process.stdout.write(stderr.join(''));
if (self.quiet && (!self.stopping)) {
process.stderr.write("rippled stderr:\n");
for (var i = 0; i < stderr.length; i++) {
process.stderr.write(stderr[i]);
};
};
// If could not exec: code=127, signal=null
// If regular exit: code=0, signal=null
// Fail the test if the server has not called 'stop'.
assert(self.stopping, 'Server died with signal ' + signal);
// Fail the test if the server has not called "stop".
assert(self.stopping, 'Server died with signal '+signal);
});
};
// Prepare server's working directory.
Server.prototype._makeBase = function (done) {
var path = this.serverPath();
var self = this;
var path = this.serverPath();
var self = this;
// Reset the server directory, build it if needed.
nodeutils.resetPath(path, '0777', function (e) {
@@ -156,7 +142,7 @@ Server.prototype._makeBase = function (done) {
};
Server.prototype.verbose = function () {
this.quiet = false;
this.quiet = false;
return this;
};
@@ -164,14 +150,9 @@ Server.prototype.verbose = function () {
// Create a standalone server.
// Prepare the working directory and spawn the server.
Server.prototype.start = function () {
var self = this;
var self = this;
if (!this.quiet) {
console.log(
'server: start: %s: %s',
this.name, JSON.stringify(this.config)
);
}
if (!this.quiet) console.log("server: start: %s: %s", this.name, JSON.stringify(this.config));
this._makeBase(function (e) {
if (e) throw e;
@@ -186,25 +167,20 @@ Server.prototype.start = function () {
Server.prototype.stop = function () {
var self = this;
if (!this.child) {
if (!self.quiet) {
console.log('server: stop: can\'t stop');
}
return this;
}
self.stopping = true;
if (!this.child) {
console.log("server: stop: can't stop");
return;
}
// Update the on exit to invoke done.
function childExited(code, signal) {
if (!self.quiet) {
console.log('server: stop: server exited');
}
this.child.on('exit', function (code, signal) {
if (!self.quiet) console.log("server: stop: server exited");
self.emit('stopped');
delete self.child;
};
});
this.child.once('exit', childExited);
this.child.kill();
return this;