Skip to content

Adding localtests via gh-ost-ci-env #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e346ecf
Adding localtests via gh-ost-ci-env
Feb 11, 2018
1828507
full local tests
Feb 11, 2018
64b4cd6
relaxed idempotent commands
Feb 11, 2018
511ee3f
script cleanup
Feb 11, 2018
4ebefea
fixed sandboxes installation path
Feb 11, 2018
dba1490
relaxed idempotent commands
Feb 11, 2018
4515e91
tests more verbose
Feb 11, 2018
c9cf4cf
more cleanup
Feb 11, 2018
9e95967
more cleanup
Feb 11, 2018
27b8413
activating sandboxes
Feb 11, 2018
dbda059
stopping sandboxes on startup
Feb 11, 2018
0d8c426
Adding grants
Feb 11, 2018
674c582
whoami
Feb 11, 2018
fa120b1
stop all
Feb 11, 2018
9b0efd0
delegating to 127.0.0.1
Feb 11, 2018
abb1be8
adding log-slave-updates
Feb 11, 2018
3d59f2f
/tmp path
Feb 11, 2018
06b7b06
gtid based replication
Feb 11, 2018
482a521
outputting test log file on error
Feb 12, 2018
a2a06ad
script/localtests is a separate test
Feb 20, 2018
34a55f1
script/localtests is excutable
Feb 20, 2018
222c42a
Merge branch 'master' into gh-ost-ci-env
Feb 26, 2018
540001b
temporarily removing localtests from travis
Feb 26, 2018
00a4d1f
prebuilt binary for localtests
Feb 26, 2018
8e3694b
testing multiple versions
Feb 26, 2018
29b4f93
fixed basename
Feb 26, 2018
40b53b1
extracting build
Feb 26, 2018
0a32d82
normalizinf sandbox-diectory
Feb 26, 2018
df9dd49
support for ignored versions
Feb 26, 2018
8f9f6c1
more verbose
Feb 26, 2018
9cfbfbf
disable gtid for 5.5
Feb 26, 2018
a9ead9e
5.5 excluded tests
Feb 26, 2018
2d56df3
5.5 excluded tests
Feb 26, 2018
242ee08
5.5 excluded tests
Feb 26, 2018
ac7765e
5.5 excluded tests
Feb 26, 2018
9061d4f
5.5 excluded tests
Feb 26, 2018
fa96757
5.5 excluded tests
Feb 26, 2018
49b3917
skipping wording
Feb 26, 2018
07a4a69
quiet grep
Feb 26, 2018
ad87b72
sort order
Feb 26, 2018
e2f6f4b
Merge branch 'master' into gh-ost-ci-env
Feb 27, 2018
efe5641
directory reset
Feb 27, 2018
5480646
adapting to dbdeployer 0.2.0
Feb 27, 2018
813f99f
clong gh-ost-ci-env only if not same commit
Feb 27, 2018
ae74611
more verbose
Feb 27, 2018
6c1d502
sanity
Feb 27, 2018
994304d
text align
Feb 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ os:

env:
- MYSQL_USER=root
- CURRENT_CI_ENV=travis

addons:
apt:
packages:
- git
- numactl
- libaio1

before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'

install: true

script: script/cibuild
script:
- script/cibuild

notifications:
email: false
1 change: 0 additions & 1 deletion go/cmd/gh-ost/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func acceptSignals(migrationContext *base.MigrationContext) {
// main is the application's entry point. It will either spawn a CLI or HTTP interfaces.
func main() {
migrationContext := base.NewMigrationContext()

flag.StringVar(&migrationContext.InspectorConnectionConfig.Key.Hostname, "host", "127.0.0.1", "MySQL hostname (preferably a replica, not the master)")
flag.StringVar(&migrationContext.AssumeMasterHostname, "assume-master-host", "", "(optional) explicitly tell gh-ost the identity of the master. Format: some.host.com[:port] This is useful in master-master setups where you wish to pick an explicit master, or in a tungsten-replicator where gh-ost is unable to determine the master")
flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
1 change: 1 addition & 0 deletions localtests/datetime-submillis/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
1 change: 1 addition & 0 deletions localtests/datetime-to-timestamp-pk-fail/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
1 change: 1 addition & 0 deletions localtests/datetime/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
1 change: 1 addition & 0 deletions localtests/json57/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5|5.6)
1 change: 1 addition & 0 deletions localtests/json57dml/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5|5.6)
1 change: 1 addition & 0 deletions localtests/swap-pk-uk/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
1 change: 1 addition & 0 deletions localtests/swap-uk-uk/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
45 changes: 39 additions & 6 deletions localtests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,38 @@

tests_path=$(dirname $0)
test_logfile=/tmp/gh-ost-test.log
ghost_binary=/tmp/gh-ost-test
default_ghost_binary=/tmp/gh-ost-test
ghost_binary=""
exec_command_file=/tmp/gh-ost-test.bash
orig_content_output_file=/gh-ost-test.orig.content.csv
ghost_content_output_file=/gh-ost-test.ghost.content.csv
test_pattern="${1:-.}"
orig_content_output_file=/tmp/gh-ost-test.orig.content.csv
ghost_content_output_file=/tmp/gh-ost-test.ghost.content.csv

master_host=
master_port=
replica_host=
replica_port=

