Skip to content

Commit

Permalink
Add CentOS on Travis CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
junaruga committed Jul 30, 2018
1 parent 95bfea3 commit 9524d5a
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Metrics/AbcSize:
# Offense count: 31
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 850
Max: 860

# Offense count: 1
# Configuration parameters: CountBlocks.
Expand Down
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
sudo: required
dist: trusty
services: docker
language: ruby
bundler_args: --without benchmarks development
# Pin Rubygems to a working version. Sometimes it breaks upstream. Update now and then.
Expand Down Expand Up @@ -73,6 +74,11 @@ matrix:
addons:
hosts:
- mysql2gem.example.com
- rvm: 2.4
env: DOCKER=centos
before_install: true
install: docker build -t mysql2 -f .travis_Dockerfile_centos .
script: docker run --add-host=mysql2gem.example.com:127.0.0.1 -t mysql2
fast_finish: true
allow_failures:
- rvm: ruby-head
Expand Down
6 changes: 6 additions & 0 deletions .travis_Dockerfile_centos
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM centos:7

WORKDIR /build
COPY . .

CMD sh .travis_centos.sh
13 changes: 13 additions & 0 deletions .travis_centos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -eux

# Install dependency packages and start mysqld service.
sh .travis_setup_centos.sh

bundle install --path vendor/bundle --without benchmarks development

# USER environment value is not set as a default in the container environment.
export USER=root

bundle exec rake
33 changes: 33 additions & 0 deletions .travis_setup_centos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -eux

yum -y update
yum -y install epel-release
# The options are to install faster.
yum -y install \
--setopt=deltarpm=0 \
--setopt=install_weak_deps=false \
--setopt=tsflags=nodocs \
mariadb-server \
mariadb-devel \
ruby-devel \
git \
gcc \
gcc-c++ \
make
gem update --system > /dev/null
gem install bundler

MYSQL_TEST_LOG="$(pwd)/mysql.log"

mysql_install_db \
--log-error="${MYSQL_TEST_LOG}"
/usr/libexec/mysqld \
--user=root \
--log-error="${MYSQL_TEST_LOG}" \
--ssl &
sleep 3
cat ${MYSQL_TEST_LOG}

mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test'
23 changes: 15 additions & 8 deletions spec/mysql2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,22 @@ def connect(*args)

# You may need to adjust the lines below to match your SSL certificate paths
ssl_client = nil
option_overrides = {
'host' => 'mysql2gem.example.com', # must match the certificates
:sslkey => '/etc/mysql/client-key.pem',
:sslcert => '/etc/mysql/client-cert.pem',
:sslca => '/etc/mysql/ca-cert.pem',
:sslcipher => 'DHE-RSA-AES256-SHA',
:sslverify => true,
}
%i[sslkey sslcert sslca].each do |item|
unless File.exist?(option_overrides[item])
pending("DON'T WORRY, THIS TEST PASSES - but #{option_overrides[item]} does not exist.")
break
end
end
expect do
ssl_client = new_client(
'host' => 'mysql2gem.example.com', # must match the certificates
:sslkey => '/etc/mysql/client-key.pem',
:sslcert => '/etc/mysql/client-cert.pem',
:sslca => '/etc/mysql/ca-cert.pem',
:sslcipher => 'DHE-RSA-AES256-SHA',
:sslverify => true,
)
ssl_client = new_client(option_overrides)
end.not_to raise_error

results = Hash[ssl_client.query('SHOW STATUS WHERE Variable_name LIKE "Ssl_%"').map { |x| x.values_at('Variable_name', 'Value') }]
Expand Down
2 changes: 1 addition & 1 deletion spec/mysql2/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
expect do
res.each_with_index do |_, i|
# Exhaust the first result packet then trigger a timeout
sleep 2 if i > 0 && i % 1000 == 0
sleep 4 if i > 0 && i % 1000 == 0
end
end.to raise_error(Mysql2::Error, /Lost connection/)
end
Expand Down

0 comments on commit 9524d5a

Please sign in to comment.