-
Notifications
You must be signed in to change notification settings - Fork 385
How to execute ActiveRecord JDBC Adapter unit test and Rails ActiveRecord unit test using rails dev box
Yasuo Honda edited this page Oct 5, 2016
·
15 revisions
This document explains how to execute ActiveRecord JDBC Adapter unit test and Rails ActiveRecord unit test using rails-dev-box for those who are interested in ActiveRecord JDBC Adapter Rails 5 support.
Since this document and this rails-dev-box is created for testing purpose only, then please do not apply changes such as changing mysql root password to empty, allowing all IPv4 connection for PostgreSQL to your production systems.
- Install Virtual Box
- Install Vagrant
- Install git
- Clone rails-dev-box
> git clone -b runs_ar_jdbc https://github.com/yahonda/rails-dev-box.git
- Bring up rails-dev-box
> cd rails-dev-box
> vagrant up
- Log in to rails-dev-box via ssh
> vagrant ssh
- Validate which JRuby version is installed
vagrant@rails-dev-box:~$ ruby -v
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 OpenJDK 64-Bit Server VM 25.91-b14 on 1.8.0_91-8u91-b14-3ubuntu1~15.10.1-b14 +jit [linux-x86_64]
- Update git config (if necessary)
vagrant@rails-dev-box:~$ git config --global url."https://".insteadOf git://
- clone ActiveRecord JDBC Adapter and checkout
rails-5
branch
vagrant@rails-dev-box:~$ git clone https://github.com/jruby/activerecord-jdbc-adapter
vagrant@rails-dev-box:~$ cd activerecord-jdbc-adapter/
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ git checkout rails-5
- Update AR_VERSION environment variable for ActiveRecord JDBC Adapter unit test
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ echo 'export AR_VERSION=5.0.0.1' >> ~/.bashrc
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ . ~/.bashrc
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ echo $AR_VERSION
5.0.0.1
You can change 5.0.0.1
to a newer version when released.
- Bundle and execute rake
vagrant@rails-dev-box:~$ cd ~/activerecord-jdbc-adapter/
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ bundle
... snip ...
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake
... snip ...
(`bundle exec rake` also executes `bundle exec rake test_mysql`)
230 tests, 433 assertions, 9 failures, 39 errors, 0 pendings, 7 omissions, 0 notifications
78.4753% passed
- Execute test_sqlite3 of ActiveRecord JDBC Adapter
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake test_sqlite3
... snip ...
176 tests, 333 assertions, 17 failures, 17 errors, 1 pendings, 10 omissions, 0 notifications
78.9157% passed
- Execute test_mysql of ActiveRecord JDBC Adapter
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake test_mysql
... snip ...
230 tests, 433 assertions, 9 failures, 39 errors, 0 pendings, 7 omissions, 0 notifications
78.4753% passed
- Execute test_postgresql of ActiveRecord JDBC Adapter
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake test_postgresql
... snip ...
382 tests, 130 assertions, 35 failures, 294 errors, 2 pendings, 3 omissions, 0 notifications
18.9974% passed
- Clone Rails and checkout
v5.0.0.1
to execute Rails ActiveRecord unit test
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ cd ~
vagrant@rails-dev-box:~$ git clone https://github.com/rails/rails
vagrant@rails-dev-box:~$ cd rails/activerecord
vagrant@rails-dev-box:~$ git checkout v5.0.0.1
- Add AR_JDBC environment variable to use ActiveRecord JDBC Adapter
rails-5
branch
vagrant@rails-dev-box:~/rails/activerecord$ echo 'export AR_JDBC=true' >> ~/.bashrc
vagrant@rails-dev-box:~/rails/activerecord$ . ~/.bashrc
vagrant@rails-dev-box:~/rails/activerecord$ echo $AR_JDBC
true
- Modify Gemfile to use
rails-5
branch
vagrant@rails-dev-box:~/rails/activerecord$ vi ../Gemfile
- Replace branch: 'master' with branch: 'rails-5'
platforms :jruby do
if ENV['AR_JDBC']
gem 'activerecord-jdbcsqlite3-adapter', github: 'jruby/activerecord-jdbc-adapter', branch: 'rails-5'
group :db do
gem 'activerecord-jdbcmysql-adapter', github: 'jruby/activerecord-jdbc-adapter', branch: 'rails-5'
gem 'activerecord-jdbcpostgresql-adapter', github: 'jruby/activerecord-jdbc-adapter', branch: 'rails-5'
end
else
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
group :db do
gem 'activerecord-jdbcmysql-adapter', '>= 1.3.0'
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.3.0'
end
end
end
- Bundle to see if
rails-5
branch appears
vagrant@rails-dev-box:~/rails/activerecord$ bundle
...
Using jdbc-mysql 5.1.31 from git://github.com/jruby/activerecord-jdbc-adapter.git (at rails-5@2cb9b57)
Using jdbc-postgres 9.3.1102 from git://github.com/jruby/activerecord-jdbc-adapter.git (at rails-5@2cb9b57)
Using jdbc-sqlite3 3.7.2.1 from git://github.com/jruby/activerecord-jdbc-adapter.git (at rails-5@2cb9b57)
... snip ...
Using activerecord-jdbc-adapter 1.3.20 from git://github.com/jruby/activerecord-jdbc-adapter.git (at rails-5@2cb9b57)
... snip ...
Using activerecord-jdbcmysql-adapter 1.3.20 from git://github.com/jruby/activerecord-jdbc-adapter.git (at rails-5@2cb9b57)
Using activerecord-jdbcpostgresql-adapter 1.3.20 from git://github.com/jruby/activerecord-jdbc-adapter.git (at rails-5@2cb9b57)
Using activerecord-jdbcsqlite3-adapter 1.3.20 from git://github.com/jruby/activerecord-jdbc-adapter.git (at rails-5@2cb9b57)
- Configure RAILS location to point the local file system which has cloned
rails
vagrant@rails-dev-box:~/rails/activerecord$ cd ~/activerecord-jdbc-adapter
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ echo 'export RAILS=/home/vagrant/rails/' >> ~/.bashrc
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ . ~/.bashrc
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ echo $RAILS
/home/vagrant/rails/
- Execute Rails ActiveRecord unit test v5.0.0.1 for sqlite3
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake rails:test_sqlite3
... snip ...
Using jdbcsqlite3
... snip ...
- Execute Rails ActiveRecord unit test v5.0.0.1 for mysql
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake rails:test_mysql
... snip ...
Using jdbcmysql
... snip ...
- Execute Rails ActiveRecord unit test v5.0.0.1 for postgres
vagrant@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake rails:test_postgres
... snip ...
Using jdbcpostgresql
... snip ...
vagrant@rails-dev-box:~/rails/activerecord$ cd ~/rails/activerecord
vagrant@rails-dev-box:~/rails/activerecord$ bundle exec rake test:jdbcsqlite3
vagrant@rails-dev-box:~/rails/activerecord$ bundle exec rake test:jdbcmysql
vagrant@rails-dev-box:~/rails/activerecord$ bundle exec rake test:jdbcpostgresql