Skip to content

Commit

Permalink
put mysql in docker for ci
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Gautier <[email protected]>
  • Loading branch information
Arthur Gautier authored and baloo committed Nov 22, 2019
1 parent 7fc95e1 commit bde3413
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 127 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dist: trusty
language: python
services:
- docker
python:
- "2.7"
- "3.4"
Expand All @@ -21,8 +23,8 @@ cache:
- $HOME/bins
before_script:
- env | grep DB
- bash -c "if [ '$DB' = 'mysql57' ]; then sudo ./scripts/install_mysql57.sh; fi"
- bash -c "if [ '$DB' = 'mysql56' ]; then sudo ./scripts/install_mysql56.sh; fi"
- bash -c "if [ '$DB' = 'mysql57' ]; then sudo ./scripts/install_mysql.sh 5.7; fi"
- bash -c "if [ '$DB' = 'mysql56' ]; then sudo ./scripts/install_mysql.sh 5.6; fi"
script:
- "sudo $(which nosetests) pymysqlreplication.tests.test_abnormal:TestAbnormalBinLogStreamReader.test_no_trailing_rotate_event"
- "nosetests -e test_no_trailing_rotate_event"
Expand Down
2 changes: 0 additions & 2 deletions pymysqlreplication/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ def setUp(self):
"charset": "utf8",
"db": "pymysqlreplication_test"
}
if os.getenv("TRAVIS") is not None and db == "mysql56":
self.database["user"] = "travis"

self.conn_control = None
db = copy.copy(self.database)
Expand Down
79 changes: 79 additions & 0 deletions scripts/install_mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash

set -x

# Remove old mysql version
/etc/init.d/mysql stop || true
apt-get remove mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5
apt-get autoremove

VERSION=$1

docker pull percona:$VERSION

# Cleanup old mysql datas
rm -rf /var/ramfs/mysql/
rm -rf /var/ramfs/mysql-ctl/
mkdir /var/ramfs/mysql/
mkdir /var/ramfs/mysql-ctl/
chmod 777 /var/ramfs/mysql/
chmod 777 /var/ramfs/mysql-ctl/
rm -rf /var/run/mysqld/
mkdir /var/run/mysqld/
chmod 777 /var/run/mysqld/

OPTIONS=""
# Replication
OPTIONS="$OPTIONS --log_bin=mysql-bin"
OPTIONS="$OPTIONS --binlog-format=row"
# Gtid
OPTIONS="$OPTIONS --log_slave_updates"
OPTIONS="$OPTIONS --gtid_mode=ON"
OPTIONS="$OPTIONS --enforce-gtid-consistency=ON"

MASTER_OPTIONS="$OPTIONS --server-id=1"
MASTER_OPTIONS="$MASTER_OPTIONS --datadir=/var/ramfs/mysql/"
MASTER_OPTIONS="$MASTER_OPTIONS --socket=/var/run/mysqld/mysqld.sock"

docker run --publish 3306:3306 \
-d --name master \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes\
-v /var/ramfs/mysql/:/var/ramfs/mysql/\
percona:$VERSION\
$MASTER_OPTIONS
# -v /var/run/mysqld/:/var/run/mysqld/\

CTL_OPTIONS="$OPTIONS --server-id=2"
CTL_OPTIONS="$CTL_OPTIONS --socket=/var/run/mysqld/mysqld-ctl.sock"
CTL_OPTIONS="$CTL_OPTIONS --datadir=/var/ramfs/mysql-ctl/"
CTL_OPTIONS="$CTL_OPTIONS --pid-file=/var/lib/mysql/mysql-ctl.pid"

docker run --publish 3307:3306 \
-d --name ctl \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes\
-v /var/ramfs/mysql-ctl/:/var/ramfs/mysql-ctl/\
percona:$VERSION\
$CTL_OPTIONS
# -v /var/run/mysqld/:/var/run/mysqld/\

for i in $(seq 0 40); do
sleep 1;
mysql -u root --host=127.0.0.1 --port=3306 -e 'SELECT VERSION();'
if [ $? -eq 0 ]; then
break 2;
fi
done

for i in $(seq 0 40); do
sleep 1;
mysql -u root --host=127.0.0.1 --port=3307 -e 'SELECT VERSION();'
if [ $? -eq 0 ]; then
break 2;
fi
done

docker logs master
docker logs ctl

mysql -u root --host=127.0.0.1 --port=3306 -e 'CREATE DATABASE pymysqlreplication_test;'
mysql -u root --host=127.0.0.1 --port=3307 -e "CREATE DATABASE pymysqlreplication_test;"
61 changes: 0 additions & 61 deletions scripts/install_mysql56.sh

This file was deleted.

62 changes: 0 additions & 62 deletions scripts/install_mysql57.sh

This file was deleted.

0 comments on commit bde3413

Please sign in to comment.