gh-ost/script/cibuild-gh-ost-replica-tests

112 lines
4.1 KiB
Plaintext
Raw Normal View History

2018-02-11 11:33:40 +00:00
#!/bin/bash
set -e
2018-02-11 12:33:39 +00:00
whoami
2021-05-07 22:44:28 +00:00
fetch_ci_env() {
# Clone gh-ost-ci-env
# Only clone if not already running locally at latest commit
2021-05-07 22:45:59 +00:00
remote_commit=$(git ls-remote https://github.com/github/gh-ost-ci-env.git HEAD | cut -f1)
2021-05-07 22:44:28 +00:00
local_commit="unknown"
[ -d "gh-ost-ci-env" ] && local_commit=$(cd gh-ost-ci-env && git log --format="%H" -n 1)
echo "remote commit is: $remote_commit"
echo "local commit is: $local_commit"
if [ "$remote_commit" != "$local_commit" ] ; then
rm -rf ./gh-ost-ci-env
git clone https://github.com/github/gh-ost-ci-env.git
fi
}
2018-02-27 11:39:19 +00:00
2021-05-07 22:44:28 +00:00
test_dbdeployer() {
gh-ost-ci-env/bin/linux/dbdeployer --version
}
2018-02-11 12:05:05 +00:00
2018-02-26 12:43:11 +00:00
test_mysql_version() {
local mysql_version
mysql_version="$1"
2018-02-11 12:15:38 +00:00
2018-02-26 13:22:57 +00:00
echo "##### Testing $mysql_version"
echo "### Setting up sandbox for $mysql_version"
2018-02-26 12:48:48 +00:00
2018-02-26 12:43:11 +00:00
find sandboxes -name "stop_all" | bash
2018-02-11 12:05:05 +00:00
2018-02-26 12:43:11 +00:00
mkdir -p sandbox/binary
rm -rf sandbox/binary/*
2022-11-25 17:38:12 +00:00
local mysql_server=${mysql_version%-*}
if echo "$mysql_server" | egrep -i "percona" ; then
tarball_name=Percona-Server-${mysql_version#*-}-12-Linux.x86_64.glibc2.12-minimal.tar.gz
rm -f gh-ost-ci-env/mysql-tarballs/${tarball_name}
ln -s "$mysql_version".tar.xz gh-ost-ci-env/mysql-tarballs/${tarball_name}
gh-ost-ci-env/bin/linux/dbdeployer unpack gh-ost-ci-env/mysql-tarballs/${tarball_name} --sandbox-binary ${PWD}/sandbox/binary
rm -f gh-ost-ci-env/mysql-tarballs/${tarball_name}
else
gh-ost-ci-env/bin/linux/dbdeployer unpack gh-ost-ci-env/mysql-tarballs/"$mysql_version".tar.xz --sandbox-binary ${PWD}/sandbox/binary
fi
2018-02-26 12:43:11 +00:00
mkdir -p sandboxes
rm -rf sandboxes/*
2018-02-26 13:41:21 +00:00
2021-05-07 22:45:59 +00:00
local mysql_version_num=${mysql_version#*-}
if echo "$mysql_version_num" | egrep "5[.]5[.]" ; then
2018-02-26 13:41:21 +00:00
gtid=""
else
gtid="--gtid"
fi
2021-05-07 22:45:59 +00:00
gh-ost-ci-env/bin/linux/dbdeployer deploy replication "$mysql_version_num" --nodes 2 --sandbox-binary ${PWD}/sandbox/binary --sandbox-home ${PWD}/sandboxes ${gtid} --my-cnf-options log_slave_updates --my-cnf-options log_bin --my-cnf-options binlog_format=ROW --sandbox-directory rsandbox
2018-02-11 11:46:27 +00:00
2018-02-26 12:43:11 +00:00
sed '/sandboxes/d' -i gh-ost-ci-env/bin/gh-ost-test-mysql-master
2018-02-26 13:11:48 +00:00
echo 'sandboxes/rsandbox/m "$@"' >> gh-ost-ci-env/bin/gh-ost-test-mysql-master
2018-02-11 11:33:40 +00:00
2018-02-26 12:43:11 +00:00
sed '/sandboxes/d' -i gh-ost-ci-env/bin/gh-ost-test-mysql-replica
2018-02-26 13:11:48 +00:00
echo 'sandboxes/rsandbox/s1 "$@"' >> gh-ost-ci-env/bin/gh-ost-test-mysql-replica
2018-02-11 12:21:38 +00:00
2018-02-26 12:43:11 +00:00
export PATH="${PWD}/gh-ost-ci-env/bin/:${PATH}"
2018-02-11 12:21:38 +00:00
2020-02-05 08:07:14 +00:00
gh-ost-test-mysql-master -uroot -e "create user 'gh-ost'@'%' identified by 'gh-ost'"
gh-ost-test-mysql-master -uroot -e "grant all on *.* to 'gh-ost'@'%'"
2018-02-11 12:14:43 +00:00
2022-11-25 09:18:32 +00:00
if echo "$mysql_server" | egrep -i "percona" ; then
echo "### Preparing for rocksdb in PerconaServer"
2022-11-25 17:38:12 +00:00
gh-ost-test-mysql-master -uroot -e 'INSTALL PLUGIN ROCKSDB SONAME "ha_rocksdb.so"'
gh-ost-test-mysql-master -uroot -e 'set global default_storage_engine="ROCKSDB"'
gh-ost-test-mysql-master -uroot -e 'set global transaction_isolation="READ-COMMITTED"'
gh-ost-test-mysql-replica -uroot -e 'INSTALL PLUGIN ROCKSDB SONAME "ha_rocksdb.so"'
gh-ost-test-mysql-replica -uroot -e 'set global default_storage_engine="ROCKSDB"'
gh-ost-test-mysql-replica -uroot -e 'set global transaction_isolation="READ-COMMITTED"'
echo "### Running gh-ost tests for $mysql_version"
./localtests/test.sh -b bin/gh-ost -s rocksdb
else
echo "### Running gh-ost tests for $mysql_version"
./localtests/test.sh -b bin/gh-ost -s innodb
2022-11-25 09:18:32 +00:00
fi
2018-02-26 12:43:11 +00:00
find sandboxes -name "stop_all" | bash
}
2021-05-07 22:44:28 +00:00
main() {
fetch_ci_env
test_dbdeployer
echo "Building..."
. script/build
# TEST_MYSQL_VERSION is set by the replica-tests CI job
if [ -z "$TEST_MYSQL_VERSION" ]; then
# Test all versions:
find gh-ost-ci-env/mysql-tarballs/ -name "*.tar.xz" | while read f ; do basename $f ".tar.xz" ; done | sort -r | while read mysql_version ; do
echo "found MySQL version: $mysql_version"
done
find gh-ost-ci-env/mysql-tarballs/ -name "*.tar.xz" | while read f ; do basename $f ".tar.xz" ; done | sort -r | while read mysql_version ; do
test_mysql_version "$mysql_version"
done
else
echo "found MySQL version: $TEST_MYSQL_VERSION"
test_mysql_version "$TEST_MYSQL_VERSION"
fi
}
main