Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 387ab3e

Browse files
committedOct 3, 2023
refactor: split tests by db
1 parent 76b5a3f commit 387ab3e

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed
 

‎.github/workflows/pytest.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: PyTest
22
on: [push, pull_request]
3-
3+
env:
4+
PYTEST_SKIP_OPTION: "not test_no_trailing_rotate_event and not test_end_log_pos and not test_query_event_latin1"
45
jobs:
56
test:
67
strategy:
@@ -29,31 +30,34 @@ jobs:
2930
docker compose create
3031
docker compose start
3132
echo "wait mysql server"
32-
33+
3334
while :
3435
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+
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
3637
break
3738
fi
3839
sleep 1
3940
done
40-
41+
4142
echo "run pytest"
4243
4344
- name: Install dependencies
4445
run: |
4546
pip install .
4647
pip install pytest
4748
48-
- name: Run test suite
49+
- name: Run tests for mysql-5
4950
working-directory: pymysqlreplication/tests
50-
run: |
51-
dbms_versions=("mysql-5" "mysql-5-ctl" "mysql-8")
52-
for version in "${dbms_versions[@]}"; do
53-
pytest -k "not test_no_trailing_rotate_event and not test_end_log_pos and not test_query_event_latin1" --dbms=$version
54-
done
51+
run: pytest -k "$PYTEST_SKIP_OPTION" --db=mysql-5
5552

56-
- name: Run tests for MariaDB
53+
- name: Run tests for mysql-5-ctl
5754
working-directory: pymysqlreplication/tests
58-
run: |
59-
pytest -m mariadb -k "not test_no_trailing_rotate_event and not test_end_log_pos and not test_query_event_latin1" --dbms=mariadb-10
55+
run: pytest -k "$PYTEST_SKIP_OPTION" --db=mysql-5-ctl
56+
57+
- name: Run tests for mysql-8
58+
working-directory: pymysqlreplication/tests
59+
run: pytest -k "$PYTEST_SKIP_OPTION" --db=mysql-8
60+
61+
- name: Run tests for mariadb-10
62+
working-directory: pymysqlreplication/tests
63+
run: pytest -k "$PYTEST_SKIP_OPTION" -m mariadb --db=mariadb-10

‎pymysqlreplication/tests/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def ignoredEvents(self):
2525
return []
2626

2727
@pytest.fixture(autouse=True)
28-
def setUpDBMS(self, get_dbms):
28+
def setUpDatabase(self, get_db):
2929
databases = get_databases()
3030
# For local testing, set the get_dbms parameter to one of the following values: 'mysql-5', 'mysql-8', mariadb-10'.
3131
# This value should correspond to the desired database configuration specified in the 'config.json' file.
32-
self.database = databases[get_dbms]
32+
self.database = databases[get_db]
3333
"""
3434
self.database = {
3535
"host": os.environ.get("MYSQL_5_7") or "localhost",

‎pymysqlreplication/tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33

44
def pytest_addoption(parser):
5-
parser.addoption("--dbms", action="store", default="mysql-5")
5+
parser.addoption("--db", action="store", default="mysql-5")
66

77

88
@pytest.fixture
9-
def get_dbms(request):
10-
return request.config.getoption("--dbms")
9+
def get_db(request):
10+
return request.config.getoption("--db")

0 commit comments

Comments
 (0)
Please sign in to comment.