-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to set a custom SSL pem files directory in test. #1293
Conversation
I can see there is one code style failure in rubocop 1.41.1 on the CI lint test. But I don't think it is related to this PR. https://github.com/brianmario/mysql2/actions/runs/3758719510/jobs/6387395566#step:4:12
The rubocop test was ok with rubocop 1.41.0. |
.github/workflows/container.yml
Outdated
@@ -16,7 +16,7 @@ jobs: | |||
# Fedora latest stable version | |||
- {distro: fedora, image: 'fedora:latest'} | |||
# Fedora development version | |||
- {distro: fedora, image: 'fedora:rawhide'} | |||
- {distro: fedora, image: 'fedora:rawhide', ssl_dir: '/tmp/mysql2'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the ssl_dir
option to test this feature.
You can see the my.cnf
is set up with the environment variable.
https://github.com/brianmario/mysql2/actions/runs/3758719509/jobs/6387395753#step:4:85
You can also see the SSL tests are not skipped. If the pem files don't exist, the tests are skipped.
https://github.com/brianmario/mysql2/actions/runs/3758719509/jobs/6387395753#step:4:664
-t \ | ||
-e TEST_RUBY_MYSQL2_SSL_DIR="${{ matrix.ssl_dir || '' }}" \ | ||
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \ | ||
mysql2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the 1 line command to the YAML block syntax, as I saw one YAML syntax error in the one line with adding the -e
option. Maybe it's good to time to change to the YAML block syntax for better visibility.
It seems that the failures in MacOS mariadb and mysql CI cases come from the failure of installing a dependency Python. I don't think it is related to this PR. |
Note that ideally I wanted to use the managed pem files without copying to another directory with the patch below. However I observed an error in the
|
spec/spec_helper.rb
Outdated
def ssl_dir | ||
return @ssl_dir if @ssl_dir | ||
|
||
@ssl_dir = ENV['TEST_RUBY_MYSQL2_SSL_DIR'] || '/etc/mysql' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the TEST_RUBY_MYSQL2_SSL_DIR
is because there is one environment variable RUBY_MYSQL2_LIBMYSQL_DLL
. So, I referred to the name.
$ grep -r RUBY_MYSQL2
README.md:* Environment variable `RUBY_MYSQL2_LIBMYSQL_DLL=C:\path\to\libmysql.dll`
tmp/x86_64-linux/stage/README.md:* Environment variable `RUBY_MYSQL2_LIBMYSQL_DLL=C:\path\to\libmysql.dll`
tmp/x86_64-linux/stage/lib/mysql2.rb: dll_path = if ENV['RUBY_MYSQL2_LIBMYSQL_DLL']
tmp/x86_64-linux/stage/lib/mysql2.rb: ENV['RUBY_MYSQL2_LIBMYSQL_DLL']
lib/mysql2.rb: dll_path = if ENV['RUBY_MYSQL2_LIBMYSQL_DLL']
lib/mysql2.rb: ENV['RUBY_MYSQL2_LIBMYSQL_DLL']
a32659c
to
5842c70
Compare
5842c70
to
bb18e4c
Compare
ci/ssl.sh
Outdated
ssl-key=/etc/mysql/server-key.pem | ||
ssl-ca=${SSL_DIR}/ca-cert.pem | ||
ssl-cert=${SSL_DIR}/server-cert.pem | ||
ssl-key=${SSL_DIR}/server-key.pem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a note, we are applying the patch below in the mysql2 gem RPM package in the Fedora project. We are using the *.pem files in the original repository directory without copying.
diff --git a/spec/mysql2/client_spec.rb b/spec/mysql2/client_spec.rb
index 5861882..3f5cda8 100644
--- a/spec/mysql2/client_spec.rb
+++ b/spec/mysql2/client_spec.rb
@@ -153,9 +153,9 @@ RSpec.describe Mysql2::Client do # rubocop:disable Metrics/B
lockLength
let(:option_overrides) do
{
'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',
+ :sslkey => 'spec/ssl/client-key.pem',
+ :sslcert => 'spec/ssl/client-cert.pem',
+ :sslca => 'spec/ssl/ca-cert.pem',
:sslcipher => 'DHE-RSA-AES256-SHA',
:sslverify => true,
}
---
2.38.1
This looks good with latest update. Ready to land? |
Just moment. I think the key word |
bb18e4c
to
b95f110
Compare
… test. In the Fedora project, we are running the mysql2 tests on the build environment with a user permission, without root permission and without `sudo`. In this case, we couldn't set up the pem files required to run SSL tests in the `/etc/mysql`. This custom SSL directory option gives an option to run the SSL tests executed in the environment. How to use: ``` $ TEST_RUBY_MYSQL2_SSL_CERT_DIR=/tmp/mysql2 \ bundle exec rake spec ```
b95f110
to
1edda51
Compare
Yes, I am ready to land! I rebased by replacing the |
What do you think? Was the previous |
Merged! I do like your last change, it is clearer that the directory is for SSL certs and not libraries or anything else. |
In the Fedora project, we are running the mysql2 tests on the build environment with a user permission, without root permission and without
sudo
.For the change in MariaDB 10.5.18 on Fedora, we need to set up the SSL pem files manually to run the SSL tests.
In this case, we couldn't set up the pem files required to run SSL tests in the
/etc/mysql
. This custom SSL directory option gives an option to run the SSL tests executed in the environment.How to use: