Skip to content
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

Run CI with GitHub Actions to support Oracle database 18c #198

Merged
merged 3 commits into from Aug 5, 2021

Conversation

yahonda
Copy link
Collaborator

@yahonda yahonda commented Jul 29, 2021

This pull request runs CI with GitHub Actions.

  • Run Oracle Database 18c
  • Only CRuby versions executed since due to Use Ubuntu Xenial at Travis CI #176
  • No Active Record matrix added yet
  • Use dbms_session.sleep for Oracle Database 18c or higher
  • Skip "using Oracle 9.2" for Oracle Database 18c or higher

@yahonda
Copy link
Collaborator Author

yahonda commented Jul 29, 2021

dbms_session.sleep may be a better option to address this error.

  2) ActiveRecord connection should safely close cursors in threaded environment
     Failure/Error: raise ArgumentError, "No database object '#{method.to_s.upcase}' found" unless object

     ArgumentError:
       No database object 'DBMS_LOCK' found
     # ./lib/plsql/schema.rb:182:in `method_missing'
     # ./spec/plsql/schema_spec.rb:233:in `block (4 levels) in <top (required)>'

https://oracle-base.com/articles/18c/dbms_session-sleep-18c

@yahonda
Copy link
Collaborator Author

yahonda commented Aug 3, 2021

The remaining failure.

Failures:

  1) Parameter type mapping / Function with table indexed by bynary integer parameter using Oracle 9.2 should create temporary tables when using Oracle 9.2
     Failure/Error: case element_metadata[:data_type]

     NoMethodError:
       undefined method `[]' for nil:NilClass
     # ./lib/plsql/procedure.rb:314:in `block in ensure_tmp_tables_created'
     # ./lib/plsql/procedure.rb:311:in `each'
     # ./lib/plsql/procedure.rb:311:in `ensure_tmp_tables_created'
     # ./lib/plsql/procedure_call.rb:15:in `initialize'
     # ./lib/plsql/procedure.rb:545:in `new'
     # ./lib/plsql/procedure.rb:545:in `exec'
     # ./lib/plsql/package.rb:67:in `method_missing'
     # ./spec/plsql/procedure_spec.rb:1522:in `block (4 levels) in <top (required)>'

Finished in 44.29 seconds (files took 0.56531 seconds to load)
453 examples, 1 failure, 3 pending

Failed examples:

rspec ./spec/plsql/procedure_spec.rb:1521 # Parameter type mapping / Function with table indexed by bynary integer parameter using Oracle 9.2 should create temporary tables when using Oracle 9.2

@yahonda
Copy link
Collaborator Author

yahonda commented Aug 3, 2021

I've got reason why it fails against Oracle database 18c.

This spec simulates the connection as if it connects to Oracle database 9.2.

# simulate Oracle 9.2 connection
plsql(:oracle_9).connection = get_connection
allow(plsql(:oracle_9).connection).to receive(:database_version).and_return([9, 2, 0, 0])

Then get_argument_metadata executes get_argument_metadata_below_18c.

def get_argument_metadata #:nodoc:
if (@schema.connection.database_version <=> [18, 0, 0, 0]) >= 0
get_argument_metadata_from_18c
else
get_argument_metadata_below_18c
end
end

Both get_argument_metadata_from_18c and get_argument_metadata_below_18c methods depend on each Oracle database dictionary implentation then only mocking database version is not enough.

I'm going to skip this test if the database version is higher than 18c.

Failures:

  1) Parameter type mapping / Function with table indexed by bynary integer parameter using Oracle 9.2 should create temporary tables when using Oracle 9.2
     Failure/Error: case element_metadata[:data_type]

     NoMethodError:
       undefined method `[]' for nil:NilClass
     # ./lib/plsql/procedure.rb:314:in `block in ensure_tmp_tables_created'
     # ./lib/plsql/procedure.rb:311:in `each'
     # ./lib/plsql/procedure.rb:311:in `ensure_tmp_tables_created'
     # ./lib/plsql/procedure_call.rb:15:in `initialize'
     # ./lib/plsql/procedure.rb:545:in `new'
     # ./lib/plsql/procedure.rb:545:in `exec'
     # ./lib/plsql/package.rb:67:in `method_missing'
     # ./spec/plsql/procedure_spec.rb:1522:in `block (4 levels) in <top (required)>'

