From 1d5233f43225e7b907cdabefa913adb37dc17622 Mon Sep 17 00:00:00 2001 From: klobuczek Date: Tue, 17 Dec 2024 23:31:37 +0100 Subject: [PATCH] fixes for 5.27.0 --- Rakefile | 4 +- jruby/neo4j/driver.rb | 9 ++--- .../cluster/routing_table_registry_impl.rb | 2 +- .../internal/internal_notification_common.rb | 13 ------- jruby/neo4j/driver/version.rb | 2 +- spec/integration/causal_clustering_spec.rb | 25 ++---------- spec/integration/load_csv_spec.rb | 6 +-- spec/integration/session_spec.rb | 16 +------- spec/integration/summary_spec.rb | 39 ++++++------------- spec/neo4j/driver/graph_database_spec.rb | 2 +- spec/neo4j/driver/simplified_examples_spec.rb | 4 +- spec/neo4j/driver/util/cc/cluster.rb | 2 +- testkit-backend/bin/testkit-backend | 2 + .../backend/messages/requests/get_features.rb | 4 ++ .../messages/requests/result_consume.rb | 2 +- testkit-backend/testkit-backend.gemspec | 3 +- 16 files changed, 38 insertions(+), 97 deletions(-) delete mode 100644 jruby/neo4j/driver/ext/internal/internal_notification_common.rb diff --git a/Rakefile b/Rakefile index 7efc22c6..0fb40dbe 100644 --- a/Rakefile +++ b/Rakefile @@ -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' @@ -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' diff --git a/jruby/neo4j/driver.rb b/jruby/neo4j/driver.rb index 441151e9..8c595220 100644 --- a/jruby/neo4j/driver.rb +++ b/jruby/neo4j/driver.rb @@ -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 @@ -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 @@ -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 diff --git a/jruby/neo4j/driver/ext/internal/cluster/routing_table_registry_impl.rb b/jruby/neo4j/driver/ext/internal/cluster/routing_table_registry_impl.rb index 28a02074..0561c474 100644 --- a/jruby/neo4j/driver/ext/internal/cluster/routing_table_registry_impl.rb +++ b/jruby/neo4j/driver/ext/internal/cluster/routing_table_registry_impl.rb @@ -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 diff --git a/jruby/neo4j/driver/ext/internal/internal_notification_common.rb b/jruby/neo4j/driver/ext/internal/internal_notification_common.rb deleted file mode 100644 index f7a9267f..00000000 --- a/jruby/neo4j/driver/ext/internal/internal_notification_common.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Neo4j - module Driver - module Ext - module Internal - module InternalNotificationCommon - def type - super.to_s - end - end - end - end - end -end diff --git a/jruby/neo4j/driver/version.rb b/jruby/neo4j/driver/version.rb index e31d0730..53b21ffc 100644 --- a/jruby/neo4j/driver/version.rb +++ b/jruby/neo4j/driver/version.rb @@ -2,6 +2,6 @@ module Neo4j module Driver - VERSION = '5.20.0.alpha.0' + VERSION = '5.27.0.alpha.0' end end diff --git a/spec/integration/causal_clustering_spec.rb b/spec/integration/causal_clustering_spec.rb index 05282c6c..fe88da70 100755 --- a/spec/integration/causal_clustering_spec.rb +++ b/spec/integration/causal_clustering_spec.rb @@ -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| @@ -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') @@ -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) @@ -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 diff --git a/spec/integration/load_csv_spec.rb b/spec/integration/load_csv_spec.rb index 608cfa13..09c1a5f0 100755 --- a/spec/integration/load_csv_spec.rb +++ b/spec/integration/load_csv_spec.rb @@ -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 diff --git a/spec/integration/session_spec.rb b/spec/integration/session_spec.rb index ae65e3b7..df955d0b 100755 --- a/spec/integration/session_spec.rb +++ b/spec/integration/session_spec.rb @@ -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 @@ -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') diff --git a/spec/integration/summary_spec.rb b/spec/integration/summary_spec.rb index 041b5a15..63d6950b 100755 --- a/spec/integration/summary_spec.rb +++ b/spec/integration/summary_spec.rb @@ -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 @@ -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 diff --git a/spec/neo4j/driver/graph_database_spec.rb b/spec/neo4j/driver/graph_database_spec.rb index 67046e08..577c50e3 100644 --- a/spec/neo4j/driver/graph_database_spec.rb +++ b/spec/neo4j/driver/graph_database_spec.rb @@ -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 diff --git a/spec/neo4j/driver/simplified_examples_spec.rb b/spec/neo4j/driver/simplified_examples_spec.rb index 1d84913d..c61e36ac 100644 --- a/spec/neo4j/driver/simplified_examples_spec.rb +++ b/spec/neo4j/driver/simplified_examples_spec.rb @@ -78,7 +78,7 @@ 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 @@ -86,7 +86,7 @@ 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 diff --git a/spec/neo4j/driver/util/cc/cluster.rb b/spec/neo4j/driver/util/cc/cluster.rb index 196cf194..c5d4cf67 100644 --- a/spec/neo4j/driver/util/cc/cluster.rb +++ b/spec/neo4j/driver/util/cc/cluster.rb @@ -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 diff --git a/testkit-backend/bin/testkit-backend b/testkit-backend/bin/testkit-backend index b23187bd..23f213bd 100755 --- a/testkit-backend/bin/testkit-backend +++ b/testkit-backend/bin/testkit-backend @@ -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 diff --git a/testkit-backend/lib/testkit/backend/messages/requests/get_features.rb b/testkit-backend/lib/testkit/backend/messages/requests/get_features.rb index 3ae0b3de..88a4fae4 100644 --- a/testkit-backend/lib/testkit/backend/messages/requests/get_features.rb +++ b/testkit-backend/lib/testkit/backend/messages/requests/get_features.rb @@ -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, diff --git a/testkit-backend/lib/testkit/backend/messages/requests/result_consume.rb b/testkit-backend/lib/testkit/backend/messages/requests/result_consume.rb index 0201bc80..fbad9060 100644 --- a/testkit-backend/lib/testkit/backend/messages/requests/result_consume.rb +++ b/testkit-backend/lib/testkit/backend/messages/requests/result_consume.rb @@ -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 diff --git a/testkit-backend/testkit-backend.gemspec b/testkit-backend/testkit-backend.gemspec index 787f0471..63059923 100644 --- a/testkit-backend/testkit-backend.gemspec +++ b/testkit-backend/testkit-backend.gemspec @@ -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"