Skip to content

Commit

Permalink
Added integration tests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
peol committed Apr 17, 2018
1 parent 49959a3 commit a46a9cd
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 25 deletions.
55 changes: 30 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,60 @@ jobs:
build:
working_directory: ~/enigma.js
docker:
- image: circleci/node:8.6.0
- image: circleci/node:8.11.1
environment:
- NPM_CONFIG_LOGLEVEL=warn
steps:
- checkout
- run:
name: greenkeeper - Update
command: |
sudo npm install -g greenkeeper-lockfile@1
greenkeeper-lockfile-update
name: Update global packages
command: sudo npm install -g npm@5 greenkeeper-lockfile@1
- run:
name: Maybe update dependencies lockfile
command: greenkeeper-lockfile-update
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Install dependencies
command: npm install --no-save
command: npm install
- run:
name: greenkeeper - Upload
name: Maybe upload dependencies lockfile
command: greenkeeper-lockfile-upload
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- node_modules
- run:
name: Linting
name: Lint source code
command: npm run -s lint
- run:
name: Unit & component testing
name: Build modules
command: npm run -s build
- run:
name: Create npm package
command: |
npm pack
mv enigma*.tgz enigma.tgz
- run:
name: Execute unit & component tests
command: |
npm run -s test
if [ ! -z "$COVERALLS_REPO_TOKEN" ]; then
echo "Uploading coverage results to coveralls.io..."
npm install -s nyc@11.3.0
npm install -s coveralls@3.0.0
./node_modules/.bin/nyc report --reporter=text-lcov --temp-directory=./coverage/.nyc_output | ./node_modules/.bin/coveralls
npm install -s nyc@11.3.0 coveralls@3.0.0
npx nyc report --reporter=text-lcov --temp-directory=./coverage/.nyc_output | npx coveralls
fi
- setup_remote_docker
- run:
name: Generate JSDoc
command: npm run -s jsdoc
- run:
name: Build library
command: npm run -s build
- run:
name: Create npm package
name: Execute integration tests
command: |
npm pack
mv enigma*.tgz enigma.tgz
- store_artifacts:
path: enigma.tgz
- store_artifacts:
path: jsdoc
ENGINE_CONTAINER_ID=$(docker run -d qlikcore/engine:12.160.0 -S AcceptEULA=yes)
ENGINE_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' $ENGINE_CONTAINER_ID)
TEST_CONTAINER_ID=$(docker run -d node:8.11.1-alpine tail -f /dev/null)
docker cp . $TEST_CONTAINER_ID:/
docker exec $TEST_CONTAINER_ID /bin/sh -c 'apk update && apk add --no-cache socat'
docker exec -d $TEST_CONTAINER_ID /bin/sh -c 'socat TCP-LISTEN:9076,fork TCP:$ENGINE_IP:9076'
docker exec $TEST_CONTAINER_ID /bin/sh -c 'npm run -s test:integration'
docker exec $TEST_CONTAINER_ID /bin/sh -c 'test/examples/run.sh'
- store_artifacts:
path: coverage
36 changes: 36 additions & 0 deletions test/examples/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

cd "$(dirname "$0")"

cd ../../examples

echo "Installing example dependencies..."
npm install --no-save

if [ -f ../enigma.tgz ]; then
echo "Found local enigma.tgz file, installing..."
npm install ../enigma.tgz --no-save
fi

examples=(
basics/events/generated-apis.js
basics/events/session.js
basics/lists/app-object-list.js
basics/lists/field-list.js
data/hypercubes/hypercube-pivot.js
data/hypercubes/hypercube-stacked.js
data/hypercubes/hypercube-straight.js
data/list-object/list-object.js
data/string-expression/string-expression.js
interceptors/retry-aborted/retry-aborted.js
mixins/complex/complex.js
mixins/simple/simple.js
)

for example in ${examples[@]}; do
echo
echo "Starting example: $example"
echo "process.on('unhandledRejection',error=>console.log(error)||process.exit(1));require('./$example');" > run.js
node run
echo "Ending example: $example"
done
2 changes: 2 additions & 0 deletions test/integration/suspend-resume.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ describe('QIX Suspend/Resume', () => {
const suspended = sinon.spy();
const closed = sinon.spy();
const session = Qix.create(config);
/* eslint no-console:0 */
session.on('traffic:*', console.log);
session.on('suspended', suspended);
session.on('closed', closed);
const id = generateId();
Expand Down

0 comments on commit a46a9cd

Please sign in to comment.