Finished in 44.29 seconds (files took 0.56531 seconds to load)
453 examples, 1 failure, 3 pending

Failed examples:

rspec ./spec/plsql/procedure_spec.rb:1521 # Parameter type mapping / Function with table indexed by bynary integer parameter using Oracle 9.2 should create temporary tables when using Oracle 9.2

@yahonda yahonda force-pushed the actions branch 5 times, most recently from f20d343 to a795ef2 Compare August 4, 2021 13:24
- Run Oracle Database 18c
- Only CRuby versions executed since due to rsim#176
- No Active Record matrix added yet
dbms_lock.sleep is also supported which requires explicit
grant statement executed like 'grant execute on sys.dbms_lock to hr'.

dbms_session.sleep can be executed without additional grant statement,
which is convenient for CI environments.

Refer
https://docs.oracle.com/en/database/oracle/oracle-database/18/arpls/DBMS_SESSION.html#GUID-27CCC2F7-6564-41D2-8C42-CFFBF25A69B5
https://oracle-base.com/articles/18c/dbms_session-sleep-18c
Without this skip, this spec will fail as follows.

```
Failures:

  1) Parameter type mapping / Function with table indexed by bynary integer parameter using Oracle 9.2 should create temporary tables when using Oracle 9.2
     Failure/Error: case element_metadata[:data_type]

     NoMethodError:
       undefined method `[]' for nil:NilClass
     # ./lib/plsql/procedure.rb:314:in `block in ensure_tmp_tables_created'
     # ./lib/plsql/procedure.rb:311:in `each'
     # ./lib/plsql/procedure.rb:311:in `ensure_tmp_tables_created'
     # ./lib/plsql/procedure_call.rb:15:in `initialize'
     # ./lib/plsql/procedure.rb:545:in `new'
     # ./lib/plsql/procedure.rb:545:in `exec'
     # ./lib/plsql/package.rb:67:in `method_missing'
     # ./spec/plsql/procedure_spec.rb:1522:in `block (4 levels) in <top (required)>'

Finished in 44.29 seconds (files took 0.56531 seconds to load)
453 examples, 1 failure, 3 pending

Failed examples:

rspec ./spec/plsql/procedure_spec.rb:1521 # Parameter type mapping / Function with table indexed by bynary integer parameter using Oracle 9.2 should create temporary tables when using Oracle 9.2
```

Here is the reason why:
This spec simulates the connection as if it connects to Oracle database 9.2.

https://github.com/rsim/ruby-plsql/blob/4c336819759d08c076eb0c351620f21eb5225161/spec/plsql/procedure_spec.rb#L1512-L1514

```ruby
 # simulate Oracle 9.2 connection
 plsql(:oracle_9).connection = get_connection
 allow(plsql(:oracle_9).connection).to receive(:database_version).and_return([9, 2, 0, 0])
```

Then `get_argument_metadata` executes `get_argument_metadata_below_18c`.

https://github.com/rsim/ruby-plsql/blob/4c336819759d08c076eb0c351620f21eb5225161/lib/plsql/procedure.rb#L85-L91

```ruby
 def get_argument_metadata #:nodoc:
   if (@schema.connection.database_version <=> [18, 0, 0, 0]) >= 0
     get_argument_metadata_from_18c
   else
     get_argument_metadata_below_18c
   end
 end
```

Both `get_argument_metadata_from_18c` and `get_argument_metadata_below_18c` methods depend on each Oracle database dictionary implentation then only mocking database version is not enough.
@yahonda yahonda marked this pull request as ready for review August 4, 2021 13:40
@yahonda
Copy link
Collaborator Author

yahonda commented Aug 5, 2021

CI failure against Rails main branch is due to rails/rails#42773, at least not relevant to this pull request.

@yahonda yahonda merged commit 0542702 into rsim:master Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant