Skip to content

Commit

Permalink
[ci] Use in memory database in CI
Browse files Browse the repository at this point in the history
In Travis we used a tmpfs volume before.
Using tmpfs volume seems not to be possible in CircleCI
as not all native docker / docker-compose commands are supported.
The official CircleCI database images mount as well /dev/shm
to make use of an in memory database.

Changing Travis is mostly done to maintain the same setup in
CircleCI and Travis.

We also need to call the command directly in the config.yml
and the database container does not have a git checkout,
therefore calling ./contrib/start_test_db is not possible.

See for the official CircleCI images:
https://hub.docker.com/r/circleci/mysql/tags/
  • Loading branch information
ChrisBr committed Jun 26, 2018
1 parent 1aea209 commit 4cf6278
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Expand Up @@ -10,7 +10,8 @@ aliases:
EAGER_LOAD: 1
<<: *cc_test_reporter_id
- image: registry.opensuse.org/obs/server/unstable/container/leap/42.3/images/openbuildservice/mariadb:latest
command: /usr/lib/mysql/mysql-systemd-helper start
command: |
/bin/bash -c 'echo -e "[mysqld]\ndatadir = /dev/shm" > /etc/my.cnf.d/obs.cnf && cp -a /var/lib/mysql/* /dev/shm && /usr/lib/mysql/mysql-systemd-helper start'
name: db
- image: registry.opensuse.org/obs/server/unstable/container/leap/42.3/images/openbuildservice/memcached:latest
name: cache
Expand All @@ -21,7 +22,8 @@ aliases:
NOKOGIRI_USE_SYSTEM_LIBRARIES: 1
<<: *cc_test_reporter_id
- image: registry.opensuse.org/obs/server/unstable/container/leap/42.3/images/openbuildservice/mariadb:latest
command: /usr/lib/mysql/mysql-systemd-helper start
command: |
/bin/bash -c 'echo -e "[mysqld]\ndatadir = /dev/shm" > /etc/my.cnf.d/obs.cnf && cp -a /var/lib/mysql/* /dev/shm && /usr/lib/mysql/mysql-systemd-helper start'
name: db
- &restore_bundle_cache
keys:
Expand Down
6 changes: 3 additions & 3 deletions contrib/start_test_db
@@ -1,8 +1,8 @@
#!/bin/bash
# Copy our data dir to the tmpfs mount
cp -a /var/lib/mysql/* /var/lib/mysql_tmpfs
cp -a /var/lib/mysql/* /dev/shm
# Remove all our databases
rm -rf /var/lib/mysql_tmpfs/api*
rm -rf /dev/shm/api*
# Configure the new datadir
echo -e "[mysqld]\ndatadir = /var/lib/mysql_tmpfs" > /etc/my.cnf.d/obs.cnf
echo -e "[mysqld]\ndatadir = /dev/shm" > /etc/my.cnf.d/obs.cnf
/usr/lib/mysql/mysql-systemd-helper start
7 changes: 1 addition & 6 deletions docker-compose.ci.yml
Expand Up @@ -21,17 +21,12 @@ services:
db:
image: registry.opensuse.org/obs/server/unstable/container/sle12/sp3/images/openbuildservice/mariadb:latest
volumes:
- mysql_vol:/var/lib/mysql_tmpfs/
- .:/obs
shm_size: 512MB
command: /obs/contrib/start_test_db
backend:
image: registry.opensuse.org/obs/server/unstable/container/sle12/sp3/images/openbuildservice/backend:latest
volumes:
- .:/obs
working_dir: /obs
command: make -C src/backend test
volumes:
mysql_vol:
driver_opts:
type: tmpfs
device: tmpfs

0 comments on commit 4cf6278

Please sign in to comment.