Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
3rd-party connectors tests: mysql-connector-python
  • Loading branch information
elenst committed Dec 14, 2020
1 parent 1a17b6f commit 49688ae
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 53 deletions.
48 changes: 22 additions & 26 deletions buildbot/maria-master.cfg
Expand Up @@ -4373,7 +4373,7 @@ mysql -uroot -prootpass --port=8303 --protocol=tcp -e "drop table mgc.t1"
# Minor upgrade for deb packages
#-------------------------------

def getDebMinorUpgradeStep(kvm_image, args, kvm_scpopt, dist_name, version_name, arch, test_mode, **kwargs):
def getDebMinorUpgradeStepOld(kvm_image, args, kvm_scpopt, dist_name, version_name, arch, test_mode, **kwargs):

return Test(
name="minor-upgrade-"+test_mode,
Expand Down Expand Up @@ -4903,9 +4903,9 @@ fi
"!= rm -f daemon.log; scp -P "+getport()+" "+kvm_scpopt+" buildbot@localhost:daemon.log ."],
**kwargs)

# End of getDebMinorUpgradeStep
# End of getDebMinorUpgradeStepOld

def getDebMinorUpgradeStepNew(kvm_image, args, kvm_scpopt, dist_name, version_name, arch, test_mode, **kwargs):
def getDebMinorUpgradeStep(kvm_image, args, kvm_scpopt, dist_name, version_name, arch, test_mode, **kwargs):

return Test(
name="minor-upgrade-"+test_mode,
Expand All @@ -4919,6 +4919,16 @@ def getDebMinorUpgradeStepNew(kvm_image, args, kvm_scpopt, dist_name, version_na
"= scp -r -P "+getport()+" "+kvm_scpopt+" debs buildbot@localhost:buildbot/",
WithProperties("""
if ! wget --timeout=20 --no-check-certificate https://github.com/MariaDB/mariadb.org-tools/archive/master.zip -O ./master.zip > /dev/null ; then
echo "ERROR: Upgrade scripts couldn't be downloaded"
exit 1
fi
sudo apt-get update
sudo apt-get install -y unzip
echo "Test revision:" `unzip -z master.zip`
unzip master.zip mariadb.org-tools-master/buildbot/*
cd mariadb.org-tools-master/buildbot
test_mode="""+test_mode+"""
branch="%(branch)s"
arch="""+arch+"""
Expand All @@ -4933,28 +4943,23 @@ major_version="%(majorVersion)s"
systemd_capability="%(systemdCapability)s"
development_branch="""+DEVELOPMENT_BRANCH+"""
# TODO: replace test-elenst with master in the block below
if wget --timeout=20 --no-check-certificate https://github.com/MariaDB/mariadb.org-tools/archive/test-elenst.zip -O ./test-elenst.zip > /dev/null ; then
sudo apt-get update
sudo apt-get install -y unzip
echo "Test revision:" `unzip -z master.zip`
unzip test-elenst.zip mariadb.org-tools-test-elenst/buildbot/*
cd mariadb.org-tools-test-elenst/buildbot
set -x
. ./steps/minor_upgrade.deb.sh
else
echo "ERROR: Upgrade scripts couldn't be downloaded"
exit 1
fi
echo "##################################################################"
echo "# To get the script steps without having to copy-paste them"
echo "# one by onefrom the output below, see the attached step-script.sh"
echo "##################################################################"
set -x
. ./steps/minor_upgrade.deb.sh
"""),
"! rm -f daemon.log; (sudo cat /var/log/daemon.log || sudo cat /var/log/syslog) >daemon.log",
"!= rm -f ldd.*; scp -P "+getport()+" "+kvm_scpopt+" buildbot@localhost:/home/buildbot/ldd.* . || true",
"!= rm -f step-script.sh; scp -P "+getport()+" "+kvm_scpopt+" buildbot@localhost:/home/buildbot/mariadb.org-tools-master/buildbot/steps/minor_upgrade.deb.sh ./step-script.sh || true",
"!= rm -f columnstore_logs; scp -P "+getport()+" "+kvm_scpopt+" buildbot@localhost:/home/buildbot/columnstore_logs . || true",
"!= rm -f daemon.log; scp -P "+getport()+" "+kvm_scpopt+" buildbot@localhost:daemon.log ."],
**kwargs)

# End of getDebMinorUpgradeStepNew
# End of getDebMinorUpgradeStep

def getPower9Builder(name, slavenames):
f = BuildFactory()
Expand Down Expand Up @@ -5132,15 +5137,6 @@ dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz
]))
addPackageArchiveStep(deb_fact, "debs", "%(tarbuildnum)s")


deb_fact.addStep(
getDebMinorUpgradeStepNew(kvm_image, args, kvm_scpopt,
dist_name, version_name, arch,
test_mode="server",
doStepIf=(lambda(step): step.getProperty("branch") == "bb-10.2-elenst" or step.getProperty("branch") == "bb-10.5-elenst")
)
)

