From 4fc4c81d8c8db1a31c214471a79626904fc8eaa7 Mon Sep 17 00:00:00 2001 From: Dmytro Shteflyuk Date: Wed, 19 Nov 2025 19:41:05 -0500 Subject: [PATCH] Enable cross tests for Ruby library --- .github/workflows/build.yml | 33 ++++++++++- test/known_failures_Linux.json | 56 +++++++++++++++++++ .../core/test_accelerated_binary_protocol.rb | 29 ++++++++++ test/rb/core/transport/test_transport.rb | 5 +- test/rb/integration/TestServer.rb | 9 ++- 5 files changed, 123 insertions(+), 9 deletions(-) create mode 100644 test/rb/core/test_accelerated_binary_protocol.rb diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 19a3dc053a0..23bdbfcbf55 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -809,6 +809,21 @@ jobs: - name: Run make check for test/rb run: make -C test/rb check + - name: Run make precross for ruby test + run: make -C test/rb precross + + - name: Upload ruby precross artifacts + # has to match the version used in cross-test + if: matrix.ruby-version == '2.7' && matrix.skip-build-ext == false + uses: actions/upload-artifact@v5 + with: + name: rb-precross + if-no-files-found: error + path: | + test/rb/gen-rb/* + lib/rb/ext/*.so + retention-days: 3 + cross-test: needs: - lib-java-kotlin @@ -817,14 +832,15 @@ jobs: - lib-go - lib-python - lib-cpp + - lib-ruby runs-on: ubuntu-24.04 strategy: matrix: # swift is currently broken and no maintainers around -> see THRIFT-5864 # kotlin cross test are failing -> see THRIFT-5879 - server_lang: ['java', 'go', 'rs', 'cpp', 'py'] + server_lang: ['java', 'go', 'rs', 'cpp', 'py', 'rb'] # we always use comma join as many client langs as possible, to reduce the number of jobs - client_lang: ['java,kotlin', 'go,rs,cpp', 'py'] + client_lang: ['java,kotlin', 'go,rs,cpp', 'py', 'rb'] fail-fast: false steps: - uses: actions/checkout@v6 @@ -845,6 +861,12 @@ jobs: java-version: 8 cache: "gradle" + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "2.7" + bundler-cache: true + working-directory: test/rb + - name: Install openssl and certificates (for SSL tests) run: | sudo apt-get update -yq @@ -897,6 +919,12 @@ jobs: name: py-precross path: . + - name: Download ruby precross artifacts + uses: actions/download-artifact@v6 + with: + name: rb-precross + path: . + - name: Set back executable flags run: | chmod a+x lib/java/build/run* @@ -909,6 +937,7 @@ jobs: chmod a+x test/cpp/.libs/* chmod a+x lib/cpp/.libs/*.so chmod a+x test/py/*.py + chmod a+x lib/rb/ext/*.so - name: Create tmp domain socket folder run: mkdir /tmp/v0.16 diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json index be623cba5aa..334065630dc 100644 --- a/test/known_failures_Linux.json +++ b/test/known_failures_Linux.json @@ -1437,6 +1437,48 @@ "py-py_multij_framed-ip-ssl", "py-py_multij_http-ip-ssl", "py-py_multij_zlib-ip-ssl", + "py-rb_accel-binary_buffered-domain", + "py-rb_accel-binary_buffered-ip", + "py-rb_accel-binary_buffered-ip-ssl", + "py-rb_accel-binary_framed-domain", + "py-rb_accel-binary_framed-ip", + "py-rb_accel-binary_framed-ip-ssl", + "py-rb_accel_buffered-domain", + "py-rb_accel_buffered-ip", + "py-rb_accel_buffered-ip-ssl", + "py-rb_accel_framed-domain", + "py-rb_accel_framed-ip", + "py-rb_accel_framed-ip-ssl", + "py-rb_accelc-compact_buffered-domain", + "py-rb_accelc-compact_buffered-ip", + "py-rb_accelc-compact_buffered-ip-ssl", + "py-rb_accelc-compact_framed-domain", + "py-rb_accelc-compact_framed-ip", + "py-rb_accelc-compact_framed-ip-ssl", + "py-rb_binary-accel_buffered-domain", + "py-rb_binary-accel_buffered-ip", + "py-rb_binary-accel_buffered-ip-ssl", + "py-rb_binary-accel_framed-domain", + "py-rb_binary-accel_framed-ip", + "py-rb_binary-accel_framed-ip-ssl", + "py-rb_binary_buffered-domain", + "py-rb_binary_buffered-ip", + "py-rb_binary_buffered-ip-ssl", + "py-rb_binary_framed-domain", + "py-rb_binary_framed-ip", + "py-rb_binary_framed-ip-ssl", + "py-rb_compact_buffered-domain", + "py-rb_compact_buffered-ip", + "py-rb_compact_buffered-ip-ssl", + "py-rb_compact_framed-domain", + "py-rb_compact_framed-ip", + "py-rb_compact_framed-ip-ssl", + "py-rb_json_buffered-domain", + "py-rb_json_buffered-ip", + "py-rb_json_buffered-ip-ssl", + "py-rb_json_framed-domain", + "py-rb_json_framed-ip", + "py-rb_json_framed-ip-ssl", "py-rs_accel-binary_buffered-domain", "py-rs_accel-binary_buffered-ip", "py-rs_accel-binary_framed-domain", @@ -1507,6 +1549,20 @@ "rb-netstd_json_buffered-ip-ssl", "rb-netstd_json_framed-ip", "rb-netstd_json_framed-ip-ssl", + "rb-py_accel-binary_buffered-ip-ssl", + "rb-py_accel-binary_framed-ip-ssl", + "rb-py_accel_buffered-ip-ssl", + "rb-py_accel_framed-ip-ssl", + "rb-py_binary-accel_buffered-ip-ssl", + "rb-py_binary-accel_framed-ip-ssl", + "rb-py_binary_buffered-ip-ssl", + "rb-py_binary_framed-ip-ssl", + "rb-py_compact-accelc_buffered-ip-ssl", + "rb-py_compact-accelc_framed-ip-ssl", + "rb-py_compact_buffered-ip-ssl", + "rb-py_compact_framed-ip-ssl", + "rb-py_json_buffered-ip-ssl", + "rb-py_json_framed-ip-ssl", "rs-netstd_binary_buffered-ip", "rs-netstd_binary_framed-ip", "rs-netstd_compact_buffered-ip", diff --git a/test/rb/core/test_accelerated_binary_protocol.rb b/test/rb/core/test_accelerated_binary_protocol.rb new file mode 100644 index 00000000000..7e1d9d6bec3 --- /dev/null +++ b/test/rb/core/test_accelerated_binary_protocol.rb @@ -0,0 +1,29 @@ +# +# 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 'thrift' + +class TestThriftTransport < Test::Unit::TestCase + def test_accelerated_protocol + return if ENV['SKIP_BUILD_EXT'] == '1' + assert defined?(Thrift::BinaryProtocolAccelerated) + end +end diff --git a/test/rb/core/transport/test_transport.rb b/test/rb/core/transport/test_transport.rb index 37afa858b3d..d5967cba94b 100644 --- a/test/rb/core/transport/test_transport.rb +++ b/test/rb/core/transport/test_transport.rb @@ -20,14 +20,15 @@ require File.join(File.dirname(__FILE__), '../../test_helper') require 'thrift' +require 'stringio' class DummyTransport < Thrift::BaseTransport def initialize(data) - @data = data + @data = StringIO.new(data) end def read(size) - @data.slice!(0, size) + @data.read(size) end end diff --git a/test/rb/integration/TestServer.rb b/test/rb/integration/TestServer.rb index 3debaa304b4..afa6c2db21f 100755 --- a/test/rb/integration/TestServer.rb +++ b/test/rb/integration/TestServer.rb @@ -133,7 +133,7 @@ def testOneway(arg0) elsif a.start_with?("--transport") transport = a.split("=")[1] elsif a.start_with?("--port") - port = a.split("=")[1].to_i + port = a.split("=")[1].to_i end end @@ -166,12 +166,11 @@ def testOneway(arg0) 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 = OpenSSL::X509::Certificate.new(File.binread(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.key = OpenSSL::PKey::RSA.new(File.binread(File.join(keysDir, "server.key"))) + ctx.min_version = :TLS1_2 ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER @transport = Thrift::SSLServerSocket.new(nil, port, ctx) else