Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
files = []
# prefer git-tracked files when available (local dev), but also pick up built files present on disk (CI)
files += `git ls-files -z`.split("\x0") if system("git rev-parse --is-inside-work-tree > /dev/null 2>&1")
files += `git ls-files -z`.split("\x0") if system("git rev-parse --is-inside-work-tree > #{File::NULL} 2>&1")

# include any built native libs (CI places them under lib/spannerlib/)
files += Dir.glob("lib/spannerlib/**/*").select { |f| File.file?(f) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require "google/cloud/spanner/v1/spanner"
require "timeout"
require "tmpdir"
require "socket"

require_relative "mock_server/statement_result"
require_relative "../lib/spannerlib/ffi"
Expand Down Expand Up @@ -94,7 +95,15 @@ def self.wait_for_port

if File.exist?($port_file)
content = File.read($port_file).strip
return content.to_i unless content.empty?
unless content.empty?
port = content.to_i
begin
Socket.tcp("127.0.0.1", port, connect_timeout: 0.1) { nil }
return port
rescue SystemCallError
# Server not yet fully listening
end
Comment thread
olavloite marked this conversation as resolved.
end
end

raise "Mock server exited unexpectedly!" if Process.waitpid($server_pid, Process::WNOHANG)
Expand Down Expand Up @@ -170,7 +179,7 @@ def find_transaction_options(requests)
before do
self.class.ensure_server_running!
File.binwrite($mock_msg_file, Marshal.dump({}))
File.write($mock_req_file, "")
File.binwrite($mock_req_file, "")
@dsn = "127.0.0.1:#{$server_port}/projects/p/instances/i/databases/d?useplaintext=true"

@pool_id = SpannerLib.create_pool(@dsn)
Expand Down
Loading