Skip to content

Commit

Permalink
Travis: install mysql-5.7 "manually"
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed Jul 16, 2016
1 parent ba805ce commit 39901da
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 39 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ matrix:
addons:
hosts:
- mysql2gem.example.com
apt:
packages:
- mysql-server-5.7
- mysql-client-core-5.7
- mysql-client-5.7
# https://github.com/travis-ci/travis-ci/issues/5122
# apt:
# packages:
# - mysql-server-5.7
# - mysql-client-core-5.7
# - mysql-client-5.7
- rvm: 2.0.0
env: DB=mysql55
os: osx
Expand Down
22 changes: 7 additions & 15 deletions .travis_mysql57.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
#!/usr/bin/env bash

set -eu

service mysql stop
apt-get purge '^mysql*' 'libmysql*'
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x8C718D3B5072E1F5
set -eux

apt-get purge -qq '^mysql*' '^libmysql*'
apt-key adv --keyserver pgp.mit.edu --recv-keys 5072E1F5
add-apt-repository 'deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-5.7'
apt-get update -qq
apt-get install -qq mysql-server libmysqlclient-dev

apt-get update
apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew -y install mysql-server libmysqlclient-dev

mysql_upgrade -u root --force --upgrade-system-tables

# Replace the final line of the mysql apparmor, allowing /etc/mysql/*.pem
sed -ie '$ s|}|\
/etc/mysql/*.pem r,\
}|' /etc/apparmor.d/usr.sbin.mysqld
service apparmor restart
# https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''"
9 changes: 3 additions & 6 deletions .travis_setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -eu
set -eux

# Install MySQL 5.7 if DB=mysql57
if [[ -n ${DB-} && x$DB =~ ^xmysql57 ]]; then
Expand All @@ -20,15 +20,12 @@ if ! [[ x$OSTYPE =~ ^xdarwin ]]; then
sudo service mysql restart
fi

sudo mysql -u root -e "CREATE USER '$USER'@'localhost'" || true
sudo mysql -u root -e "GRANT ALL ON test.* TO '$USER'@'localhost'" || true

# Print the MySQL version and create the test DB
if [[ x$OSTYPE =~ ^xdarwin ]]; then
$(brew --prefix "$DB")/bin/mysqld --version
$(brew --prefix "$DB")/bin/mysql -u $USER -e "CREATE DATABASE IF NOT EXISTS test"
$(brew --prefix "$DB")/bin/mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test'
else
mysqld --version
# IF NOT EXISTS is mariadb-10+ only - https://mariadb.com/kb/en/mariadb/comment-syntax/
mysql -u $USER -e "CREATE DATABASE /*M!50701 IF NOT EXISTS */ test"
mysql -u root -e 'CREATE DATABASE /*M!50701 IF NOT EXISTS */ test'
fi
2 changes: 1 addition & 1 deletion .travis_ssl.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -eu
set -eux

# Make sure there is an /etc/mysql
mkdir -p /etc/mysql
Expand Down
6 changes: 0 additions & 6 deletions spec/configuration.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@ user:
username: LOCALUSERNAME
password:
database: mysql2_test

numericuser:
host: localhost
username: LOCALUSERNAME
password:
database: 12345
11 changes: 6 additions & 5 deletions spec/mysql2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,14 @@ def run_gc
end

it "should be able to connect to database with numeric-only name" do
creds = DatabaseCredentials['numericuser']
@client.query "CREATE DATABASE IF NOT EXISTS `#{creds['database']}`"
@client.query "GRANT ALL ON `#{creds['database']}`.* TO #{creds['username']}@`#{creds['host']}`"
database = 1235
@client.query "CREATE DATABASE IF NOT EXISTS `#{database}`"

expect { Mysql2::Client.new(creds) }.not_to raise_error
expect {
Mysql2::Client.new(DatabaseCredentials['root'].merge('database' => database))
}.not_to raise_error

@client.query "DROP DATABASE IF EXISTS `#{creds['database']}`"
@client.query "DROP DATABASE IF EXISTS `#{database}`"
end

it "should respond to #close" do
Expand Down
2 changes: 1 addition & 1 deletion spec/ssl/gen_certs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -eu
set -eux

echo "
[ ca ]
Expand Down

0 comments on commit 39901da

Please sign in to comment.