File tree Expand file tree Collapse file tree 5 files changed +91
-6
lines changed Expand file tree Collapse file tree 5 files changed +91
-6
lines changed Original file line number Diff line number Diff line change 2828 run : |
2929 docker compose create
3030 docker compose start
31- # Wait for the services to accept connections,
32- # TODO: do that smarter, poll connection attempt until it succeeds
33- sleep 30
31+ echo "wait mysql server"
32+
33+ while :
34+ do
35+ if mysql -h 127.0.0.1 --user=root --execute "SELECT version();" 2>&1 >/dev/null && mysql -h 127.0.0.1 --port=3307 --user=root --execute "SELECT version();" 2>&1 >/dev/null; then
36+ break
37+ fi
38+ sleep 1
39+ done
40+
41+ echo "run pytest"
3442
3543 - name : Install dependencies
3644 run : |
Original file line number Diff line number Diff line change 1+ version : ' 3.2'
2+ services :
3+ percona-5.7 :
4+ platform : linux/amd64
5+ image : percona:5.7
6+ environment :
7+ MYSQL_ALLOW_EMPTY_PASSWORD : true
8+ MYSQL_DATABASE : pymysqlreplication_test
9+ ports :
10+ - 3306:3306
11+ command : mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates
12+ restart : always
13+ networks :
14+ - default
15+
16+ percona-5.7-ctl :
17+ image : percona:5.7
18+ environment :
19+ MYSQL_ALLOW_EMPTY_PASSWORD : true
20+ MYSQL_DATABASE : pymysqlreplication_test
21+ ports :
22+ - 3307:3307
23+ command : mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates -P 3307
24+
25+ pymysqlreplication :
26+ build :
27+ context : .
28+ dockerfile : test.Dockerfile
29+ args :
30+ BASE_IMAGE : python:3.11-alpine
31+ MYSQL_5_7 : percona-5.7
32+ MYSQL_5_7_CTL : percona-5.7-ctl
33+
34+ command :
35+ - /bin/sh
36+ - -ce
37+ - |
38+ echo "wait mysql server"
39+
40+ while :
41+ do
42+ if mysql -h percona-5.7 --user=root --execute "USE pymysqlreplication_test;" 2>&1 >/dev/null && mysql -h percona-5.7-ctl --port=3307 --user=root --execute "USE pymysqlreplication_test;" 2>&1 >/dev/null; then
43+ break
44+ fi
45+ sleep 1
46+ done
47+
48+ echo "run pytest"
49+ pytest -k "not test_no_trailing_rotate_event and not test_end_log_pos"
50+
51+ working_dir : /pymysqlreplication
52+ networks :
53+ - default
54+ depends_on :
55+ - percona-5.7
56+ - percona-5.7-ctl
57+
58+ networks :
59+ default : {}
Original file line number Diff line number Diff line change @@ -19,11 +19,9 @@ def ignoredEvents(self):
1919 return []
2020
2121 def setUp (self ):
22-
23- db = os .environ .get ('DB' )
2422 # default
2523 self .database = {
26- "host" : "localhost" ,
24+ "host" : os . environ . get ( "MYSQL_5_7" ) or "localhost" ,
2725 "user" : "root" ,
2826 "passwd" : "" ,
2927 "port" : 3306 ,
Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
2+ import os
3+
24import pymysql
35import copy
46import time
@@ -768,6 +770,8 @@ def setUp(self):
768770 ctl_db = copy .copy (self .database )
769771 ctl_db ["db" ] = None
770772 ctl_db ["port" ] = 3307
773+ if os .environ .get ("MYSQL_5_7_CTL" ) is not None :
774+ ctl_db ["host" ] = os .environ .get ("MYSQL_5_7_CTL" )
771775 self .ctl_conn_control = pymysql .connect (** ctl_db )
772776 self .ctl_conn_control .cursor ().execute ("DROP DATABASE IF EXISTS pymysqlreplication_test" )
773777 self .ctl_conn_control .cursor ().execute ("CREATE DATABASE pymysqlreplication_test" )
Original file line number Diff line number Diff line change 1+ ARG BASE_IMAGE=${BASE_IMAGE:-python:3.11-alpine}
2+ FROM ${BASE_IMAGE}
3+
4+ COPY pymysqlreplication pymysqlreplication
5+ COPY README.md README.md
6+ COPY setup.py setup.py
7+ RUN apk add bind-tools
8+ RUN apk add mysql-client
9+ RUN pip install .
10+ RUN pip install pytest
11+
12+ ARG MYSQL_5_7
13+ ENV MYSQL_5_7 ${MYSQL_5_7}
14+
15+ ARG MYSQL_5_7_CTL
16+ ENV MYSQL_5_7_CTL ${MYSQL_5_7_CTL}
You can’t perform that action at this time.
0 commit comments