diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3da4399a2..4117fa862 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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. diff --git a/.travis.yml b/.travis.yml index a8661f785..c8f3503b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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. @@ -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 diff --git a/.travis_Dockerfile_centos b/.travis_Dockerfile_centos new file mode 100644 index 000000000..4879d2062 --- /dev/null +++ b/.travis_Dockerfile_centos @@ -0,0 +1,6 @@ +FROM centos:7 + +WORKDIR /build +COPY . . + +CMD sh .travis_centos.sh diff --git a/.travis_centos.sh b/.travis_centos.sh new file mode 100644 index 000000000..5ea63a1d7 --- /dev/null +++ b/.travis_centos.sh @@ -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 diff --git a/.travis_setup_centos.sh b/.travis_setup_centos.sh new file mode 100644 index 000000000..a4aa3af83 --- /dev/null +++ b/.travis_setup_centos.sh @@ -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' diff --git a/spec/mysql2/client_spec.rb b/spec/mysql2/client_spec.rb index 00d9c17db..e9f09ec0a 100644 --- a/spec/mysql2/client_spec.rb +++ b/spec/mysql2/client_spec.rb @@ -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') }] diff --git a/spec/mysql2/result_spec.rb b/spec/mysql2/result_spec.rb index 89744fc2f..a70b38ef0 100644 --- a/spec/mysql2/result_spec.rb +++ b/spec/mysql2/result_spec.rb @@ -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