Skip to content

Commit

Permalink
Execute tests with versions 3.2, 3.4, 3.6 and 4.0 of MongoDB (#13049)
Browse files Browse the repository at this point in the history
* Execute tests with versions 3.2, 3.4, 3.6 and 4.0 of MongoDB

* Reduce duplicated configuration

* Fix image inherintence

* Fix test of mongo 4 without oplog
  • Loading branch information
rodrigok authored Dec 28, 2018
1 parent d828b1e commit 5fb5d79
Showing 1 changed file with 126 additions and 82 deletions.
208 changes: 126 additions & 82 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,74 @@
defaults: &defaults
working_directory: ~/repo

attach_workspace: &attach_workspace
at: /tmp

test-install-dependencies: &test-install-dependencies
name: Install dependencies
command: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb [ arch=amd64 ] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org-shell google-chrome-stable
test-run: &test-run
name: Run Tests
command: |
for i in $(seq 1 5); do mongo rocketchat --eval 'db.dropDatabase()' && npm test && s=0 && break || s=$? && sleep 1; done; (exit $s)
test-npm-install: &test-npm-install
name: NPM install
command: |
npm install
test-store_artifacts: &test-store_artifacts
path: .screenshots/

test-configure-replicaset: &test-configure-replicaset
name: Configure Replica Set
command: |
mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})'
mongo --eval 'rs.status()'
test-docker-image: &test-docker-image
circleci/node:8.11-browsers

test: &test
<<: *defaults
environment: &test-environment
TEST_MODE: "true"
MONGO_URL: mongodb://localhost:27017/rocketchat


test-with-oplog: &test-with-oplog
<<: *test
environment:
<<: *test-environment
MONGO_OPLOG_URL: mongodb://localhost:27017/local

steps:
- attach_workspace: *attach_workspace
- checkout
- run: *test-install-dependencies
- run: *test-configure-replicaset
- run: *test-npm-install
- run: *test-run
- store_artifacts: *test-store_artifacts

test-without-oplog: &test-without-oplog
<<: *test
steps:
- attach_workspace: *attach_workspace
- checkout
- run: *test-install-dependencies
- run: *test-npm-install
- run: *test-run
- store_artifacts: *test-store_artifacts


version: 2
jobs:
build:
Expand Down Expand Up @@ -132,91 +200,60 @@ jobs:
- store_artifacts:
path: /tmp/build

test-with-oplog:
<<: *defaults

test-with-oplog-mongo-3-2:
<<: *test-with-oplog
docker:
- image: circleci/node:8.11-browsers
- image: mongo:4.0
- image: *test-docker-image
- image: mongo:3.2
command: [mongod, --noprealloc, --smallfiles, --replSet=rs0]

environment:
TEST_MODE: "true"
MONGO_URL: mongodb://localhost:27017/rocketchat
MONGO_OPLOG_URL: mongodb://localhost:27017/local

steps:
- attach_workspace:
at: /tmp

- checkout

- run:
name: Install dependencies
command: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb [ arch=amd64 ] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org-shell google-chrome-stable
- run:
name: Configure Replica Set
command: |
mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})'
mongo --eval 'rs.status()'
- run:
name: NPM install
command: |
npm install
- run:
name: Run Tests
command: |
for i in $(seq 1 5); do mongo rocketchat --eval 'db.dropDatabase()' && npm test && s=0 && break || s=$? && sleep 1; done; (exit $s)
- store_artifacts:
path: .screenshots/
test-with-oplog-mongo-3-4:
<<: *test-with-oplog
docker:
- image: *test-docker-image
- image: mongo:3.4
command: [mongod, --noprealloc, --smallfiles, --replSet=rs0]

test-without-oplog:
<<: *defaults
test-with-oplog-mongo-3-6:
<<: *test-with-oplog
docker:
- image: circleci/node:8.11-browsers
- image: circleci/mongo:4.0
- image: *test-docker-image
- image: mongo:3.6
command: [mongod, --noprealloc, --smallfiles, --replSet=rs0]

environment:
TEST_MODE: "true"
MONGO_URL: mongodb://localhost:27017/rocketchat
test-with-oplog-mongo-4-0:
<<: *test-with-oplog
docker:
- image: *test-docker-image
- image: mongo:4.0
command: [mongod, --noprealloc, --smallfiles, --replSet=rs0]

steps:
- attach_workspace:
at: /tmp

- checkout
test-without-oplog-mongo-3-2:
<<: *test-without-oplog
docker:
- image: *test-docker-image
- image: mongo:3.2

- run:
name: Install dependencies
command: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb [ arch=amd64 ] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org-shell google-chrome-stable
test-without-oplog-mongo-3-4:
<<: *test-without-oplog
docker:
- image: *test-docker-image
- image: mongo:3.4

- run:
name: NPM install
command: |
npm install
test-without-oplog-mongo-3-6:
<<: *test-without-oplog
docker:
- image: *test-docker-image
- image: mongo:3.6

- run:
name: Run Tests
command: |
for i in $(seq 1 5); do mongo rocketchat --eval 'db.dropDatabase()' && npm test && s=0 && break || s=$? && sleep 1; done; (exit $s)
test-without-oplog-mongo-4-0:
<<: *test-without-oplog
docker:
- image: *test-docker-image
- image: mongo:4.0

- store_artifacts:
path: .screenshots/

deploy:
<<: *defaults
Expand Down Expand Up @@ -378,22 +415,29 @@ workflows:
filters:
tags:
only: /^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$/
- test-with-oplog:
requires:
- build
filters:
tags:
only: /^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$/
- test-without-oplog:
- test-with-oplog-mongo-3-2: &test-mongo
requires:
- build
filters:
tags:
only: /^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$/
- test-with-oplog-mongo-3-4: *test-mongo
- test-with-oplog-mongo-3-6: *test-mongo
- test-with-oplog-mongo-4-0: *test-mongo
- test-without-oplog-mongo-3-2: *test-mongo
- test-without-oplog-mongo-3-4: *test-mongo
- test-without-oplog-mongo-3-6: *test-mongo
- test-without-oplog-mongo-4-0: *test-mongo
- deploy:
requires:
- test-with-oplog
- test-without-oplog
- test-with-oplog-mongo-3-2
- test-with-oplog-mongo-3-4
- test-with-oplog-mongo-3-6
- test-with-oplog-mongo-4-0
- test-without-oplog-mongo-3-2
- test-without-oplog-mongo-3-4
- test-without-oplog-mongo-3-6
- test-without-oplog-mongo-4-0
filters:
branches:
only: develop
Expand Down

0 comments on commit 5fb5d79

Please sign in to comment.