Upgrading dependency to Thrift 0.12.0

This commit is contained in:
Renan DelValle 2018-11-27 18:03:50 -08:00
parent 3e4590dcc0
commit 356978cb42
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
1302 changed files with 101701 additions and 26784 deletions

View file

@ -2,6 +2,6 @@ source "http://rubygems.org"
require "rubygems"
gem "rack", "~> 1.5.2"
gem "thin", "~> 1.5.0"
gem "test-unit"
gem 'rack', '~> 2.0', '>= 2.0.4'
gem 'thin', '~> 1.7', '>= 1.7.2'
gem 'test-unit', '~> 3.2', '>= 3.2.7'

View file

@ -17,11 +17,10 @@
# under the License.
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
stubs: $(THRIFT) ../ThriftTest.thrift ../SmallTest.thrift
$(THRIFT) --gen rb ../ThriftTest.thrift
$(THRIFT) --gen rb ../SmallTest.thrift
$(THRIFT) --gen rb ../Recursive.thrift
precross: stubs

View file

@ -0,0 +1,41 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
require File.join(File.dirname(__FILE__), '../test_helper')
require 'recursive_types'
class TestRecursiveGeneration < Test::Unit::TestCase
CHILD_ITEM = "child item"
PARENT_ITEM = "parent item"
def test_can_create_recursive_tree
child_tree = RecTree.new
child_tree.item = CHILD_ITEM
parent_tree = RecTree.new
parent_tree.item = PARENT_ITEM
parent_tree.children = [child_tree]
assert_equal(PARENT_ITEM, parent_tree.item)
assert_equal(1, parent_tree.children.length)
assert_equal(CHILD_ITEM, parent_tree.children.first.item)
assert_nil(parent_tree.children.first.children)
end
end

View file

@ -26,35 +26,63 @@ require 'test_helper'
require 'thrift'
require 'thrift_test'
$protocolType = "binary"
$domain_socket = nil
$host = "localhost"
$port = 9090
$protocolType = "binary"
$ssl = false
$transport = "buffered"
ARGV.each do|a|
if a == "--help"
puts "Allowed options:"
puts "\t -h [ --help ] \t produce help message"
puts "\t--host arg (=localhost) \t Host to connect"
puts "\t--port arg (=9090) \t Port number to listen"
puts "\t--protocol arg (=binary) \t protocol: binary, accel"
puts "\t--domain-socket arg (=) \t Unix domain socket path"
puts "\t--host arg (=localhost) \t Host to connect \t not valid with domain-socket"
puts "\t--port arg (=9090) \t Port number to listen \t not valid with domain-socket"
puts "\t--protocol arg (=binary) \t protocol: accel, binary, compact, json"
puts "\t--ssl \t use ssl \t not valid with domain-socket"
puts "\t--transport arg (=buffered) transport: buffered, framed, http"
exit
elsif a.start_with?("--domain-socket")
$domain_socket = a.split("=")[1]
elsif a.start_with?("--host")
$host = a.split("=")[1]
elsif a.start_with?("--protocol")
$protocolType = a.split("=")[1]
elsif a == "--ssl"
$ssl = true
elsif a.start_with?("--transport")
$transport = a.split("=")[1]
elsif a.start_with?("--port")
$port = a.split("=")[1].to_i
end
end
ARGV=[]
class SimpleClientTest < Test::Unit::TestCase
def setup
unless @socket
@socket = Thrift::Socket.new($host, $port)
if $domain_socket.to_s.strip.empty?
if $ssl
# the working directory for ruby crosstest is test/rb/gen-rb
keysDir = File.join(File.dirname(File.dirname(Dir.pwd)), "keys")
ctx = OpenSSL::SSL::SSLContext.new
ctx.ca_file = File.join(keysDir, "CA.pem")
ctx.cert = OpenSSL::X509::Certificate.new(File.open(File.join(keysDir, "client.crt")))
ctx.cert_store = OpenSSL::X509::Store.new
ctx.cert_store.add_file(File.join(keysDir, 'server.pem'))
ctx.key = OpenSSL::PKey::RSA.new(File.open(File.join(keysDir, "client.key")))
ctx.options = OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
ctx.ssl_version = :SSLv23
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
@socket = Thrift::SSLSocket.new($host, $port, nil, ctx)
else
@socket = Thrift::Socket.new($host, $port)
end
else
@socket = Thrift::UNIXSocket.new($domain_socket)
end
if $transport == "buffered"
transportFactory = Thrift::BufferedTransport.new(@socket)
elsif $transport == "framed"
@ -74,7 +102,7 @@ class SimpleClientTest < Test::Unit::TestCase
else
raise 'Unknown protocol type'
end
@client = Thrift::Test::ThriftTest::Client.new(@protocol)
@client = Thrift::Test::ThriftTest::Client.new(@protocol)
@socket.open
end
end