#---------------------------------
# Deb packages: clean installation
#---------------------------------
Expand Down
@@ -1,9 +1,36 @@
#!/bin/bash -x

### Tests seen sporadically fail in MySQL:
# ERROR: bugs.BugOra21947091.test_ssl_disabled_pure
# FAIL: connection.MySQLConnectionTests.test_shutdown
# ERROR: bugs.Bug551533and586003.test_select (using MySQLConnection)
# ERROR: bugs.Bug865859.test_reassign_connection (using MySQLConnection)

### Tests seen sporadically fail in MariaDB:
# FAIL: bugs.BugOra18415927.test_auth_response
# ERROR: connection.MySQLConnectionTests.test_cmd_stmt_execute

cd mysql-connector-python-*/
sed -ie 's/-for python/for python/' debian/rules
sed -ie '/(5, 7, /,/^$/d' tests/mysqld.py

dh build |tee build.log 2>&1
sudo sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y python3 dh-python debhelper dpkg-dev"
sed -ie "s/override_dh_auto_test/override_dh_auto_test_orig/g" debian/rules

cat >> debian/rules << EOF
override_dh_auto_test:
ifeq (,\$(findstring nocheck,\$(DEB_BUILD_OPTIONS)))
-for python in \$(PYTHON2) \$(PYTHON3); do \\
LIB=\$\$(\$\$python -c "from distutils.command.build import build ; from distutils.core import Distribution ; b = build(Distribution()) ; b.finalize_options() ; print (b.build_purelib)") ;\\
mkdir -p /tmp/con-python/ ; \\
PYTHONPATH=\$(CURDIR)/\$\$LIB \$\$python unittests.py --with-mysql=/usr/ --mysql-topdir=/tmp/con-python/ --verbosity=2 --bind-address=:: --host=::1 --stats ; \\
rm -rf /tmp/con-python/ ; \\
done
endif
EOF

sed -ie 's/^\(\s*\)def _get_version(self):.*$/\1def _get_version(self):\n\1\1return (5,6,99)/' tests/mysqld.py
sed -ie "s/'--is-wheel'//" tests/__init__.py

make -f debian/rules build 2>&1 | tee build.log

grep '^\(FAIL\|ERROR\):' build.log
grep '^\(FAIL\|ERROR\):' build.log | grep -vE "bugs.BugOra21947091.test_ssl_disabled_pure|connection.MySQLConnectionTests.test_shutdown|bugs.Bug551533and586003.test_select|bugs.Bug865859.test_reassign_connection|bugs.BugOra18415927.test_auth_response|connection.MySQLConnectionTests.test_cmd_stmt_execute" | tee /tmp/test.out
69 changes: 46 additions & 23 deletions buildbot/steps/minor_upgrade.deb.sh
Expand Up @@ -45,9 +45,6 @@ echo "Current test mode: $test_mode"
script_path=`readlink -f $0`
script_home=`dirname $script_path`

DEBIAN_FRONTEND=noninteractive
MYSQLD_STARTUP_TIMEOUT=180

#============
# Environment
#============
Expand Down Expand Up @@ -110,8 +107,7 @@ echo "Package_list: $package_list"
# Prepare apt source configuration for installation of the last release
#======================================================================

#sudo sh -c "echo 'deb http://mirror.netinch.com/pub/mariadb/repo/$major_version/$dist_name $version_name main' > /etc/apt/sources.list.d/mariadb_upgrade.list"
sudo sh -c "echo 'deb http://mirror.netinch.com/pub/mariadb/mariadb-10.2.34/repo/$dist_name $version_name main' > /etc/apt/sources.list.d/mariadb_upgrade.list"
sudo sh -c "echo 'deb http://mirror.netinch.com/pub/mariadb/repo/$major_version/$dist_name $version_name main' > /etc/apt/sources.list.d/mariadb_upgrade.list"

# We need to pin directory to ensure that installation happens from MariaDB repo
# rather than from the default distro repo
Expand Down Expand Up @@ -139,7 +135,7 @@ if [[ $res -ne 0 ]] ; then
exit $res
fi

