Skip to content

Commit

Permalink
setup gtm on travis
Browse files Browse the repository at this point in the history
  • Loading branch information
killmenot committed Nov 28, 2017
1 parent 08d14b9 commit 97dd38f
Show file tree
Hide file tree
Showing 23 changed files with 270 additions and 33 deletions.
7 changes: 7 additions & 0 deletions .chef/knife.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cookbook_path "chef/cookbooks"
node_path "chef/nodes"
role_path "chef/roles"
environment_path "chef/environments"
data_bag_path "chef/data_bags"

knife[:berkshelf_path] = "chef/cookbooks"
2 changes: 2 additions & 0 deletions .librarian/chef/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
LIBRARIAN_CHEF_PATH: chef/cookbooks
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm --create use ruby-2.3.1
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,26 @@ node_js:
- '6'
services:
- redis-server
before_install:
- chmod +x `ls installers/*.sh`
- if [ $DATABASE = "gtm" ]; then
./installers/install_gtm_only.sh;
source ~/.profile;
./installers/install_nodem.sh $TRAVIS_BUILD_DIR;
source ~/.profile;
fi
env:
# Can't figure out how to DRY this up: http://stackoverflow.com/q/22397300/3191
- WEB_SERVER=express DATABASE=redis
- WEB_SERVER=koa DATABASE=redis
- WEB_SERVER=express DATABASE=gtm
- WEB_SERVER=koa DATABASE=gtm
matrix:
exclude:
- node_js: '6'
env: WEB_SERVER=koa DATABASE=redis
- node_js: '6'
env: WEB_SERVER=koa DATABASE=gtm
after_success:
- npm run coverage:unit
- npm run coveralls
7 changes: 7 additions & 0 deletions Cheffile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
#^syntax detection

site 'https://supermarket.getchef.com/api/v1'

cookbook 'git', '~> 6.1.0'
cookbook 'nodejs', '~> 3.0.0'
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

