Skip to content

Commit 67d1b16

Browse files
authored
Merge pull request brianmario#767 from tamird/deflake-CI
Deflake CI
2 parents 6bf7c34 + 39901da commit 67d1b16

File tree

9 files changed

+34
-49
lines changed

9 files changed

+34
-49
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ matrix:
6464
addons:
6565
hosts:
6666
- mysql2gem.example.com
67-
apt:
68-
packages:
69-
- mysql-server-5.7
70-
- mysql-client-core-5.7
71-
- mysql-client-5.7
67+
# https://github.com/travis-ci/travis-ci/issues/5122
68+
# apt:
69+
# packages:
70+
# - mysql-server-5.7
71+
# - mysql-client-core-5.7
72+
# - mysql-client-5.7
7273
- rvm: 2.0.0
7374
env: DB=mysql55
7475
os: osx

.travis_mysql57.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
#!/usr/bin/env bash
22

3-
set -eu
4-
5-
service mysql stop
6-
apt-get purge '^mysql*' 'libmysql*'
7-
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x8C718D3B5072E1F5
3+
set -eux
84

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

11-
apt-get update
12-
apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew -y install mysql-server libmysqlclient-dev
13-
14-
mysql_upgrade -u root --force --upgrade-system-tables
15-
16-
# Replace the final line of the mysql apparmor, allowing /etc/mysql/*.pem
17-
sed -ie '$ s|}|\
18-
/etc/mysql/*.pem r,\
19-
}|' /etc/apparmor.d/usr.sbin.mysqld
20-
service apparmor restart
11+
# https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
12+
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''"

.travis_setup.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
set -eu
3+
set -eux
44

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

23-
sudo mysql -u root -e "CREATE USER '$USER'@'localhost'" || true
24-
sudo mysql -u root -e "GRANT ALL ON test.* TO '$USER'@'localhost'" || true
25-
2623
# Print the MySQL version and create the test DB
2724
if [[ x$OSTYPE =~ ^xdarwin ]]; then
2825
$(brew --prefix "$DB")/bin/mysqld --version
29-
$(brew --prefix "$DB")/bin/mysql -u $USER -e "CREATE DATABASE IF NOT EXISTS test"
26+
$(brew --prefix "$DB")/bin/mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test'
3027
else
3128
mysqld --version
3229
# IF NOT EXISTS is mariadb-10+ only - https://mariadb.com/kb/en/mariadb/comment-syntax/
33-
mysql -u $USER -e "CREATE DATABASE /*M!50701 IF NOT EXISTS */ test"
30+
mysql -u root -e 'CREATE DATABASE /*M!50701 IF NOT EXISTS */ test'
3431
fi

.travis_ssl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
set -eu
3+
set -eux
44

55
# Make sure there is an /etc/mysql
66
mkdir -p /etc/mysql

Rakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ load 'tasks/compile.rake'
88
load 'tasks/generate.rake'
99
load 'tasks/benchmarks.rake'
1010

11-
# TODO: remove when we end support for < 1.9.3
12-
begin
11+
# TODO: remove engine check when rubinius stops crashing on RuboCop
12+
# TODO: remove defined?(Encoding) when we end support for < 1.9.3
13+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && defined?(Encoding)
1314
require 'rubocop/rake_task'
1415
RuboCop::RakeTask.new
1516
task :default => [:spec, :rubocop]
16-
17-
rescue LoadError
17+
else
1818
warn 'RuboCop is not available'
1919
task :default => :spec
2020
end

spec/configuration.yml.example

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,3 @@ user:
99
username: LOCALUSERNAME
1010
password:
1111
database: mysql2_test
12-
13-
numericuser:
14-
host: localhost
15-
username: LOCALUSERNAME
16-
password:
17-
database: 12345

spec/mysql2/client_spec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,14 @@ def run_gc
263263
end
264264

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

270-
expect { Mysql2::Client.new(creds) }.not_to raise_error
269+
expect {
270+
Mysql2::Client.new(DatabaseCredentials['root'].merge('database' => database))
271+
}.not_to raise_error
271272

272-
@client.query "DROP DATABASE IF EXISTS `#{creds['database']}`"
273+
@client.query "DROP DATABASE IF EXISTS `#{database}`"
273274
end
274275

275276
it "should respond to #close" do

spec/mysql2/statement_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
@client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "utf8"))
77
end
88

9+
def stmt_count
10+
@client.query("SHOW STATUS LIKE 'Prepared_stmt_count'").first['Value'].to_i
11+
end
12+
913
it "should create a statement" do
1014
statement = nil
11-
expect { statement = @client.prepare 'SELECT 1' }.to change {
12-
@client.query("SHOW STATUS LIKE 'Prepared_stmt_count'").first['Value'].to_i
13-
}.by(1)
15+
expect { statement = @client.prepare 'SELECT 1' }.to change(&method(:stmt_count)).by(1)
1416
expect(statement).to be_an_instance_of(Mysql2::Statement)
1517
end
1618

@@ -689,9 +691,7 @@
689691
context 'close' do
690692
it 'should free server resources' do
691693
stmt = @client.prepare 'SELECT 1'
692-
expect { stmt.close }.to change {
693-
@client.query("SHOW STATUS LIKE 'Prepared_stmt_count'").first['Value'].to_i
694-
}.by(-1)
694+
expect { stmt.close }.to change(&method(:stmt_count)).by(-1)
695695
end
696696

697697
it 'should raise an error on subsequent execution' do

spec/ssl/gen_certs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
set -eu
3+
set -eux
44

55
echo "
66
[ ca ]

0 commit comments

Comments
 (0)