Skip to content

Commit

Permalink
Merge #118501
Browse files Browse the repository at this point in the history
118501: roachtest: fix ports in ruby-pg helper r=rafiss a=rafiss

The test suite needs this logic so that certain tests work correctly.

fixes #118499
Release note: None

Co-authored-by: Rafi Shamim <[email protected]>
  • Loading branch information
craig[bot] and rafiss committed Feb 1, 2024
2 parents 420c8b2 + a49cf8f commit cc4fdff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
10 changes: 1 addition & 9 deletions pkg/cmd/roachtest/tests/ruby_pg_blocklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ var rubyPGBlocklist = blocklist{
`PG::Connection multinationalization support handles clearing result in or after set_notice_receiver`: "unknown",
`PG::Connection multinationalization support receives properly encoded messages in the notice callbacks`: "unknown",
`PG::Connection multinationalization support receives properly encoded text from wait_for_notify`: "unknown",
`PG::Connection multinationalization support respect and convert character encoding of input strings should convert error string to #put_copy_end`: "unknown",
`PG::Connection multinationalization support respect and convert character encoding of input strings should convert query string and parameters to #exec_params`: "unknown",
`PG::Connection multinationalization support respect and convert character encoding of input strings should convert query string and parameters to #send_query_params`: "unknown",
`PG::Connection multinationalization support respect and convert character encoding of input strings should convert strings and parameters to #prepare and #exec_prepared`: "unknown",
Expand Down Expand Up @@ -111,7 +110,6 @@ var rubyPGBlocklist = blocklist{
`PG::Connection#copy_data gracefully handle SQL statements while in #copy_data for input`: "unknown",
`PG::Connection#copy_data gracefully handle SQL statements while in #copy_data for output`: "unknown",
`PG::Connection#discard_results returns false on connection failures`: "unknown",
`PG::Connection#inspect should print host, port and user of a fresh connection, but not more`: "unknown",
`PG::Connection#inspect should tell about non UTF8 client encoding`: "unknown",
`PG::Connection#transaction automatically rolls back a transaction if an exception is raised`: "unknown",
`PG::Connection#transaction commits even if the block includes an early break/return`: "unknown",
Expand Down Expand Up @@ -158,6 +156,7 @@ var rubyPGBlocklist = blocklist{
`running with sync_* methods PG::Connection multinationalization support handles clearing result in or after set_notice_receiver`: "unknown",
`running with sync_* methods PG::Connection multinationalization support receives properly encoded messages in the notice callbacks`: "unknown",
`running with sync_* methods PG::Connection multinationalization support receives properly encoded text from wait_for_notify`: "unknown",
`running with sync_* methods PG::Connection multinationalization support respect and convert character encoding of input strings should convert error string to #put_copy_end`: "unknown",
`running with sync_* methods PG::Connection multinationalization support respect and convert character encoding of input strings should convert query string and parameters to #exec_params`: "unknown",
`running with sync_* methods PG::Connection multinationalization support respect and convert character encoding of input strings should convert query string and parameters to #send_query_params`: "unknown",
`running with sync_* methods PG::Connection multinationalization support respect and convert character encoding of input strings should convert strings and parameters to #prepare and #exec_prepared`: "unknown",
Expand Down Expand Up @@ -187,22 +186,15 @@ var rubyPGBlocklist = blocklist{
`running with sync_* methods PG::Connection type casting with default result type map should work with arbitrary number of params in conjunction with type casting`: "unknown",
`running with sync_* methods PG::Connection with async established connection provides the server generated error message`: "unknown",
`running with sync_* methods PG::Connection with multiple PostgreSQL servers honors target_session_attrs requirements`: "unknown",
`running with sync_* methods PG::Connection#copy_data can handle client errors after all data is consumed in #copy_data for output`: "unknown",
`running with sync_* methods PG::Connection#copy_data can handle client errors in #copy_data for input`: "unknown",
`running with sync_* methods PG::Connection#copy_data can handle client errors in #copy_data for output`: "unknown",
`running with sync_* methods PG::Connection#copy_data can handle incomplete #copy_data output queries`: "unknown",
`running with sync_* methods PG::Connection#copy_data can handle server errors in #copy_data for input`: "unknown",
`running with sync_* methods PG::Connection#copy_data can handle server errors in #copy_data for output`: "unknown",
`running with sync_* methods PG::Connection#copy_data can process #copy_data input queries`: "unknown",
`running with sync_* methods PG::Connection#copy_data can process #copy_data input queries with lots of data`: "unknown",
`running with sync_* methods PG::Connection#copy_data can process #copy_data output queries`: "unknown",
`running with sync_* methods PG::Connection#copy_data doesn't lose client error when #copy_data can not be finished`: "unknown",
`running with sync_* methods PG::Connection#copy_data gracefully handle SQL statements while in #copy_data for input`: "unknown",
`running with sync_* methods PG::Connection#copy_data gracefully handle SQL statements while in #copy_data for output`: "unknown",
`running with sync_* methods PG::Connection#copy_data should raise an error for non copy statements in #copy_data`: "unknown",
`running with sync_* methods PG::Connection#discard_results discards previous results`: "unknown",
`running with sync_* methods PG::Connection#discard_results returns false on connection failures`: "unknown",
`running with sync_* methods PG::Connection#inspect should print host, port and user of a fresh connection, but not more`: "unknown",
`running with sync_* methods PG::Connection#inspect should tell about non UTF8 client encoding`: "unknown",
`running with sync_* methods PG::Connection#transaction automatically rolls back a transaction if an exception is raised`: "unknown",
`running with sync_* methods PG::Connection#transaction commits even if the block includes an early break/return`: "unknown",
Expand Down
20 changes: 20 additions & 0 deletions pkg/cmd/roachtest/tests/ruby_pg_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ def self::included( mod )
@conninfo = $pg_server.conninfo
@unix_socket = $pg_server.unix_socket
@conn = $pg_server.connect

# Find a local port that is not in use
@port_down = @port + 10
loop do
@port_down = @port_down + 1
begin
TCPSocket.new("::1", @port_down)
rescue SystemCallError
begin
TCPSocket.new("127.0.0.1", @port_down)
rescue SystemCallError
break
end
end
end
end

mod.around( :each ) do |example|
Expand All @@ -52,6 +67,11 @@ def self::included( mod )
end
@conn.exit_pipeline_mode
end
@conn.setnonblocking false
@conn.type_map_for_results = PG::TypeMapAllStrings.new
@conn.type_map_for_queries = PG::TypeMapAllStrings.new
@conn.encoder_for_put_copy_data = nil
@conn.decoder_for_get_copy_data = nil
@conn.exec( 'ROLLBACK' ) unless example.metadata[:without_transaction]
end
end
Expand Down

0 comments on commit cc4fdff

Please sign in to comment.