Skip to content

Commit

Permalink
Adds Vagrant-based Linux testing VM. Ensures all tests lint correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbdclark committed Jan 30, 2017
1 parent 5644a8a commit face0c7
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
node_modules
bower_components
/.vagrant/
74 changes: 74 additions & 0 deletions Vagrantfile
@@ -0,0 +1,74 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'yaml'

ansible_vars = YAML.load_file("provisioning/vars.yml")

app_name = ansible_vars["nodejs_app_name"]

app_directory = ansible_vars["nodejs_app_install_dir"]

app_start_script = ansible_vars["nodejs_app_start_script"]

# Check for the existence of the 'VM_HOST_TCP_PORT' environment variable. If it
# doesn't exist and 'nodejs_app_tcp_port' is defined in vars.yml then use that
# port. Failing that use defaults provided in this file.
host_tcp_port = ENV["VM_HOST_TCP_PORT"] || ansible_vars["nodejs_app_tcp_port"] || 8081
guest_tcp_port = ansible_vars["nodejs_app_tcp_port"] || 8081

# By default this VM will use 2 processor cores and 2GB of RAM. The 'VM_CPUS' and
# "VM_RAM" environment variables can be used to change that behaviour.
cpus = ENV["VM_CPUS"] || 2
ram = ENV["VM_RAM"] || 2048

Vagrant.configure(2) do |config|

config.vm.box = "inclusivedesign/fedora24"

# Your working directory will be synced to /home/vagrant/sync in the VM.
config.vm.synced_folder ".", "#{app_directory}"

# List additional directories to sync to the VM in your "Vagrantfile.local" file
# using the following format:
# config.vm.synced_folder "../path/on/your/host/os/your-project", "/home/vagrant/sync/your-project"

if File.exist? "Vagrantfile.local"
instance_eval File.read("Vagrantfile.local"), "Vagrantfile.local"
end

# Port forwarding takes place here. The 'guest' port is used inside the VM
# whereas the 'host' port is used by your host operating system.
config.vm.network "forwarded_port", guest: guest_tcp_port, host: host_tcp_port, protocol: "tcp",
auto_correct: true

# Port 19531 is needed so logs can be viewed using systemd-journal-gateway
#config.vm.network "forwarded_port", guest: 19531, host: 19531, protocol: "tcp",
# auto_correct: true

config.vm.hostname = app_name

config.vm.provider :virtualbox do |vm|
vm.customize ["modifyvm", :id, "--memory", ram]
vm.customize ["modifyvm", :id, "--cpus", cpus]
vm.customize ["modifyvm", :id, "--vram", "256"]
vm.customize ["modifyvm", :id, "--accelerate3d", "off"]
vm.customize ["modifyvm", :id, "--audio", "null", "--audiocontroller", "ac97"]
vm.customize ["modifyvm", :id, "--ioapic", "on"]
vm.customize ["setextradata", "global", "GUI/SuppressMessages", "all"]
end

config.vm.provision "shell", inline: <<-SHELL
sudo dnf -y upgrade firefox google-chrome-stable
sudo ansible-galaxy install -fr /home/vagrant/sync/provisioning/requirements.yml
sudo PYTHONUNBUFFERED=1 ansible-playbook /home/vagrant/sync/provisioning/playbook.yml --tags="install,configure"
SHELL

# Using config.vm.hostname to set the hostname on Fedora VMs seems to remove the string
# "localhost" from the first line of /etc/hosts. This script reinserts it if it's missing.
# https://github.com/mitchellh/vagrant/pull/6203
config.vm.provision "shell",
inline: "/usr/local/bin/edit-hosts.sh",
run: "always"

end
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -48,6 +48,7 @@
"scripts": {
"test": "npm run node-test && npm run browser-test",
"browser-test": "testem ci --file tests/unit/testem.json",
"node-test": "node tests/unit/nodejs/all-node-tests.js"
"node-test": "node tests/unit/nodejs/all-node-tests.js",
"linux-vm-test": "vagrant ssh -c 'cd /home/vagrant/sync/; DISPLAY=:0 npm test'"
}
}
12 changes: 12 additions & 0 deletions provisioning/clean-npm.sh
@@ -0,0 +1,12 @@
#!/bin/bash
if [ -d "node_modules" ]; then
rm -r node_modules
fi

