Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ branches:
env:
global:
- CACHE_NAME=JOB1
- MONGODB_VERSION=3.4.16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talking about version pinning, I believe what we have now /mongodb-org/3.4 in repo with major.minor would be overall a more preferable approach.
I think that in mongodb context pinning patch version instead of giving a better control would, in fact, work against us.

- ENABLE_COVERAGE=$([ "${TRAVIS_PULL_REQUEST}" = "false" ] && echo "yes" || echo "no")
matrix:
include:
Expand All @@ -36,17 +37,16 @@ matrix:
addons:
apt:
sources:
- mongodb-upstart
- sourceline: 'deb [arch=amd64] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse'
key_url: 'https://www.mongodb.org/static/pgp/server-3.4.asc'
#- mongodb-upstart
# - sourceline: 'deb [arch=amd64] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse'
# key_url: 'https://www.mongodb.org/static/pgp/server-3.4.asc'
- sourceline: 'ppa:git-core/ppa'
packages:
- mongodb-org-server
- mongodb-org-shell
#- mongodb-org-server
#- mongodb-org-shell
- git

services:
- mongodb
- rabbitmq

cache:
Expand All @@ -68,10 +68,14 @@ install:
- if [ "${TASK}" = 'compilepy3 ci-py3-unit' ] || [ "${TASK}" = 'ci-py3-integration' ]; then pip install "tox==3.0.0"; else make requirements; fi
- if [ "${TASK}" = 'ci-unit' ] || [ "${TASK}" = 'ci-integration' ] && [ "${ENABLE_COVERAGE}" = 'yes' ]; then pip install codecov; fi
- if [ "${TASK}" = 'ci-unit' ] || [ "${TASK}" = 'ci-integration' ] || [ "${TASK}" = 'compilepy3 ci-py3-unit' ] || [ "${TASK}" = 'ci-py3-integration' ]; then sudo .circle/add-itest-user.sh; fi
# Note: We use ramdisk for better performance
- sudo -E ./scripts/travis/create-and-mount-ramdisk.sh
- ./scripts/travis/install-and-run-mongodb.sh

# Let's enable rabbitmqadmin
# See https://github.com/messagebus/lapine/wiki/Testing-on-Travis.
before_script:
Copy link
Member

@arm4b arm4b Jul 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference of editing existing mongo conf, this looks like a good hint:
http://georgeshank.com/how-to-enable-a-mongodb-replica-set-on-travis/

before_script:
  - echo "foo = bar" | sudo tee -a /etc/mongodb.conf
  - sudo service mongodb restart

which overall is more clean.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be fine with that, although we might also need to use or sed or similar if config option already exists, so it could get a bit messy.

- mongo --version
- git --version
- pip --version
- virtualenv --version
Expand Down
49 changes: 36 additions & 13 deletions scripts/travis/install-and-run-mongodb.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,56 @@
#!/usr/bin/env bash

# Script which installs versions of MongoDB specified using an environment variable

if [ ! "${MONGODB}" ]; then
echo "MONGODB environment variable not set"
if [ ! "${MONGODB_VERSION}" ]; then
echo "MONGODB_VERSION environment variable not set."
exit 2
fi

# Note: MongoDB 2.4 and 2.6 don't work with ramdisk since they don't work with
# small files and require at least 3 GB of space
if [ ${MONGODB} = '2.4.9' ] || [ ${MONGODB} = '2.6.12' ]; then
if [ "${MONGODB_VERSION}" = '2.4.9' ] || [ "${MONGODB_VERSION}" = '2.6.12' ]; then
DATA_DIR=/tmp/mongodbdata
else
DATA_DIR=/mnt/ramdisk/mongodb
fi

wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB}.tgz -O /tmp/mongodb.tgz
tar -xvf /tmp/mongodb.tgz
DATA_DIR=/tmp/mongodbdata
MONGODB_DIR=/tmp/mongodb

mkdir -p ${DATA_DIR}
echo "Starting MongoDB v${MONGODB}"
${PWD}/mongodb-linux-x86_64-${MONGODB}/bin/mongod --nojournal --journalCommitInterval 500 \
--syncdelay 0 --dbpath ${DATA_DIR} --bind_ip 127.0.0.1 &> /tmp/mongodb.log &
EXIT_CODE=$?
mkdir -p ${MONGODB_DIR}

DOWNLOAD_URL="http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB_VERSION}.tgz"

echo "Downloading MongoDB ${MONGODB_VERSION} from ${DOWNLOAD_URL}"
wget -q ${DOWNLOAD_URL} -O /tmp/mongodb.tgz
tar -xvf /tmp/mongodb.tgz -C ${MONGODB_DIR} --strip=1

echo "Symlinking mongo shell binary to /usr/local/bin"

# Symlink latest mongodb shell
sudo ln -sf ${MONGODB_DIR}/bin/mongo /usr/local/bin/mongo
sudo ln -sf ${MONGODB_DIR}/bin/mongo /usr/bin/mongo

echo "Starting MongoDB v${MONGODB_VERSION}"
# Note: We use --notablescan option to detected missing indexes early. When this
# option is enabled, queries which result in table scan (which usually means a
# missing index or a bad query) are not allowed and result in a failed test.
#--wiredTigerStatisticsLogDelaySecs 0 --noIndexBuildRetry --noscripting --notablescan \
${MONGODB_DIR}/bin/mongod --nojournal --journalCommitInterval 500 --syncdelay 0 \
--wiredTigerStatisticsLogDelaySecs 0 --noIndexBuildRetry --noscripting \
--dbpath ${DATA_DIR} --bind_ip 127.0.0.1 &> /tmp/mongodb.log &
MONGODB_PID=$!

# Give process some time to start up
sleep 5

if [ ${EXIT_CODE} -ne 0 ]; then
if ps -p ${MONGODB_PID} > /dev/null; then
echo "MongoDB successfuly started"
tail -30 /tmp/mongodb.log
exit 0
else
echo "Failed to start MongoDB"
tail -30 /tmp/mongodb.log
exit 1
fi

tail -30 /tmp/mongodb.log
5 changes: 3 additions & 2 deletions st2tests/st2tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ def _establish_connection_and_re_create_db(cls):
db_ensure_indexes()

@classmethod
def _drop_db(cls):
cls._drop_collections()
def _drop_db(cls): # NOTE: In older MongoDB versions you needed to drop all the collections prior to dropping
# the database - that's not needed anymore with the wiredtiger engine
# cls._drop_collections()

if cls.db_connection is not None:
cls.db_connection.drop_database(cfg.CONF.database.db_name)
Expand Down