Merge remote-tracking branch 'origin/master' into newclient-dockerlike-deploy

Conflicts:
	scripts/makestatic.sh
This commit is contained in:
Tim Robinson 2015-04-16 14:51:40 +00:00
parent 4be5e490f9
commit 8a0d2cfc16
10 changed files with 145 additions and 91 deletions

3
.gitignore vendored
View File

@ -13,6 +13,7 @@ plugins/c9.ide.language.javascript.tern/util/sigs_ts
plugins/c9.account.billing/node_modules/
plugins/c9.account/node_modules/
plugins/c9.api.project/coverage/
plugins/c9.proxy.apps/coverage/
plugins/c9.db.redis/coverage/
scripts/build
build/output
@ -67,6 +68,8 @@ plugins/c9.proxy/proxy.cfg
plugins/c9.proxy/haproxy
plugins/c9.proxy/haproxy-*
**/.module-cache/
plugins/c9.account.billing/node_modules/
plugins/c9.account/node_modules/
.c9revisions
.settings

View File

@ -173,6 +173,7 @@ module.exports = function(config, optimist) {
"./c9.vfs.server/download",
"./c9.vfs.server/filelist",
"./c9.vfs.server/statics",
"./c9.metrics/mock_metrics",
{
packagePath: "./c9.vfs.server/vfs.connect.standalone",
workspaceDir: baseProc,

View File

@ -2,6 +2,9 @@
"use server";
require("amd-loader");
var assert = require("assert");
var sinon = require("sinon");
@ -284,14 +287,18 @@ module.exports = {
root.handle({
method: "PUT",
url: "/post/fab?age=34"
}, this.res, assert.fail);
sinon.assert.calledWith(this.res.writeHead, 422);
var errors = JSON.parse(this.res.end.args[0][0]).errors;
assert.equal(errors.length, 1);
assert.equal(errors[0].resource, "root");
assert.equal(errors[0].field, "name");
assert.equal(errors[0].code, "missing_field");
}, this.res, function(err){
assert.ok( err );
var errors = err.errors;
assert.equal(errors.length, 1);
assert.equal(errors[0].resource, "root");
assert.equal(errors[0].field, "name");
assert.equal(errors[0].code, "missing_field");
});
this.res.writeHead.reset();
this.res.end.reset();
@ -299,14 +306,19 @@ module.exports = {
method: "PUT",
url: "/post/fab?age=juhu",
body: { name: "Fabian"}
}, this.res, assert.fail);
sinon.assert.calledWith(this.res.writeHead, 422);
var errors = JSON.parse(this.res.end.args[0][0]).errors;
assert.equal(errors.length, 1);
assert.equal(errors[0].resource, "root");
assert.equal(errors[0].field, "age");
assert.equal(errors[0].type_expected, "int");
assert.equal(errors[0].code, "invalid");
}, this.res, function(err){
assert.ok( err );
var errors = err.errors;
assert.equal(errors.length, 1);
assert.equal(errors[0].resource, "root");
assert.equal(errors[0].field, "age");
assert.equal(errors[0].type_expected, "int");
assert.equal(errors[0].code, "invalid");
});
},
"test custom type with register": function() {

View File

@ -2,6 +2,8 @@
"use server";
require("amd-loader");
var assert = require("assert");
var sinon = require("sinon");

View File

@ -2,6 +2,8 @@
"use server";
require("amd-loader");
var assert = require("assert");
var types = require("./types");

View File

@ -2,6 +2,7 @@
"use strict";
"use server";
"use mocha";
"use blacklist";
require("c9/inline-mocha")(module);

View File

@ -0,0 +1,19 @@
/**
* Dummy implementation of metrics.
*/
"use strict";
plugin.consumes = [];
plugin.provides = ["metrics"];
module.exports = plugin;
function plugin(options, imports, register) {
register(null, {
"metrics": {
log: function() {},
increment: function() {}
}
});
}

View File

@ -5,7 +5,8 @@ define(function(require, exports, module) {
"connect.render",
"connect.render.ejs",
"connect.redirect",
"connect.static"
"connect.static",
"metrics"
];
main.provides = ["preview.handler"];
return main;
@ -15,6 +16,7 @@ define(function(require, exports, module) {
var https = require("https");
var http = require("http");
var mime = require("mime");
var metrics = imports.metrics;
var parseUrl = require("url").parse;
var debug = require("debug")("preview");
@ -167,6 +169,7 @@ define(function(require, exports, module) {
else
serveFile(request);
}).on("error", function(err) {
metrics.increment("preview.failed.error");
next(err);
});

View File

@ -97,7 +97,9 @@ define(function(require, exports, module) {
function getVfsEndpoint(version, callback) {
getServers(function(err, _servers) {
if (err) {
errorHandler.reportError(err);
if (err.code !== "EDISCONNECT")
errorHandler.reportError(new Error("Could not get list of VFS servers"), { cause: err });
metrics.increment("vfs.failed.connect_getservers", 1, true);
initDefaultServers();
_servers = servers;
}

View File

@ -1,8 +1,13 @@
#!/usr/bin/env node
"use strict";
"use server";
"use mocha";
require("c9/inline-mocha")(module);
if (typeof define === "undefined") {
require("amd-loader");
}
require("amd-loader");
var assert = require("assert");
var fs = require("fs");
var tmp = require("tmp");
@ -12,11 +17,10 @@ var download = require("./download");
var urlParse = require('url').parse;
var execFile = require('child_process').execFile;
module.exports = {
describe(__filename, function(){
this.timeout(4000);
timeout: 4000,
setUp: function(next) {
beforeEach(function(next) {
var that = this;
var vfs = localfs({root: "/"});
download({}, {
@ -41,80 +45,85 @@ module.exports = {
});
that.server.listen(8787, "0.0.0.0", next);
});
},
});
tearDown: function(next) {
afterEach(function(next) {
this.server.close(next);
},
});
"test download": function(next) {
tmp.dir({unsafeCleanup: true}, function(err, path) {
var filename = path + "/download.tar.gz";
var file = fs.createWriteStream(filename);
http.get("http://localhost:8787/?download=download.tar.gz", function(res) {
assert.equal(res.headers["content-type"], "application/x-gzip");
assert.equal(res.headers["content-disposition"], "attachment; filename*=utf-8''download.tar.gz");
res.pipe(file);
res.on("end", function() {
execFile("tar", ["-zxvf", filename, "c9.vfs.server/download.js"], {cwd: path}, function(err, stdout, stderr) {
assert.equal(err, null);
assert.equal(
fs.readFileSync(__dirname + "/download.js", "utf8"),
fs.readFileSync(path + "/c9.vfs.server/download.js", "utf8")
);
next();
});
});
});
});
},
describe("download", function() {
"test download sub directory": function(next) {
tmp.dir({unsafeCleanup: true}, function(err, path) {
var filename = path + "/download.tar.gz";
var file = fs.createWriteStream(filename);
http.get("http://localhost:8787/views?download=download.tar.gz", function(res) {
res.pipe(file);
res.on("end", function() {
execFile("tar", ["-zxvf", filename, "views/status.html.ejs"], {cwd: path}, function(err) {
assert.equal(err, null);
assert.equal(
fs.readFileSync(__dirname + "/views/status.html.ejs", "utf8"),
fs.readFileSync(path + "/views/status.html.ejs", "utf8")
);
next();
});
});
});
});
},
it("should download", function(next) {
tmp.dir({unsafeCleanup: true}, function(err, path) {
var filename = path + "/download.tar.gz";
var file = fs.createWriteStream(filename);
http.get("http://localhost:8787/?download=download.tar.gz", function(res) {
assert.equal(res.headers["content-type"], "application/x-gzip");
assert.equal(res.headers["content-disposition"], "attachment; filename*=utf-8''download.tar.gz");
"test download without specifying a name": function(next) {
tmp.dir({unsafeCleanup: true}, function(err, path) {
var filename = path + "/download.tar.gz";
var file = fs.createWriteStream(filename);
http.get("http://localhost:8787/views?download", function(res) {
assert.equal(res.headers["content-type"], "application/x-gzip");
assert.equal(res.headers["content-disposition"], "attachment; filename*=utf-8''views.tar.gz");
res.pipe(file);
res.on("end", function() {
execFile("tar", ["-zxvf", filename, "views/status.html.ejs"], {cwd: path}, function(err) {
assert.equal(err, null);
assert.equal(
fs.readFileSync(__dirname + "/views/status.html.ejs", "utf8"),
fs.readFileSync(path + "/views/status.html.ejs", "utf8")
);
next();
res.pipe(file);
res.on("end", function() {
execFile("tar", ["-zxvf", filename, "c9.vfs.server/download.js"], {cwd: path}, function(err, stdout, stderr) {
assert.equal(err, null);
assert.equal(
fs.readFileSync(__dirname + "/download.js", "utf8"),
fs.readFileSync(path + "/c9.vfs.server/download.js", "utf8")
);
next();
});
});
});
});
});
}
};
!module.parent && require("asyncjs").test.testcase(module.exports).exec();
it("should download sub directory", function(next) {
tmp.dir({unsafeCleanup: true}, function(err, path) {
assert.equal(err, null);
var filename = path + "/download.tar.gz";
var file = fs.createWriteStream(filename);
http.get("http://localhost:8787/views?download=download.tar.gz", function(res) {
res.pipe(file);
res.on("end", function() {
execFile("tar", ["-zxvf", filename, "views/status.html.ejs"], {cwd: path}, function(err) {
assert.equal(err, null);
assert.equal(
fs.readFileSync(__dirname + "/views/status.html.ejs", "utf8"),
fs.readFileSync(path + "/views/status.html.ejs", "utf8")
);
next();
});
});
});
});
});
it("should download without specifying a name", function(next) {
tmp.dir({unsafeCleanup: true}, function(err, path) {
assert.equal(err, null);
var filename = path + "/download.tar.gz";
var file = fs.createWriteStream(filename);
http.get("http://localhost:8787/views?download", function(res) {
assert.equal(res.headers["content-type"], "application/x-gzip");
assert.equal(res.headers["content-disposition"], "attachment; filename*=utf-8''views.tar.gz");
res.pipe(file);
res.on("end", function() {
execFile("tar", ["-zxvf", filename, "views/status.html.ejs"], {cwd: path}, function(err) {
assert.equal(err, null);
assert.equal(
fs.readFileSync(__dirname + "/views/status.html.ejs", "utf8"),
fs.readFileSync(path + "/views/status.html.ejs", "utf8")
);
next();
});
});
});
});
});
});
});