function get_columnstore_logs () {
get_columnstore_logs () {
if [[ "$test_mode" == "columnstore" ]] ; then
echo "Storing Columnstore logs in columnstore_logs"
set +ex
Expand All @@ -165,7 +161,7 @@ function get_columnstore_logs () {
# and can be executed later or even omitted.
# We will wait till they finish, to avoid any clashes with SQL we are going to execute

function wait_for_mysql_upgrade () {
wait_for_mysql_upgrade () {
res=1
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
sleep 3
Expand All @@ -183,15 +179,15 @@ function wait_for_mysql_upgrade () {
fi
}

if ! sudo apt-get -o Dpkg::Options::=--force-confnew install --allow-unauthenticated -y $package_list ; then
if ! sudo sh -c "DEBIAN_FRONTEND=noninteractive MYSQLD_STARTUP_TIMEOUT=180 apt-get -o Dpkg::Options::=--force-confnew install --allow-unauthenticated -y $package_list" ; then
echo "ERROR: Installation of a previous release failed, see the output above"
exit 1
fi

wait_for_mysql_upgrade

if [ -n "$spider_package_list" ] ; then
if ! sudo apt-get -o Dpkg::Options::=--force-confnew install --allow-unauthenticated -y $spider_package_list ; then
if ! sudo sh -c "DEBIAN_FRONTEND=noninteractive MYSQLD_STARTUP_TIMEOUT=180 apt-get -o Dpkg::Options::=--force-confnew install --allow-unauthenticated -y $spider_package_list" ; then
echo "ERROR: Installation of Spider from the previous release failed, see the output above"
exit 1
fi
Expand Down Expand Up @@ -252,16 +248,32 @@ set +e
# Run protocol (3rd-party connectors) tests and store results BEFORE upgrade
#====================================================================================

if [[ "$test_mode" == "server" ]] ; then
sudo sed -ie 's/^# deb-src/deb-src/' /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y debhelper dpkg-dev
connectors_tests () {
# The function expects a parameter with a value either 'old' or 'new'
#
# Each runner script is expected to extract the important part
# of the test results into /tmp/test.out file

for script in $script_home/steps/3rd-party-client-tests/*.deb.sh; do
script=`basename $script`
# The outside directory is used to prevent too long socket paths in tests
rm -rf $HOME/3rd-party
mkdir $HOME/3rd-party
cd $HOME/3rd-party
if apt-get --assume-yes --only-source source ${script%.deb.sh}; then
$script_home/steps/3rd-party-client-tests/${script} 2>&1 | tee /tmp/${script}.result.old
$script_home/steps/3rd-party-client-tests/${script}
mv /tmp/test.out /tmp/${script}.test.out.$1
else
echo "Upgrade warning: source package for connector ${script%.deb.sh} could not be installed with the $1 server"
fi
done
}

if [[ "$test_mode" == "server" ]] ; then
sudo sed -ie 's/^# deb-src/deb-src/' /etc/apt/sources.list
sudo apt-get update
sudo sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -y debhelper dpkg-dev"
connectors_tests "old"
fi

#====================================================================================
Expand Down Expand Up @@ -344,15 +356,15 @@ fi
# Install the new packages
#=========================

sudo apt-get -o Dpkg::Options::=--force-confnew install --allow-unauthenticated -y $package_list
sudo sh -c "DEBIAN_FRONTEND=noninteractive MYSQLD_STARTUP_TIMEOUT=180 apt-get -o Dpkg::Options::=--force-confnew install --allow-unauthenticated -y $package_list"
if [[ $? -ne 0 ]] ; then
echo "ERROR: Installation of the new packages failed, see the output above"
exit 1
fi
wait_for_mysql_upgrade

if [ -n "$spider_package_list" ] ; then
sudo apt-get -o Dpkg::Options::=--force-confnew install --allow-unauthenticated -y $spider_package_list
sudo sh -c "DEBIAN_FRONTEND=noninteractive MYSQLD_STARTUP_TIMEOUT=180 apt-get -o Dpkg::Options::=--force-confnew install --allow-unauthenticated -y $spider_package_list"
if [[ $? -ne 0 ]] ; then
echo "ERROR: Installation of the new Spider packages failed, see the output above"
exit 1
Expand Down Expand Up @@ -524,17 +536,28 @@ esac
#====================================================================================

if [[ "$test_mode" == "server" ]] ; then
for script in /tmp/*.deb.sh.result.old; do
script=${script%.result.old}
script=`basename $script`
$script_home/steps/3rd-party-client-tests/${script} 2>&1 | tee /tmp/${script}.result.new
if ! diff -u /tmp/${script}.result.old /tmp/${script}.result.new ; then
echo "ERROR: Results for ${script%.deb.sh} connector differ"
res=1
sudo sed -ie 's/^# deb-src/deb-src/' /etc/apt/sources.list
sudo apt-get update
connectors_tests "new"
fi

if [[ "$test_mode" == "server" ]] ; then
cd $HOME/3rd-party
for old_result in /tmp/*.deb.sh.test.out.old ; do
if [ -f $old_result ] ; then
new_result=${old_result%.old}.new
if ! diff -u $old_result $new_result ; then
echo "ERROR: Results for ${script%.deb.sh} connector differ"
res=1
fi
fi
done
fi

#====================================================================================
# Check that the server version was modified by the server upgrade
#====================================================================================

diff -u /tmp/version.old /tmp/version.new
if [[ $? -eq 0 ]] ; then
echo "ERROR: server version has not changed after upgrade"
Expand Down

0 comments on commit 49688ae

Please sign in to comment.