Skip to content

Commit 81a7448

Browse files
authored
Merge pull request #212 from macbre/test-mysql-on-custom-port
CI | run database on a custom port
2 parents 67f4775 + 7e933db commit 81a7448

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

.github/workflows/python.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
MYSQL_ALLOW_EMPTY_PASSWORD: yes
3333
MYSQL_DATABASE: index_digest
3434
ports:
35-
- "3306:3306"
35+
- "53306:3306"
3636
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
3737

3838
steps:
@@ -57,18 +57,20 @@ jobs:
5757
${{ runner.os }}-pip-
5858
5959
- name: Install dependencies
60-
run: make install
60+
run: |
61+
pip install wheel
62+
make install
6163
6264
- name: Linter
6365
run: make lint
6466

6567
- name: Set up the database
6668
run: |
6769
docker ps
68-
mysql --protocol=tcp -u root -v < setup.sql
70+
mysql --protocol=tcp --port=53306 -u root --password="" -v < setup.sql
6971
# import the test schema files
7072
"./sql/populate.sh"
71-
mysql --protocol=tcp -uindex_digest -pqwerty index_digest -v -e '\s; SHOW TABLES; SHOW DATABASES;'
73+
mysql --protocol=tcp --port=53306 -uindex_digest -pqwerty index_digest -v -e '\s; SHOW TABLES; SHOW DATABASES;'
7274
7375
- name: Tests
7476
run: make test

.github/workflows/tests.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
MYSQL_ALLOW_EMPTY_PASSWORD: yes
3838
MYSQL_DATABASE: index_digest
3939
ports:
40-
- "3306:3306"
40+
- "53306:3306"
4141
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
4242

4343
steps:
@@ -62,18 +62,20 @@ jobs:
6262
${{ runner.os }}-pip-
6363
6464
- name: Install dependencies
65-
run: make install
65+
run: |
66+
pip install wheel
67+
make install
6668
6769
- name: Linter
6870
run: make lint
6971

7072
- name: Set up the database
7173
run: |
7274
docker ps
73-
mysql --protocol=tcp -u root -v < setup.sql
75+
mysql --protocol=tcp --port=53306 -u root --password="" -v < setup.sql
7476
# import the test schema files
7577
"./sql/populate.sh"
76-
mysql --protocol=tcp -uindex_digest -pqwerty index_digest -v -e '\s; SHOW TABLES; SHOW DATABASES;'
78+
mysql --protocol=tcp --port=53306 -uindex_digest -pqwerty index_digest -v -e '\s; SHOW TABLES; SHOW DATABASES;'
7779
7880
- name: Tests
7981
run: make test

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ make install
4747
We assume database is running locally on port 3306. You can use the following to test your changes locally before pushing them (this one uses MySQL 8.0.20):
4848

4949
```
50-
docker run -p 3306:3306 --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -e "MYSQL_DATABASE=index_digest" mysql:8.0.20
50+
docker run --rm -p 53306:3306 --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -e "MYSQL_DATABASE=index_digest" --name=index_digest_mysql mysql:8.0.22 "--default-authentication-plugin=mysql_native_password"
5151
```
5252

5353
Wait until the server is up and running.
5454

5555
```
56-
mysql --protocol=tcp -u root -v < setup.sql
56+
mysql --protocol=tcp --port=53306 -u root --password="" -v < setup.sql
5757
./sql/populate.sh
58-
mysql --protocol=tcp -uindex_digest -pqwerty index_digest -v -e '\s; SHOW TABLES; SHOW DATABASES;'
58+
mysql --protocol=tcp --port=53306 -uindex_digest -pqwerty index_digest -v -e '\s; SHOW TABLES; SHOW DATABASES;'
5959
6060
make test
6161
```

indexdigest/test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def read_queries_from_log(log_file):
1818

1919

2020
class DatabaseTestMixin(object):
21-
DSN = 'mysql://index_digest:qwerty@127.0.0.1/index_digest'
21+
DSN = 'mysql://index_digest:qwerty@127.0.0.1:53306/index_digest'
2222
DBNAME = 'index_digest'
2323

2424
@property

sql/populate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ FILES=`ls sql/*.sql`
55
for FILE in $FILES
66
do
77
echo -n "* Importing ${FILE} ... "
8-
cat $FILE | mysql --protocol=tcp -uindex_digest -pqwerty index_digest 2>&1 | grep -v "Using a password"
8+
cat $FILE | mysql --protocol=tcp --port=53306 -uindex_digest -pqwerty index_digest 2>&1 | grep -v "Using a password"
99
echo "done"
1010
done

0 commit comments

Comments
 (0)