Skip to content

Instantly share code, notes, and snippets.

@avtar
Created May 12, 2017 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avtar/48c45e219c32e36db071a5464626b5e3 to your computer and use it in GitHub Desktop.
Save avtar/48c45e219c32e36db071a5464626b5e3 to your computer and use it in GitHub Desktop.
F2F DevOps - Vagrant Kasper's PR
Running the preferences server on port 8081 causes an issue with the production config tests because this config spawns multiple ephemeral preferences servers during the tests, and everything is hardcoded to use port 8081....
It seems this will become an impossible task without the env var support... so even the tests can be told to use another port.
Additionally, there are some tests that connect directly to CouchDB on localhost:5984... they would also have to be modified.
ENSURE YOU HAVE AN UPDATED VAGRANT BOX (`vagrant box update`)
FROM node:6-alpine
WORKDIR /home/node/node_modules/universal
COPY . /home/node/node_modules/universal
RUN apk add --no-cache --virtual build-dependencies python make git g++ && \
yarn --production && \
yarn cache clean && \
apk del build-dependencies
CMD ["sh","-c","node gpii.js"]
.git
node_modules
#!/bin/sh
if [ $# -ne 2 ]; then
echo "Usage: $0 <dir> <url>"
exit 1
fi
DIR=$1
URL=$2
curl -X DELETE $URL
curl -X PUT $URL
for file in `ls $DIR/*.json`; do
FILENAME=$(basename $file .json)
DATA="{ \"_id\":\"$FILENAME\", \"value\":$(cat $file) }"
echo "Upload $file"
curl -q -H 'Content-Type: application/json' \
-X POST $URL \
-d "$DATA"
if [ $? -ne 0 ]; then
echo "Failed"
exit 1
fi
done
env:
vms:
server:
box: inclusivedesign/centos7
stages:
- setup
- test
setup_job:
stage: setup
script:
# Clean workspace (delete old image and containers)
- docker rmi -f universal || true
- docker rm -f couchdb || true
- docker rm -f prefs-server || true
# Build new image
- docker build -t universal .
# Run CouchDB and Preferences Server
- docker run -d --net host -p 5984 --name couchdb couchdb
- docker run -d --net host -p 8081 --name prefs-server -e NODE_ENV=gpii.config.preferencesServer.standalone.production universal
# Load Preferences Data
- /vagrant/testData/preferences/uploadPrefData.sh /vagrant/testData/preferences http://localhost:5984/preferences
test_job:
stage: test
script:
# Run tests inside container we built previously
- docker run --rm -i --net host universal npm test
- docker run --rm -i --net host universal node tests/ProductionConfigTests.js
# Antranig raised a good point: testing the GPII/universal repo doesn't need to happen on Linux and Windows, it's enough to test this only on Linux.
# Because of this, the updated config file only has one VM.
env:
default: &default
cpu: 1
memory: 2048
autostart: false
vms:
server:
<<: *default
box: inclusivedesign/centos7 # CouchDB, preferences-server
tags: ['server']
memory: 1024
windows:
<<: *default
box: inclusivedesign/windows10-eval-x64
tags: ['windows']
linux:
<<: *default
box: inclusivedesign/fedora24
tags: ['fedora']
stages:
- setup_server
- setup_client
- test_server
- test_client
setup_server_job:
stage: setup_server
tags: ['server']
script:
# Clean workspace (delete old image and containers)
- docker rmi -f universal || true
- docker rm -f couchdb || true
- docker rm -f prefs-server || true
# Build new image
- docker build -t universal .
# Run CouchDB and Preferences Server
- docker run -d --net host -p 5984 --name couchdb couchdb
- docker run -d --net host -p 8081 --name prefs-server -e NODE_ENV=gpii.config.preferencesServer.standalone.production universal
# Load Preferences Data
- testData/preferences/uploadPrefData.sh testData/preferences http://localhost:5984/preferences
test_server_job:
stage: test_server
tags: ["server"]
script:
# Run tests inside container we built previously
- docker run --rm -i universal npm test
- docker run --rm -i universal node tests/ProductionConfigTests.js
setup_client_job:
stage: setup_client
tags: ['windows']
script:
- |
choco upgrade firefox googlechrome -y
$moduleLocation = Join-Path $env:SystemDrive "vagrant/provisioning/Provisioning.psm1"
$destinationDir = Join-Path $env:SystemDrive "tmp"
cp $moduleLocation $destinationDir
- provisioning/Chocolatey.ps1
- provisioning/Npm.ps1
- provisioning/Build.ps1
- provisioning/Installer.ps1
test_client_job:
stage: test_client
tags: ["windows"]
script:
- do.ps1 -c 'node tests/AcceptanceTests.js builtIn'
- do.ps1 -c 'node tests/UnitTests.js'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment