Permalink
Fetching contributors…
Cannot retrieve contributors at this time
110 lines (78 sloc) 4.75 KB

Build Status

When and Which tests need to be executed

When you are creating a fix and/or some new features for Oracle enhanced adapter, It is recommended to execute Oracle enhanced adapter unit tests and ActiveRecord unit tests.

  • Oracle enhanced adapter unit test
  • ActiveRecord unit test

This document explains how to prepare and execute Oracle enhanced adapter unit test. For ActiveRecord unit test, please refer Contributing to Ruby on Rails .

This document talks about developing Oracle enhanced adapter itself, does NOT talk about developing Rails applications using Oracle enhanced adapter.

Building development and test environment

You can create Oracle enhanced adapter development and test environment by following one of them. If you are first to create this environment rails-dev-box runs_oracle branch is recommended.

rails-dev-box runs_oracle branch

rails-dev-box runs_oracle_on_docker branch

Create by yourself

You can create your development and test environment by yourself.

Install Ruby

Install Ruby 2.2.2 or higher version of Ruby and JRuby 9.0.5 or higher. To switch multiple version of ruby, you can use use ruby-build or Ruby Version Manager(RVM).

Creating the test database

To test Oracle enhanced adapter Oracle database is necesssary. You can build by your own or use the Docker to run pre-build Oracle Database Express Edition 11g Release 2.

Create database by yourself

Oracle database 11.2 or later with SYS and SYSTEM user access. AL32UTF8 database character set is recommended.

Docker

If no Oracle database with SYS and SYSTEM user access is available, try the docker approach.

  • Install Docker

  • Pull docker-oracle-xe-11g image from docker hub

    $ docker pull wnameless/oracle-xe-11g
  • Start a Oracle database docker container with mapped ports. Use port 49161 to access the database.

    $ docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g
  • Check connection to the database with sqlplus. The user is system, the password is oracle.

    $ sqlplus64 system/oracle@localhost:49161

Creating database schemas at the test database

  • Create Oracle database schema for test purposes. Review spec/spec_helper.rb to see default schema/user names and database names (use environment variables to override defaults)
SQL> CREATE USER oracle_enhanced IDENTIFIED BY oracle_enhanced;
SQL> GRANT unlimited tablespace, create session, create table, create sequence, create procedure, create trigger, create view, create materialized view, create database link, create synonym, create type, ctxapp TO oracle_enhanced;

SQL> CREATE USER oracle_enhanced_schema IDENTIFIED BY oracle_enhanced_schema;
SQL> GRANT unlimited tablespace, create session, create table, create sequence, create procedure, create trigger, create view, create materialized view, create database link, create synonym, create type, ctxapp TO oracle_enhanced_schema;

Configure database login credentials

  • Configure database credentials in one of two ways:

    • copy spec/spec_config.yaml.template to spec/spec_config.yaml and modify as needed
    • set required environment variables (see DATABASE_NAME in spec_helper.rb)
  • The oracle enhanced configuration file spec/spec_config.yaml should look like:

    # copy this file to spec/config.yaml and set appropriate values
    # you can also use environment variables, see spec_helper.rb
    database:
      name:         'xe'
      host:         'localhost'
      port:         49161
      user:         'oracle_enhanced'
      password:     'oracle_enhanced'
      sys_password: 'oracle'
      non_default_tablespace: 'SYSTEM'
      timezone: 'Europe/Riga'

Running Oracle enhanced adapter unit tests

  • Install bundler

    $ gem install bundler
  • Execute bundle install to install required gems

    $ bundle install
  • Run Oracle enhanced adapter unit tests

    $ bundle exec rake spec