Skip to content
This repository was archived by the owner on Nov 7, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into livestream
Browse files Browse the repository at this point in the history
  • Loading branch information
yourcelf committed Mar 31, 2016
2 parents a6f795b + 732bfac commit 00d3e7b
Show file tree
Hide file tree
Showing 22 changed files with 191 additions and 89 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
language: node_js
node_js:
- 0.10
addons:
firefox: "28.0"
env: DISPLAY=:99.0
#addons:
# firefox: "38.7.1esr"
#env: DISPLAY=:99.0
services:
- redis-server
before_install:
- sudo apt-get update && sudo apt-get install -qq build-essential libssl-dev curl
- sh -e /etc/init.d/xvfb start
- cp conf.json.example conf.json
before_script:
- curl -L https://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.0.jar > bin/selenium-server-standalone.jar
script: "npm test"
# - sh -e /etc/init.d/xvfb start
#before_script:
# - curl -L https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar > bin/selenium-server-standalone.jar
script: "npm run noseleniumtest"
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## v2.1.0

- Upgrade to selenium-server-standalone v2.53.0 and selenium-webdriver v2.47.0. You will likely need to re-download selenium-server-standalone:

curl -L https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar > bin/selenium-server-standalone.jar

- Tear out old farming functionality, which Google broke. See [hangout-farmer](https://github.com/unhangout/hangout-farmer.git) for a temporary workaround until we can replace Google Hangouts.

## v2.0.0

- First version of changelog.
1 change: 1 addition & 0 deletions bin/selenium.loglevel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.util.logging.ConsoleHandler.level = OFF
11 changes: 9 additions & 2 deletions bin/uglytests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/bin/bash

cleanup () {
if [ -n "$SELENIUM" ]; then
kill -9 $SELENIUM
fi
exit 1
}

# Stop everything if we get control-c, even if we aren't done.
trap "exit 1" SIGINT SIGTERM
trap cleanup SIGINT SIGTERM INT

# Change to the project root -- one above the current directory.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Expand All @@ -17,7 +24,7 @@ EXIT=$?

# Run selenium tests, one at a time.
for TEST in test/test.*.selenium.js ; do
NODE_ENV=testing $MOCHA $TEST
NODE_ENV=testing $MOCHA $TEST || NODE_ENV=testing $MOCHA $TEST
STATUS=$?
if [ $STATUS -ne 0 ]; then
EXIT=$STATUS
Expand Down
19 changes: 17 additions & 2 deletions lib/hangout-farming.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ exports.init = function(app, db, options) {
}
});
});
}
};