group :development do
gem 'librarian-chef'
end
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Twitter: [@rtweed](https://twitter.com/rtweed)

Google Group for discussions, support, advice etc: [http://groups.google.co.uk/group/enterprise-web-developer-community](http://groups.google.co.uk/group/enterprise-web-developer-community)

Thanks to Ward De Backer for debugging assistance and functionality suggestions
Thanks to Ward De Backer for debugging assistance and functionality suggestions.


## What is QEWD?

This is best answered by reading [this article on QEWD](https://robtweed.wordpress.com/2017/04/18/having-your-node-js-cake-and-eating-it-too/)
This is best answered by reading [this article on QEWD](https://robtweed.wordpress.com/2017/04/18/having-your-node-js-cake-and-eating-it-too/).

In summary: [QEWD](http://qewdjs.com) is a Node.js-based platform for developing and running interactive browser-based applications and Web/REST services.

Expand Down Expand Up @@ -79,7 +79,8 @@ See the free online [training course](http://docs.qewdjs.com/qewd_training.html)

## License

Copyright (c) 2016 M/Gateway Developments Ltd,
```
Copyright (c) 2017 M/Gateway Developments Ltd,
Reigate, Surrey UK.
All rights reserved.
Expand All @@ -98,3 +99,4 @@ See the free online [training course](http://docs.qewdjs.com/qewd_training.html)
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
142 changes: 142 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu/trusty64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
#
# View the documentation for the provider you're using for more
# information on available options.

config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
v.customize ["modifyvm", :id, "--memory", "2048"]
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
end

# Enable provisioning with CFEngine. CFEngine Community packages are
# automatically installed. For example, configure the host as a
# policy server and optionally a policy file to run:
#
# config.vm.provision "cfengine" do |cf|
# cf.am_policy_hub = true
# # cf.run_file = "motd.cf"
# end
#
# You can also configure and bootstrap a client to an existing
# policy server:
#
# config.vm.provision "cfengine" do |cf|
# cf.policy_server_address = "10.0.2.15"
# end

# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file default.pp in the manifests_path directory.
#
# config.vm.provision "puppet" do |puppet|
# puppet.manifests_path = "manifests"
# puppet.manifest_file = "site.pp"
# end

# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
# config.vm.provision "chef_solo" do |chef|
# chef.cookbooks_path = "../my-recipes/cookbooks"
# chef.roles_path = "../my-recipes/roles"
# chef.data_bags_path = "../my-recipes/data_bags"
# chef.add_recipe "mysql"
# chef.add_role "web"
#
# # You may also specify custom JSON attributes:
# chef.json = { mysql_password: "foo" }
VAGRANT_JSON = JSON.parse(Pathname(__FILE__).dirname.join('chef', 'nodes', 'vagrant.json').read)

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "chef/cookbooks"
chef.provisioning_path = "/tmp/vagrant-chef"

# You may also specify custom JSON attributes:
chef.run_list = VAGRANT_JSON.delete('run_list')
chef.json = VAGRANT_JSON
end

# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision "chef_client" do |chef|
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
# chef.validation_key_path = "ORGNAME-validator.pem"
# end
#
# If you're using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = "ORGNAME-validator"

config.omnibus.chef_version = '13.1.31'
end
16 changes: 16 additions & 0 deletions chef/nodes/vagrant.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"git": {
"version": "2.15.0"
},
"nodejs": {
"version": "9.2.0",
"install_method": "binary",
"binary": {
"checksum": "84579415724cd607d177cd493881b409be08203198abbb26834e06b0b4462b59"
}
},
"run_list": [
"recipe[git]",
"recipe[nodejs]"
]
}
3 changes: 2 additions & 1 deletion lib/appHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ module.exports = function() {
result = handleJWT.reregister.call(this, session, messageObj);
}
else {
session.socketId = messageObj.socketId;
if (messageObj.socketId) session.socketId = messageObj.socketId;
if (messageObj.ipAddress) session.ipAddress = messageObj.ipAddress;
result = {ok: true};
}

Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"ewd-client": "^1.17.0",
"ewd-qoper8": "^3.16.0",
"ewd-qoper8-cache": "^2.2.1",
"ewd-qoper8-express": "killmenot/ewd-qoper8-express#refactoring",
"ewd-qoper8-express": "github:killmenot/ewd-qoper8-express#refactoring",
"ewd-qoper8-gtm": "^2.3.2",
"ewd-qoper8-koa": "killmenot/ewd-qoper8-koa#tests",
"ewd-qoper8-koa": "github:killmenot/ewd-qoper8-koa#tests",
"ewd-qoper8-redis": "^0.1.1",
"ewd-session": "^2.19.0",
"express": "^4.16.2",
Expand All @@ -58,7 +58,6 @@
"koa-better-router": "^2.1.1",
"koa-bodyparser": "^4.2.0",
"koa-static": "^4.0.1",
"polyjuice": "^2.2.4",
"qewd-monitor": "^2.4.0",
"qewd-router": "^1.12.0",
"redis": "^2.8.0",
Expand All @@ -81,8 +80,8 @@
"nyc": "^11.1.0",
"pre-commit": "^1.2.2",
"qewd": "file:./",
"rewire": "killmenot/rewire#fix-101",
"rewire": "github:killmenot/rewire#fix-101",
"supertest": "^3.0.0",
"tcp-netx": "^1.0.7-a"
"tcp-netx": "^1.0.7"
}
}
5 changes: 5 additions & 0 deletions spec/helpers/timeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000;

process.env.QEWD_STARTED_TIMEOUT = 1000;
process.env.EXIT_TIMEOUT = 1000;
process.env.MICROSERVICES_STARTED_TIMEOUT = 5000;
14 changes: 13 additions & 1 deletion spec/integration/microservices/primary/qewd.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ const config = {
host: 'http://127.0.0.1:8081',
application: 'login-micro-service'
},
store: {
store1: {
host: 'http://127.0.0.1:8082',
application: 'stock-list'
},
store2: {
host: 'http://127.0.0.1:8082',
application: 'stock-list'
},
all_stores: {
destinations: ['store1', 'store2']
}
},
routes: [
Expand All @@ -56,6 +63,11 @@ const config = {
{
path: '/api/store/:destination/category/:category/stocklist',
method: 'GET'
},
{
path: '/api/store/all/stocklist',
method: 'GET',
destination: 'all_stores'
}
]
}
Expand Down
28 changes: 14 additions & 14 deletions spec/integration/microservices/testrunner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const async = require('async');
const isJWT = require('is-jwt');
const request = require('supertest')('http://localhost:8080');
const utils = require('../utils');
const MICROSERVICES_STARTED_TIMEOUT = process.env.MICROSERVICES_STARTED_TIMEOUT;

describe('integration/qewd/microservices:', () => {
let cps;
Expand All @@ -23,7 +24,7 @@ describe('integration/qewd/microservices:', () => {
if (err) return done.fail(err);

cps = results;
done();
setTimeout(done, MICROSERVICES_STARTED_TIMEOUT);
});
});

Expand Down Expand Up @@ -81,18 +82,18 @@ describe('integration/qewd/microservices:', () => {
});
});

describe('GET /api/info', () => {
it('should be able to do request to local handlers and return data', (done) => {
describe('GET /api/patient/:patientId/demographics', () => {
it('should be able to do request to micro service return data', (done) => {
request.
get('/api/info').
get('/api/patient/123457/demographics').
set('authorization', `Bearer ${token}`).
expect(200).
expect(res => {
expect(res.body).toEqual({
info: {
server: 'primary-server',
loggedInAs: 'rob'
},
firstName: 'Jane',
lastName: 'Smith',
gender: 'Female',
country: 'USA',
token: jasmine.any(String)
});
expect(isJWT(res.body.token)).toBeTruthy();
Expand All @@ -101,18 +102,17 @@ describe('integration/qewd/microservices:', () => {
});
});

describe('GET /api/patient/:patientId/demographics', () => {
describe('GET /api/store/:destination/stocklist', () => {
it('should be able to do request to micro service return data', (done) => {
request.
get('/api/patient/123457/demographics').
get('/api/store/store1/stocklist').
set('authorization', `Bearer ${token}`).
expect(200).
expect(res => {
expect(res.body).toEqual({
firstName: 'Jane',
lastName: 'Smith',
gender: 'Female',
country: 'USA',
store: 'store1',
ip: '127.0.0.1:8082',
stock: 'stock list here...',
token: jasmine.any(String)
});
expect(isJWT(res.body.token)).toBeTruthy();
Expand Down
Loading

0 comments on commit 97dd38f

Please sign in to comment.