OPTIND=1
while getopts "b:" OPTION
do
case $OPTION in
b)
ghost_binary="$OPTARG"
;;
esac
done
shift $((OPTIND-1))

test_pattern="${1:-.}"

verify_master_and_replica() {
if [ "$(gh-ost-test-mysql-master -e "select 1" -ss)" != "1" ] ; then
echo "Cannot verify gh-ost-test-mysql-master"
exit 1
fi
read master_host master_port <<< $(gh-ost-test-mysql-master -e "select @@hostname, @@port" -ss)
[ "$master_host" == "$(hostname)" ] && master_host="127.0.0.1"
echo "# master verified at $master_host:$master_port"
if [ "$(gh-ost-test-mysql-replica -e "select 1" -ss)" != "1" ] ; then
echo "Cannot verify gh-ost-test-mysql-replica"
exit 1
Expand All @@ -35,6 +50,8 @@ verify_master_and_replica() {
exit 1
fi
read replica_host replica_port <<< $(gh-ost-test-mysql-replica -e "select @@hostname, @@port" -ss)
[ "$replica_host" == "$(hostname)" ] && replica_host="127.0.0.1"
echo "# replica verified at $replica_host:$replica_port"
}

exec_cmd() {
Expand Down Expand Up @@ -66,6 +83,15 @@ test_single() {
local test_name
test_name="$1"

if [ -f $tests_path/$test_name/ignore_versions ] ; then
ignore_versions=$(cat $tests_path/$test_name/ignore_versions)
mysql_version=$(gh-ost-test-mysql-master -s -s -e "select @@version")
if echo "$mysql_version" | egrep -q "^${ignore_versions}" ; then
echo -n "Skipping: $test_name"
return 0
fi
fi

echo -n "Testing: $test_name"

echo_dot
Expand Down Expand Up @@ -98,6 +124,7 @@ test_single() {
--password=gh-ost \
--host=$replica_host \
--port=$replica_port \
--assume-master-host=${master_host}:${master_port}
--database=test \
--table=gh_ost_test \
--alter='engine=innodb' \
Expand Down Expand Up @@ -148,7 +175,8 @@ test_single() {

if [ $execution_result -ne 0 ] ; then
echo
echo "ERROR $test_name execution failure. cat $test_logfile"
echo "ERROR $test_name execution failure. cat $test_logfile:"
cat $test_logfile
return 1
fi

Expand All @@ -170,7 +198,12 @@ test_single() {

build_binary() {
echo "Building"
rm -f $ghost_binary
rm -f $default_ghost_binary
[ "$ghost_binary" == "" ] && ghost_binary="$default_ghost_binary"
if [ -f "$ghost_binary" ] ; then
echo "Using binary: $ghost_binary"
return 0
fi
go build -o $ghost_binary go/cmd/gh-ost/main.go
if [ $? -ne 0 ] ; then
echo "Build failure"
Expand Down
1 change: 1 addition & 0 deletions localtests/timestamp-to-datetime/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
1 change: 1 addition & 0 deletions localtests/timestamp/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
1 change: 1 addition & 0 deletions localtests/tz-datetime-ts/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
1 change: 1 addition & 0 deletions localtests/tz/ignore_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(5.5)
66 changes: 66 additions & 0 deletions script/cibuild-gh-ost-replica-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

set -e

whoami

# Clone gh-ost-ci-env
# Only clone if not already running locally at latest commit
remote_commit=$(git ls-remote https://github.com/github/gh-ost-ci-env.git HEAD | cut -f1)
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

test_mysql_version() {
local mysql_version
mysql_version="$1"

echo "##### Testing $mysql_version"

echo "### Setting up sandbox for $mysql_version"

find sandboxes -name "stop_all" | bash

mkdir -p sandbox/binary
rm -rf sandbox/binary/*
gh-ost-ci-env/bin/linux/dbdeployer unpack gh-ost-ci-env/mysql-tarballs/"$mysql_version".tar.gz --unpack-version="$mysql_version" --sandbox-binary ${PWD}/sandbox/binary

mkdir -p sandboxes
rm -rf sandboxes/*

if echo "$mysql_version" | egrep "5[.]5[.]" ; then
gtid=""
else
gtid="--gtid"
fi
gh-ost-ci-env/bin/linux/dbdeployer deploy replication "$mysql_version" --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

sed '/sandboxes/d' -i gh-ost-ci-env/bin/gh-ost-test-mysql-master
echo 'sandboxes/rsandbox/m "$@"' >> gh-ost-ci-env/bin/gh-ost-test-mysql-master

sed '/sandboxes/d' -i gh-ost-ci-env/bin/gh-ost-test-mysql-replica
echo 'sandboxes/rsandbox/s1 "$@"' >> gh-ost-ci-env/bin/gh-ost-test-mysql-replica

export PATH="${PWD}/gh-ost-ci-env/bin/:${PATH}"

gh-ost-test-mysql-master -uroot -e "grant all on *.* to 'gh-ost'@'%' identified by 'gh-ost'"

echo "### Running gh-ost tests for $mysql_version"
./localtests/test.sh -b bin/gh-ost

find sandboxes -name "stop_all" | bash
}

echo "Building..."
. script/build
# Test all versions:
find gh-ost-ci-env/mysql-tarballs/ -name "*.tar.gz" | while read f ; do basename $f ".tar.gz" ; done | sort -r | while read mysql_version ; do
test_mysql_version "$mysql_version"
done