Skip to content

Commit 4502796

Browse files
authored
Use docker for CI replica tests, deprecate dbdeployer (#1529)
* use docker for ci tests * set charset server * remove unusued cibuild-gh-ost-replica-tests * add doc for how to run localtests
1 parent d651ae9 commit 4502796

File tree

5 files changed

+28
-148
lines changed

5 files changed

+28
-148
lines changed

Diff for: .github/workflows/replica-tests.yml

+1-24
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,12 @@ name: migration tests
33
on: [pull_request]
44

55
jobs:
6-
build:
7-
8-
runs-on: ubuntu-20.04
9-
strategy:
10-
fail-fast: false
11-
matrix:
12-
version: [mysql-5.7.25,mysql-8.0.16,PerconaServer-8.0.21]
13-
14-
steps:
15-
- uses: actions/checkout@v4
16-
17-
- name: Set up Go
18-
uses: actions/setup-go@v5
19-
with:
20-
go-version-file: go.mod
21-
22-
- name: migration tests
23-
env:
24-
TEST_MYSQL_VERSION: ${{ matrix.version }}
25-
run: script/cibuild-gh-ost-replica-tests
26-
276
docker-tests:
287
runs-on: ubuntu-22.04
298
strategy:
309
fail-fast: false
3110
matrix:
32-
image: ['mysql:8.4.3']
11+
image: ['mysql/mysql-server:5.7.41','mysql:8.0.41','mysql:8.4.3','percona/percona-server:8.0.41-32']
3312
env:
3413
TEST_MYSQL_IMAGE: ${{ matrix.image }}
3514

@@ -45,5 +24,3 @@ jobs:
4524
- name: Teardown environment
4625
if: always()
4726
run: script/docker-gh-ost-replica-tests down
48-
49-

Diff for: doc/local-tests.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`gh-ost` is continuously tested in production via `--test-on-replica alter='engine=innodb'`. These tests check the GitHub workload and usage, but not necessarily the general case.
44

5-
Local tests are an additional layer of tests. They will eventually be part of continuous integration tests.
5+
Local tests are an additional layer of tests used for continuous integration tests and local development.
66

77
Local tests test explicit use cases, such as column renames, mix of time zones, special types and alters. Traits of a single test:
88

@@ -19,4 +19,18 @@ Tests are found under [localtests](https://github.com/github/gh-ost/tree/master/
1919

2020
New data-integrity, synchronization issues or otherwise concerns are expected to be tested by new test cases.
2121

22-
While this is merged work is still ongoing.
22+
## Run with docker compose
23+
24+
Local tests can be run locally with docker compose using the helper script [script/docker-gh-ost-replica-tests](https://github.com/github/gh-ost/tree/master/script/docker-gh-ost-replica-tests).
25+
26+
Example usage:
27+
```shell
28+
# create primary-replica containers with specified mysql image
29+
TEST_MYSQL_IMAGE="mysql-server:8.0.16" ./script/docker-gh-ost-replica-tests up
30+
31+
# run all tests
32+
./script/docker-gh-ost-replica-tests run
33+
34+
# cleanup containers
35+
./script/docker-gh-ost-replica-tests down
36+
```

Diff for: localtests/docker-compose.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@ services:
22
mysql-primary:
33
image: $TEST_MYSQL_IMAGE
44
container_name: mysql-primary
5-
command: --server-id=1 --log-bin=mysql-bin --binlog-format=row --gtid-mode=ON --enforce-gtid-consistency=ON $MYSQL_NATIVE_PASSWORD_FLAG
5+
command: --server-id=1 --log-bin=mysql-bin --binlog-format=row --gtid-mode=ON --enforce-gtid-consistency=ON --character-set-server=utf8mb4 $MYSQL_NATIVE_PASSWORD_FLAG
66
environment:
77
MYSQL_ROOT_PASSWORD: opensesame
88
MYSQL_ROOT_HOST: '%'
99
MYSQL_DATABASE: test
1010
MYSQL_TCP_PORT: 3307
11+
INIT_ROCKSDB: 1 # for percona-server
1112
ports:
1213
- '3307:3307'
1314
expose:
1415
- '3307'
1516
mysql-replica:
1617
image: $TEST_MYSQL_IMAGE
1718
container_name: mysql-replica
18-
command: --server-id=2 --log-bin=mysql-bin --binlog-format=row --gtid-mode=ON --enforce-gtid-consistency=ON --log-slave-updates=ON $MYSQL_NATIVE_PASSWORD_FLAG
19+
command: --server-id=2 --log-bin=mysql-bin --binlog-format=row --gtid-mode=ON --enforce-gtid-consistency=ON --log-slave-updates=ON --character-set-server=utf8mb4 $MYSQL_NATIVE_PASSWORD_FLAG
1920
environment:
2021
MYSQL_ROOT_PASSWORD: opensesame
2122
MYSQL_ROOT_HOST: '%'
2223
MYSQL_DATABASE: test
2324
MYSQL_TCP_PORT: 3308
25+
INIT_ROCKSDB: 1 # for percona-server
2426
ports:
2527
- '3308:3308'
2628
expose:

Diff for: script/cibuild-gh-ost-replica-tests

-111
This file was deleted.

Diff for: script/docker-gh-ost-replica-tests

+7-9
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ fi
1919
poll_mysql() {
2020
CTR=0
2121
cmd="gh-ost-test-mysql-$1"
22-
while ! $cmd -e "select 1;" > /dev/null 2>&1
23-
do
22+
while ! $cmd -e "select 1;" >/dev/null 2>&1; do
2423
sleep 1
2524
CTR=$((CTR + 1))
2625
if [ $CTR -gt 30 ]; then
@@ -34,23 +33,22 @@ poll_mysql() {
3433

3534
mysql-source() {
3635
if [[ $TEST_MYSQL_IMAGE =~ "mysql:8.4" ]]; then
37-
gh-ost-test-mysql-master --ssl-mode=required "$@";
36+
gh-ost-test-mysql-master --ssl-mode=required "$@"
3837
else
39-
gh-ost-test-mysql-master $@;
38+
gh-ost-test-mysql-master "$@"
4039
fi
4140
}
4241

4342
mysql-replica() {
4443
if [[ $TEST_MYSQL_IMAGE =~ "mysql:8.4" ]]; then
45-
gh-ost-test-mysql-replica --ssl-mode=required "$@";
44+
gh-ost-test-mysql-replica --ssl-mode=required "$@"
4645
else
47-
gh-ost-test-mysql-replica $@;
46+
gh-ost-test-mysql-replica "$@"
4847
fi
4948
}
5049

51-
5250
setup() {
53-
[ -z "$TEST_MYSQL_IMAGE" ] && TEST_MYSQL_IMAGE="mysql:8.0.39"
51+
[ -z "$TEST_MYSQL_IMAGE" ] && TEST_MYSQL_IMAGE="mysql:8.0.41"
5452

5553
echo "Starting MySQL $TEST_MYSQL_IMAGE containers..."
5654
compose_file="$GH_OST_ROOT/localtests/docker-compose.yml"
@@ -60,7 +58,7 @@ setup() {
6058
MYSQL_PASSWORD_HASHING_ALGORITHM="caching_sha2_password"
6159
MYSQL_SHA2_RSA_KEYS_FLAG="--caching-sha2-password-auto-generate-rsa-keys=ON"
6260
fi
63-
(TEST_MYSQL_IMAGE="$TEST_MYSQL_IMAGE" MYSQL_SHA2_RSA_KEYS_FLAG="$MYSQL_SHA2_RSA_KEYS_FLAG" envsubst < "$compose_file") > "$compose_file.tmp"
61+
(TEST_MYSQL_IMAGE="$TEST_MYSQL_IMAGE" MYSQL_SHA2_RSA_KEYS_FLAG="$MYSQL_SHA2_RSA_KEYS_FLAG" envsubst <"$compose_file") >"$compose_file.tmp"
6462
docker compose -f "$compose_file.tmp" up -d --wait
6563

6664
echo "Waiting for MySQL..."

0 commit comments

Comments
 (0)