View file

@ -106,21 +106,30 @@ class SimpleHandler
end
protocol = "binary"
domain_socket = nil
port = 9090
protocol = "binary"
@protocolFactory = nil
ssl = false
transport = "buffered"
@transportFactory = Thrift::BufferedTransportFactory.new
@protocolFactory = Thrift::BinaryProtocolFactory.new
@transportFactory = nil
ARGV.each do|a|
if a == "--help"
puts "Allowed options:"
puts "\t -h [ --help ] \t produce help message"
puts "\t--port arg (=9090) \t Port number to listen"
puts "\t--protocol arg (=binary) \t protocol: binary, accel"
puts "\t--domain-socket arg (=) \t Unix domain socket path"
puts "\t--port arg (=9090) \t Port number to listen \t not valid with domain-socket"
puts "\t--protocol arg (=binary) \t protocol: accel, binary, compact, json"
puts "\t--ssl \t use ssl \t not valid with domain-socket"
puts "\t--transport arg (=buffered) transport: buffered, framed, http"
exit
elsif a.start_with?("--domain-socket")
domain_socket = a.split("=")[1]
elsif a.start_with?("--protocol")
protocol = a.split("=")[1]
elsif a == "--ssl"
ssl = true
elsif a.start_with?("--transport")
transport = a.split("=")[1]
elsif a.start_with?("--port")
@ -128,9 +137,7 @@ ARGV.each do|a|
end
end
if protocol == "binary"
@protocolFactory = Thrift::BinaryProtocolFactory.new
elsif protocol == ""
if protocol == "binary" || protocol.to_s.strip.empty?
@protocolFactory = Thrift::BinaryProtocolFactory.new
elsif protocol == "compact"
@protocolFactory = Thrift::CompactProtocolFactory.new
@ -142,9 +149,7 @@ else
raise 'Unknown protocol type'
end
if transport == "buffered"
@transportFactory = Thrift::BufferedTransportFactory.new
elsif transport == ""
if transport == "buffered" || transport.to_s.strip.empty?
@transportFactory = Thrift::BufferedTransportFactory.new
elsif transport == "framed"
@transportFactory = Thrift::FramedTransportFactory.new
@ -152,8 +157,32 @@ else
raise 'Unknown transport type'
end
@handler = SimpleHandler.new
@handler = SimpleHandler.new
@processor = Thrift::Test::ThriftTest::Processor.new(@handler)
@transport = Thrift::ServerSocket.new(port)
@server = Thrift::ThreadedServer.new(@processor, @transport, @transportFactory, @protocolFactory)
@transport = nil
if domain_socket.to_s.strip.empty?
if ssl
# the working directory for ruby crosstest is test/rb/gen-rb
keysDir = File.join(File.dirname(File.dirname(Dir.pwd)), "keys")
ctx = OpenSSL::SSL::SSLContext.new
ctx.ca_file = File.join(keysDir, "CA.pem")
ctx.cert = OpenSSL::X509::Certificate.new(File.open(File.join(keysDir, "server.crt")))
ctx.cert_store = OpenSSL::X509::Store.new
ctx.cert_store.add_file(File.join(keysDir, 'client.pem'))
ctx.key = OpenSSL::PKey::RSA.new(File.open(File.join(keysDir, "server.key")))
ctx.options = OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
ctx.ssl_version = :SSLv23
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
@transport = Thrift::SSLServerSocket.new(nil, port, ctx)
else
@transport = Thrift::ServerSocket.new(port)
end
else
@transport = Thrift::UNIXServerSocket.new(domain_socket)
end
@server = Thrift::ThreadedServer.new(@processor, @transport, @transportFactory, @protocolFactory)
puts "Starting TestServer #{@server.to_s}"
@server.serve
puts "done."