Skip to content

Commit bc73887

Browse files
junarugasodabrew
authored andcommitted
Add CentOS on Travis CI. (brianmario#989)
1 parent 3b9a267 commit bc73887

7 files changed

+75
-10
lines changed

.rubocop_todo.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Metrics/AbcSize:
2222
# Offense count: 31
2323
# Configuration parameters: CountComments, ExcludedMethods.
2424
Metrics/BlockLength:
25-
Max: 850
25+
Max: 860
2626

2727
# Offense count: 1
2828
# Configuration parameters: CountBlocks.

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
sudo: required
22
dist: trusty
3+
services: docker
34
language: ruby
45
bundler_args: --without benchmarks development
56
# Pin Rubygems to a working version. Sometimes it breaks upstream. Update now and then.
@@ -73,6 +74,11 @@ matrix:
7374
addons:
7475
hosts:
7576
- mysql2gem.example.com
77+
- rvm: 2.4
78+
env: DOCKER=centos
79+
before_install: true
80+
install: docker build -t mysql2 -f .travis_Dockerfile_centos .
81+
script: docker run --add-host=mysql2gem.example.com:127.0.0.1 -t mysql2
7682
fast_finish: true
7783
allow_failures:
7884
- rvm: ruby-head

.travis_Dockerfile_centos

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM centos:7
2+
3+
WORKDIR /build
4+
COPY . .
5+
6+
RUN yum -y update
7+
RUN yum -y install epel-release
8+
# The options are to install faster.
9+
RUN yum -y install \
10+
--setopt=deltarpm=0 \
11+
--setopt=install_weak_deps=false \
12+
--setopt=tsflags=nodocs \
13+
mariadb-server \
14+
mariadb-devel \
15+
ruby-devel \
16+
git \
17+
gcc \
18+
gcc-c++ \
19+
make
20+
RUN gem update --system > /dev/null
21+
RUN gem install bundler
22+
23+
CMD sh .travis_centos.sh

.travis_centos.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
# Start mysqld service.
6+
sh .travis_setup_centos.sh
7+
8+
bundle install --path vendor/bundle --without benchmarks development
9+
10+
# USER environment value is not set as a default in the container environment.
11+
export USER=root
12+
13+
bundle exec rake

.travis_setup_centos.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
MYSQL_TEST_LOG="$(pwd)/mysql.log"
6+
7+
mysql_install_db \
8+
--log-error="${MYSQL_TEST_LOG}"
9+
/usr/libexec/mysqld \
10+
--user=root \
11+
--log-error="${MYSQL_TEST_LOG}" \
12+
--ssl &
13+
sleep 3
14+
cat ${MYSQL_TEST_LOG}
15+
16+
mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test'

spec/mysql2/client_spec.rb

+15-8
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,22 @@ def connect(*args)
135135

136136
# You may need to adjust the lines below to match your SSL certificate paths
137137
ssl_client = nil
138+
option_overrides = {
139+
'host' => 'mysql2gem.example.com', # must match the certificates
140+
:sslkey => '/etc/mysql/client-key.pem',
141+
:sslcert => '/etc/mysql/client-cert.pem',
142+
:sslca => '/etc/mysql/ca-cert.pem',
143+
:sslcipher => 'DHE-RSA-AES256-SHA',
144+
:sslverify => true,
145+
}
146+
%i[sslkey sslcert sslca].each do |item|
147+
unless File.exist?(option_overrides[item])
148+
pending("DON'T WORRY, THIS TEST PASSES - but #{option_overrides[item]} does not exist.")
149+
break
150+
end
151+
end
138152
expect do
139-
ssl_client = new_client(
140-
'host' => 'mysql2gem.example.com', # must match the certificates
141-
:sslkey => '/etc/mysql/client-key.pem',
142-
:sslcert => '/etc/mysql/client-cert.pem',
143-
:sslca => '/etc/mysql/ca-cert.pem',
144-
:sslcipher => 'DHE-RSA-AES256-SHA',
145-
:sslverify => true,
146-
)
153+
ssl_client = new_client(option_overrides)
147154
end.not_to raise_error
148155

149156
results = Hash[ssl_client.query('SHOW STATUS WHERE Variable_name LIKE "Ssl_%"').map { |x| x.values_at('Variable_name', 'Value') }]

spec/mysql2/result_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
expect do
165165
res.each_with_index do |_, i|
166166
# Exhaust the first result packet then trigger a timeout
167-
sleep 2 if i > 0 && i % 1000 == 0
167+
sleep 4 if i > 0 && i % 1000 == 0
168168
end
169169
end.to raise_error(Mysql2::Error, /Lost connection/)
170170
end

0 commit comments

Comments
 (0)