File tree 5 files changed +91
-6
lines changed
5 files changed +91
-6
lines changed Original file line number Diff line number Diff line change 28
28
run : |
29
29
docker compose create
30
30
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"
34
42
35
43
- name : Install dependencies
36
44
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):
19
19
return []
20
20
21
21
def setUp (self ):
22
-
23
- db = os .environ .get ('DB' )
24
22
# default
25
23
self .database = {
26
- "host" : "localhost" ,
24
+ "host" : os . environ . get ( "MYSQL_5_7" ) or "localhost" ,
27
25
"user" : "root" ,
28
26
"passwd" : "" ,
29
27
"port" : 3306 ,
Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
+ import os
3
+
2
4
import pymysql
3
5
import copy
4
6
import time
@@ -768,6 +770,8 @@ def setUp(self):
768
770
ctl_db = copy .copy (self .database )
769
771
ctl_db ["db" ] = None
770
772
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" )
771
775
self .ctl_conn_control = pymysql .connect (** ctl_db )
772
776
self .ctl_conn_control .cursor ().execute ("DROP DATABASE IF EXISTS pymysqlreplication_test" )
773
777
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