// get a hangout url from redis
exports.getNextHangoutUrl = function(callback) {

// just hit redis directly here, with an rpop.
curDb.redis.rpop("global:hangout_urls", function(err, url) {
if (!err) {
numHangoutUrlsAvailable--;
numHangoutUrlsAvailable = Math.max(0, numHangoutUrlsAvailable - 1);
}
callback && callback(err, url);
logger.analytics("farming", {action: "consume", url: url, total: numHangoutUrlsAvailable});
Expand All @@ -163,3 +163,18 @@ exports.reuseUrl = function(url, callback) {
exports.getNumHangoutsAvailable = function() {
return numHangoutUrlsAvailable;
}

// Remove all URLs from redis. Used only by tests.
exports.popAllUrls = function(callback) {
var urls = [];
exports.getNextHangoutUrl(function(err, url) {
if (err) {
return callback(err);
} else if (url === null) {
return callback(null, urls);
} else {
urls.push(url);
return exports.popAllUrls(callback);
}
});
}
6 changes: 5 additions & 1 deletion lib/unhangout-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var logger = require('./logging').getLogger(),
var UnhangoutDb = function(options) {
this.options = options;
};

var _origUsersComparator;
_.extend(UnhangoutDb.prototype, events.EventEmitter.prototype, {
init: function(callback) {
_.bindAll(this, "loadModels");
Expand All @@ -19,6 +19,8 @@ _.extend(UnhangoutDb.prototype, events.EventEmitter.prototype, {
this.options.UNHANGOUT_REDIS_HOST
);
this.users = new models.ServerUserList();
_origUsersComparator = this.users.comparator;
this.users.comparator = undefined;
this.events = new models.ServerEventList();
this.permalinkSessions = new models.ServerSessionList();

Expand Down Expand Up @@ -205,6 +207,8 @@ _.extend(UnhangoutDb.prototype, events.EventEmitter.prototype, {
};
async.mapSeries(loaders, load, function(err, results) {
logger.info("Done loading models.");
that.users.comparator = _origUsersComparator;
that.users.sort();
callback();
});

Expand Down
2 changes: 1 addition & 1 deletion lib/unhangout-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ module.exports = {
var message = {
"html": html,
"subject": "unhangout administrator account",
"from_email": "[email protected]",
"from_email": options.UNHANGOUT_SERVER_EMAIL_ADDRESS,
"from_name": "Unhangout Team",
"to": [{
"email": req.body.adminInviteeEmail
Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unhangout-server",
"version": "2.0.0",
"version": "2.1.0",
"author": "Drew Harry <[email protected]>",
"description": "a server for managing un-hangouts; large scale online un-conference-style events using Google Hangout",
"contributors": [
Expand All @@ -23,10 +23,7 @@
"start": "node ./bin/unhangout-server",
"setup": "source conf.sh",
"test": "bin/uglytests.sh",
"forever-start": "NODE_ENV=production forever start --minUptime 1000 --spinSleepTime 1000 -a -l unhangout.log -o logs/out.log -e logs/err.log bin/unhangout-server",
"forever-stop": "forever stop bin/unhangout-server",
"forever-restart": "NODE_ENV=production forever restart bin/unhangout-server",
"forever-list": "forever list"
"noseleniumtest": "NODE_ENV=testing SKIP_SELENIUM_TESTS=1 mocha"
},
"main": "./lib/unhangout-server.js",
"repository": {
Expand Down Expand Up @@ -73,8 +70,8 @@
"expect.js": "0.3.1",
"libxmljs": "git://github.com/gwicke/libxmljs.git#7e1ceaf",
"mailparser": "~0",
"mocha": "1.18.2",
"selenium-webdriver": "2.44.0",
"mocha": "2.4.5",
"selenium-webdriver": "2.47.0",
"should": "3.2.0-beta1",
"simplesmtp": "~0",
"sinon": "1.10.3",
Expand Down
1 change: 1 addition & 0 deletions public/js/event-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ $(document).ready(function() {
if(IS_ADMIN) {
if (NUM_HANGOUT_URLS_WARNING > 0 && NUM_HANGOUT_URLS_AVAILABLE < NUM_HANGOUT_URLS_WARNING) {
$("#no-urls-warning").modal('show');
console.error("Too few hangout URLS available!", NUM_HANGOUT_URLS_AVAILABLE);
}
this.adminButtonView = new eventViews.AdminButtonView({
event: curEvent, transport: trans
Expand Down
33 changes: 32 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var conf = require("../lib/options"),
unhangoutServer = require('../lib/unhangout-server'),
farming = require("../lib/hangout-farming"),
seed = require('../bin/seed.js'),
path = require("path"),
redis = require("redis").createClient(),
Expand Down Expand Up @@ -78,6 +79,11 @@ var buildBrowser = function(callback) {
browser.get(exports.FAST_URL);
return browser.executeScript("document.cookie = 'mock_user=; path=/';");
};
browser.awaitModalDismissal = function(selector) {
return browser.wait(webdriver.until.elementIsNotVisible(
browser.findElement(webdriver.By.css(selector || ".modal")))
);
};
// This is sugar to wrap selenium's `wait` with a default timeout. We want
// to throw exceptions rather than waiting for mocha's timeout so that we
// can see a stack trace (mocha's timeous don't provide one).
Expand Down Expand Up @@ -256,14 +262,27 @@ exports.server = null;
// A list of all open connections to the HTTP server, which we can nuke to
// allow us to force-restart the server.

function addDummyFarmedUrls(numToAdd, callback) {
if (isNaN(numToAdd)) {
throw Error("Asked to add NaN urls");
}
if (numToAdd <= 0) {
callback();
} else {
farming.reuseUrl("http://example.com", function(err) {
if (err) { throw err; }
addDummyFarmedUrls(numToAdd - 1, callback);
});
}
}

exports.standardSetup = function(done, skipSeed) {
exports.server = new unhangoutServer.UnhangoutServer();

exports.server.on("inited", function() {
exports.server.start()
});
exports.server.on("started", function() {
done();
// This is a hack to allow us to kill the server while it still has
// ongoing connections, without terminating the node process. We use
// this for simulating server restarts.
Expand All @@ -281,6 +300,18 @@ exports.standardSetup = function(done, skipSeed) {
}
OPEN_CONNS = [];
});
if (skipSeed) {
done();
} else {
// Ensure there is at least one hangout URL to suppress modal warning
// that breaks tests.
exports.server.db.redis.llen("global:hangout_urls", function(err, len) {
if (err) { throw err; }
if (len < conf.UNHANGOUT_HANGOUT_URLS_WARNING) {
addDummyFarmedUrls(conf.UNHANGOUT_HANGOUT_URLS_WARNING - len, done);
}
});
}
});
if (!skipSeed) {
exports.seedDatabase(function() {
Expand Down
5 changes: 4 additions & 1 deletion test/test.chat.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("CHAT", function() {
browser.executeScript('$("#chat-container-region .panel-body").scrollTop(100)');
checkScroll(browser, false)
browser.byCss("#chat-input").sendKeys("msg " + i + "\n");
checkScroll(browser, true).then(function() { done(); });
checkScroll(browser, true);
browser.executeScript('$("#chat-container-region .panel-body").scrollTop(100)').then(function() {;
// Send a message from another user.
sock.write(JSON.stringify({
Expand Down Expand Up @@ -116,6 +116,9 @@ describe("CHAT", function() {
}
});
checkScroll(browser, false);
browser.then(function() {
done();
});

});

Expand Down
3 changes: 2 additions & 1 deletion test/test.create-sessions.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ describe("CREATE SESSIONS", function() {
browser.byCss("#join_cap").clear();
browser.byCss("#join_cap").sendKeys("wat");
browser.byCss("#join_cap").getAttribute("value").then(function(val) {
expect(val).to.be("wat");
//expect(val).to.be("wat"); // Recent firefox doesn't allow these chars on number input
expect(val).to.be("");
});
browser.byCss("#create-session").click();
browser.waitForSelector(".join-cap-error");
Expand Down
16 changes: 9 additions & 7 deletions test/test.event-session-messages.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ describe("EVENT SESSION MESSAGES", function() {

beforeEach(function(done) {
this.timeout(240000);
common.getSeleniumBrowser(function (theBrowser) {
browser = theBrowser;
common.standardSetup(function() {
event = common.server.db.events.findWhere({shortName: "writers-at-work"});
event.set("open", true);
done();
});
common.stopSeleniumServer().then(function() {
common.getSeleniumBrowser(function (theBrowser) {
browser = theBrowser;
common.standardSetup(function() {
event = common.server.db.events.findWhere({shortName: "writers-at-work"});
event.set("open", true);
done();
});
});
});
});
afterEach(function(done) {
Expand Down
5 changes: 5 additions & 0 deletions test/test.facilitator-embeds.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ describe("FACILITATOR EMBEDS", function() {
});

// Remove the embed.
browser.awaitModalDismissal();
browser.byCss(".activity-settings").click();
browser.waitForSelector(".remove-embed");
browser.byCss(".remove-embed").click();

// Ensure 'about' is displayed.
browser.awaitModalDismissal();
browser.waitForSelector(".about-activity");
browser.waitForScript("$");
browser.executeScript("return $('.about-activity').text();").then(function(text) {
Expand All @@ -77,6 +79,7 @@ describe("FACILITATOR EMBEDS", function() {
});

// Add a new activity.
browser.awaitModalDismissal();
browser.byCss(".add-activity").click();
browser.waitForSelector(".add-activity-dialog input[type='text']");
// Doesn't allow blank URL's.
Expand All @@ -97,6 +100,8 @@ describe("FACILITATOR EMBEDS", function() {
}]);
});
// Embeds youtube videos.
browser.awaitModalDismissal(".add-activity-dialog");
browser.waitTime(1000);
browser.byCss(".activity-settings").click();
// Can't seem to get around this hard-coded delay; get occasional
// "Element is no longer attached to the DOM" errors without it.
Expand Down
8 changes: 5 additions & 3 deletions test/test.frontend.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ describe("FRONT PAGE", function() {

before(function(done) {
this.timeout(240000);
common.getSeleniumBrowser(function (theBrowser) {
browser = theBrowser;
common.standardSetup(done);
common.stopSeleniumServer().then(function() {
common.getSeleniumBrowser(function (theBrowser) {
browser = theBrowser;
common.standardSetup(done);
});
});
});
after(function(done) {
Expand Down
Loading

0 comments on commit 00d3e7b

Please sign in to comment.