Skip to content

Commit

Permalink
fixes for 5.27.0
Browse files Browse the repository at this point in the history
  • Loading branch information
klobuczek committed Dec 17, 2024
1 parent f7fb6c3 commit 1d5233f
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 97 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ end.spec 'neo4j-ruby-driver' do

self.clean_globs += %w[Gemfile Gemfile.lock *.gemspec lib/org lib/*_jars.rb]

require_ruby_version '>= 3.1'

if jruby?
require_ruby_version '>= 2.6'
dependency 'async', '< 2', :dev
dependency 'concurrent-ruby-edge', '>= 0.6.0'
dependency 'jar-dependencies', '0.4.1'
Expand All @@ -46,7 +47,6 @@ end.spec 'neo4j-ruby-driver' do
spec_extras[:requirements] = ->(requirements) { requirements << 'jar org.neo4j.driver, neo4j-java-driver-all, 5.27.0' }
spec_extras[:platform] = 'java'
else
require_ruby_version '>= 3.1'
dependency 'async', '< 2.13'
dependency 'async-io', '>= 0'
dependency 'connection_pool', '>= 0'
Expand Down
9 changes: 4 additions & 5 deletions jruby/neo4j/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Driver
Transaction = Java::OrgNeo4jDriverInternal::InternalTransaction

module Internal
java_import org.neo4j.driver.internal.DatabaseNameUtil
java_import org.neo4j.driver.internal.bolt.api.DatabaseNameUtil
end

module Net
Expand Down Expand Up @@ -43,8 +43,7 @@ module Types
Java::OrgNeo4jDriverInternal::InternalDriver.prepend Neo4j::Driver::Ext::InternalDriver
Java::OrgNeo4jDriverInternal::InternalEntity.include Neo4j::Driver::Ext::InternalEntity
Java::OrgNeo4jDriverInternal::InternalNode.prepend Neo4j::Driver::Ext::InternalNode
Java::OrgNeo4jDriverInternal::InternalNotificationCategory.prepend Neo4j::Driver::Ext::Internal::InternalNotificationCommon
Java::OrgNeo4jDriverInternal::InternalNotificationSeverity.prepend Neo4j::Driver::Ext::Internal::InternalNotificationCommon
Java::OrgNeo4jDriverInternal::InternalNotificationSeverity.delegate :name, to: :type
Java::OrgNeo4jDriverInternal::InternalPath.include Neo4j::Driver::Ext::StartEndNaming
Java::OrgNeo4jDriverInternal::InternalPath::SelfContainedSegment.include Neo4j::Driver::Ext::StartEndNaming
Java::OrgNeo4jDriverInternal::InternalRecord.prepend Neo4j::Driver::Ext::InternalRecord
Expand All @@ -53,8 +52,8 @@ module Types
Java::OrgNeo4jDriverInternal::InternalSession.prepend Neo4j::Driver::Ext::InternalSession
Java::OrgNeo4jDriverInternal::InternalTransaction.prepend Neo4j::Driver::Ext::InternalTransaction
Java::OrgNeo4jDriverInternalAsync::InternalAsyncSession.prepend Neo4j::Driver::Ext::Internal::Async::InternalAsyncSession
Java::OrgNeo4jDriverInternalCluster::RoutingTableRegistryImpl.include Neo4j::Driver::Ext::Internal::Cluster::RoutingTableRegistryImpl
Java::OrgNeo4jDriverInternalCursor::DisposableAsyncResultCursor.prepend Neo4j::Driver::Ext::Internal::Cursor::DisposableAsyncResultCursor
Java::OrgNeo4jDriverInternalBoltRoutedimplCluster::RoutingTableRegistryImpl.include Neo4j::Driver::Ext::Internal::Cluster::RoutingTableRegistryImpl
# Java::OrgNeo4jDriverInternalCursor::DisposableAsyncResultCursor.prepend Neo4j::Driver::Ext::Internal::Cursor::DisposableAsyncResultCursor
Java::OrgNeo4jDriverInternalMetrics::InternalConnectionPoolMetrics.include Neo4j::Driver::Ext::Internal::Metrics::InternalConnectionPoolMetrics
Java::OrgNeo4jDriverInternalSummary::InternalNotification.prepend Neo4j::Driver::Ext::Internal::Summary::InternalNotification
Java::OrgNeo4jDriverInternalSummary::InternalPlan.prepend Neo4j::Driver::Ext::Internal::Summary::InternalPlan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Internal
module Cluster
module RoutingTableRegistryImpl
def routing_table_handler(database)
get_routing_table_handler(org.neo4j.driver.internal.DatabaseNameUtil.database(database)).then do |it|
get_routing_table_handler(org.neo4j.driver.internal.bolt.api.DatabaseNameUtil.database(database)).then do |it|
it.get if it.present?
end
end
Expand Down
13 changes: 0 additions & 13 deletions jruby/neo4j/driver/ext/internal/internal_notification_common.rb

This file was deleted.

2 changes: 1 addition & 1 deletion jruby/neo4j/driver/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Neo4j
module Driver
VERSION = '5.20.0.alpha.0'
VERSION = '5.27.0.alpha.0'
end
end
25 changes: 4 additions & 21 deletions spec/integration/causal_clustering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,11 @@ def new_session(mode)
expect(count).to eq 1
end

# DisabledOnNeo4jWith( BOLT_V4 )
it 'executes reads and writes when router is discovered', version: '<4' do
count = execute_write_and_read_through_bolt_on_first_available_address(cluster.any_read_replica, leader)
expect(count).to eq 1
end

it 'executes reads and writes when driver supplied with address of follower ' do
count = execute_write_and_read_through_bolt(cluster.any_follower)
expect(count).to eq 1
end

# DisabledOnNeo4jWith( BOLT_V4 )
it 'session creation fails if calling discovery procedure on edge server', version: '<4' do
read_replica = cluster.any_read_replica
create_driver(read_replica.routing_uri) do |driver|
expect(&driver.method(:verify_connectivity))
.to raise_error Neo4j::Driver::Exceptions::ServiceUnavailableException,
'Unable to connect to database management service, ensure the database is running and that ' \
'there is a working network connection to it.'
end
end

# Ensure that Bookmarks work with single instances using a driver created using a bolt[not+routing] URI.
it 'bookmarks work with driver pinned to single server' do
create_driver(leader.bolt_uri) do |driver|
Expand Down Expand Up @@ -96,8 +79,8 @@ def new_session(mode)
end

# needs implementation details. Impossible as integration test
#it 'shouldDropBrokenOldConnections' do
#end
# it 'shouldDropBrokenOldConnections' do
# end

it 'begin transaction raises for invalid bookmark' do
invalid_bookmark = Neo4j::Driver::Bookmark.from('hi, this is an invalid bookmark')
Expand All @@ -111,7 +94,7 @@ def new_session(mode)
end

# Started failing suddenly for neo4j 3.5. Probably due to some enviromental change in GH actions. Won't fix anymore.
it 'handles graceful leader switch', version: '>=4' do
it 'handles graceful leader switch' do
cluster_address = Neo4j::Driver::Net::ServerAddress.of('cluster', 7687)
cluster_uri = "neo4j://#{cluster_address.host}:#{cluster_address.port}"
core_addresses = cluster.cores.map(&:bolt_address)
Expand Down Expand Up @@ -178,7 +161,7 @@ def new_session(mode)

it 'routing tables' do
create_driver(leader.routing_uri, routing_table_purge_delay: 3.minutes) do |driver|
database = version?('>=4.0') ? 'neo4j' : nil
database = 'neo4j'
driver.session(database: database) do |session|
session.read_transaction { |tx| tx.run('RETURN 1').consume }
end
Expand Down
6 changes: 1 addition & 5 deletions spec/integration/load_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,7 @@
load = 'LOAD CSV WITH HEADERS FROM $csv_file_url AS l'
subquery = "MATCH (c:Class {name: l.class_name}) CREATE (c)<-[:HAS_CLASS]-(s:Sample{sepal_length: l.sepal_length, sepal_width: l.sepal_width, petal_length: l.petal_length, petal_width: l.petal_width})"
return_s = 'RETURN count(*) AS c'
query = if version?('<4.4')
"USING PERIODIC COMMIT #{size} #{load} #{subquery} #{return_s}"
else
"#{load} CALL { WITH l #{subquery} } IN TRANSACTIONS OF #{size} ROWS #{return_s}"
end
query = "#{load} CALL { WITH l #{subquery} } IN TRANSACTIONS OF #{size} ROWS #{return_s}"
result = session.run(query, csv_file_url: "file:///#{File.basename(file)}")
expect(result.next[:c]).to eq(150)
expect(result.has_next?).to be_falsey
Expand Down
16 changes: 1 addition & 15 deletions spec/integration/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def expectNotEmptyBookmark(bookmark)
end
end

it 'does not propagate failure when streaming is cancelled', version: '>=4' do
it 'does not propagate failure when streaming is cancelled' do
driver.session do |session|
session.run('UNWIND range(20000, 0, -1) AS x RETURN 10 / x')
end
Expand Down Expand Up @@ -560,20 +560,6 @@ def expectNotEmptyBookmark(bookmark)
expect { result.to_a }.to raise_error Neo4j::Driver::Exceptions::ResultConsumedException
end

it 'Allow To Consume Records Slowly And Close Session', version: '<4' do
driver.session do |session|
result = session.run('UNWIND range(10000, 0, -1) AS x RETURN 10 / x')
10.times do
expect(result).to have_next
expect(result.next).to be_present
sleep(0.05)
end
expect { session.close }.to raise_error Neo4j::Driver::Exceptions::ClientException do |error|
expect(error.code).to match /ArithmeticError/
end
end
end

it 'Allow To Consume Records Slowly And Retrieve Summary' do
driver.session do |session|
result = session.run('UNWIND range(8000, 1, -1) AS x RETURN 42 / x')
Expand Down
39 changes: 11 additions & 28 deletions spec/integration/summary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,13 @@
expect(session.run('CREATE (n {magic: 42})').consume.counters.contains_updates?).to be true
expect(session.run('MATCH (n:ALabel) REMOVE n:ALabel ').consume.counters.labels_removed).to eq 1

if version?('>=4.4')
expect(session.run('CREATE INDEX name FOR (l:ALabel) ON (l.prop)').consume.counters.indexes_added).to eq 1
expect(session.run('DROP INDEX name').consume.counters.indexes_removed).to eq 1

expect(session.run('CREATE CONSTRAINT name FOR (book:Book) REQUIRE book.isbn IS UNIQUE')
.consume.counters.constraints_added).to eq 1
expect(session.run('DROP CONSTRAINT name')
.consume.counters.constraints_removed).to eq 1
else
expect(session.run('CREATE INDEX ON :ALabel(prop)').consume.counters.indexes_added).to eq 1
expect(session.run('DROP INDEX ON :ALabel(prop)').consume.counters.indexes_removed).to eq 1

expect(session.run('CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE')
.consume.counters.constraints_added).to eq 1
expect(session.run('DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE')
.consume.counters.constraints_removed).to eq 1
end
expect(session.run('CREATE INDEX name FOR (l:ALabel) ON (l.prop)').consume.counters.indexes_added).to eq 1
expect(session.run('DROP INDEX name').consume.counters.indexes_removed).to eq 1

expect(session.run('CREATE CONSTRAINT name FOR (book:Book) REQUIRE book.isbn IS UNIQUE')
.consume.counters.constraints_added).to eq 1
expect(session.run('DROP CONSTRAINT name')
.consume.counters.constraints_removed).to eq 1
end
end

Expand All @@ -66,17 +56,10 @@
.to eq Neo4j::Driver::Summary::QueryType::WRITE_ONLY
expect(session.run('CREATE (n) RETURN (n)').consume.query_type)
.to eq Neo4j::Driver::Summary::QueryType::READ_WRITE
if version?('>=4.4')
expect(session.run('CREATE INDEX name FOR (u:User) ON (u.p)').consume.query_type)
.to eq Neo4j::Driver::Summary::QueryType::SCHEMA_WRITE
expect(session.run('DROP INDEX name').consume.query_type)
.to eq Neo4j::Driver::Summary::QueryType::SCHEMA_WRITE
else
expect(session.run('CREATE INDEX ON :User(p)').consume.query_type)
.to eq Neo4j::Driver::Summary::QueryType::SCHEMA_WRITE
expect(session.run('DROP INDEX ON :User(p)').consume.query_type)
.to eq Neo4j::Driver::Summary::QueryType::SCHEMA_WRITE
end
expect(session.run('CREATE INDEX name FOR (u:User) ON (u.p)').consume.query_type)
.to eq Neo4j::Driver::Summary::QueryType::SCHEMA_WRITE
expect(session.run('DROP INDEX name').consume.query_type)
.to eq Neo4j::Driver::Summary::QueryType::SCHEMA_WRITE
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/neo4j/driver/graph_database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def simple_query(driver)
it { is_expected.to eq 1 }
end

context 'when neo4j', version: '>=4' do
context 'when neo4j' do
let(:scheme) { 'neo4j' }
it { is_expected.to eq 1 }
end
Expand Down
4 changes: 2 additions & 2 deletions spec/neo4j/driver/simplified_examples_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@
end
end

it 'accepts transaction config', version: '>=3.5' do
it 'accepts transaction config' do
driver.session do |session|
session.read_transaction(timeout: 1.minute, metadata: { a: 1, b: 'string' }) do |tx|
expect(tx.run('RETURN 1').single.first).to eq 1
end
end
end

it 'accepts run config', version: '>=3.5' do
it 'accepts run config' do
driver.session do |session|
expect(session.run('RETURN 1', {}, timeout: 1.minute, metadata: { a: 1, b: 'string' }).single.first).to eq 1
end
Expand Down
2 changes: 1 addition & 1 deletion spec/neo4j/driver/util/cc/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def driver(bolt_uri)
def core_member?(driver)
driver.session(default_access_mode: Neo4j::Driver::AccessMode::READ) do |session|
%w[LEADER FOLLOWER].include?(
session.run("CALL dbms.cluster.role(#{'$database' if version?('>=4')})", database: 'neo4j')
session.run("CALL dbms.cluster.role($database)", database: 'neo4j')
.single.first
)
end
Expand Down
2 changes: 2 additions & 0 deletions testkit-backend/bin/testkit-backend
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env ruby

require "bundler/setup"
require 'ostruct'
require "testkit/backend"
require "active_support/core_ext/object/blank"

Async do
Testkit::Backend::Runner.new(9876).run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class GetFeatures < Request
'Feature:Bolt:5.2' => 'jar',
'Feature:Bolt:5.3' => 'ja',
'Feature:Bolt:5.4' => 'ja',
'Feature:Bolt:5.5' => 'ja',
'Feature:Bolt:5.6' => 'ja',
'Feature:Bolt:5.7' => 'ja',
'Feature:Bolt:5.8' => 'a',
'Feature:Bolt:Patch:UTC' => 'ja',
'Feature:Impersonation' => 'ja',
'Feature:TLS:1.1' => 'a', # TODO works for java,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def map_entry(n, method, *methods)
def notifications(ns)
ns.map do |n|
to_map(n, *%w[code title description raw_category severity raw_severity_level])
.merge(to_map(n, *%w[category severity_level]) { |o| o&.type || 'UNKNOWN' })
.merge(to_map(n, *%w[category severity_level]) { |o| o&.name || 'UNKNOWN' })
.merge(map_entry(n, :position, :column, :line, :offset))
end
end
Expand Down
3 changes: 2 additions & 1 deletion testkit-backend/testkit-backend.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Gem::Specification.new do |spec|
spec.add_dependency 'async-io'
spec.add_dependency 'nio4r'
spec.add_dependency 'zeitwerk'
spec.add_dependency 'activesupport', '< 7.1'
spec.add_dependency 'activesupport'
spec.add_dependency 'ostruct'
spec.add_dependency 'psych', '5.1.0' if RUBY_PLATFORM == 'java' # Temporary workaround
spec.add_development_dependency 'rspec'
# spec.add_development_dependency "async-rspec", "~> 1.10"
Expand Down

0 comments on commit 1d5233f

Please sign in to comment.