if [ -d ".npm" ]; then
rm -r .npm
fi

if [ -d ".npmrc" ]; then
rm -r .npmrc
fi
10 changes: 10 additions & 0 deletions provisioning/playbook.yml
@@ -0,0 +1,10 @@
---
- hosts: localhost
user: root

vars_files:
- vars.yml

roles:
- facts
- nodejs
5 changes: 5 additions & 0 deletions provisioning/requirements.yml
@@ -0,0 +1,5 @@
- src: https://github.com/idi-ops/ansible-facts
name: facts

- src: https://github.com/idi-ops/ansible-nodejs
name: nodejs
37 changes: 37 additions & 0 deletions provisioning/vars.yml
@@ -0,0 +1,37 @@
---
# Please refer to https://github.com/idi-ops/ansible-nodejs/blob/master/defaults/main.yml
# for documentation related to these variables

nodejs_app_name: flocking-linux

nodejs_app_git_repo: https://github.com/colinbdclark/Flocking.git

nodejs_app_git_branch: master

nodejs_branch: lts

# If a specific npm version is needed, specify it here
#nodejs_npm_version: 1.4.28

nodejs_app_rpm_packages:
- alsa-lib-devel
- libstdc++
- gcc-c++
- gyp
- libstdc++-devel
- libuv
- libuv-devel

nodejs_app_npm_packages:
- node-gyp
- testem
- grunt

nodejs_app_commands:
- ./provisioning/clean-npm.sh
- npm install
- grunt

nodejs_app_install_dir: /home/vagrant/sync

nodejs_app_git_clone: false
7 changes: 3 additions & 4 deletions tests/unit/js/buffer-ugen-tests.js
Expand Up @@ -6,7 +6,7 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
*/

/*global require, Float32Array*/
/*global require*/

var fluid = fluid || require("infusion"),
jqUnit = jqUnit || fluid.require("node-jqunit"),
Expand All @@ -15,12 +15,11 @@ var fluid = fluid || require("infusion"),
(function () {
"use strict";

var QUnit = fluid.registerNamespace("QUnit"),
$ = fluid.registerNamespace("jQuery");
var QUnit = fluid.registerNamespace("QUnit");

fluid.registerNamespace("flock.test.ugen.bufferDuration");

module = flock.test.module({
var module = flock.test.module({
name: "flock.ugen.bufferDuration tests",

enviroOptions: {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/js/perf-tests.js
Expand Up @@ -79,8 +79,8 @@ var fluid = fluid || require("infusion"),
});

var avg = runTimingTest(synth.nodeList.nodes, 50);
assertCeiling(avg, 5,
"Generating and outputting 1 second of stereo signal from flock.ugen.value should take less than 5 ms.");
assertCeiling(avg, 7,
"Generating and outputting 1 second of stereo signal from flock.ugen.value should take less than 7 ms.");
});

flock.test.module({
Expand Down
5 changes: 1 addition & 4 deletions tests/unit/js/playbuffer-ugen-tests.js
Expand Up @@ -6,7 +6,7 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
*/

/*global require, Float32Array*/
/*global require*/

var fluid = fluid || require("infusion"),
jqUnit = jqUnit || fluid.require("node-jqunit"),
Expand All @@ -15,9 +15,6 @@ var fluid = fluid || require("infusion"),
(function () {
"use strict";

var QUnit = fluid.registerNamespace("QUnit"),
$ = fluid.registerNamespace("jQuery");

fluid.registerNamespace("flock.test");

flock.test.registerBuffer = function (enviro, id, left, right) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/js/writebuffer-ugen-tests.js
Expand Up @@ -6,7 +6,7 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
*/

/*global require, Float32Array*/
/*global require*/

var fluid = fluid || require("infusion"),
jqUnit = jqUnit || fluid.require("node-jqunit"),
Expand Down

0 comments on commit face0c7

Please sign in to comment.