Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sidekiq test: perms fix for inline bundled redis #2804

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
55 changes: 39 additions & 16 deletions test/multiverse/suites/sidekiq/sidekiq_with_redis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# frozen_string_literal: true

require 'bundler/inline'
require 'fileutils'

class SidekiqWithRedisTest < MiniTest::Test
#
Expand Down Expand Up @@ -36,28 +37,50 @@ class SidekiqWithRedisTest < MiniTest::Test
def test_redis_client_pipelined_calls_work
skip 'Testing conducted only using Sidekiq v7.0+ with redis not yet bundled' unless sidekiq_without_redis?

gemfile do
source 'https://rubygems.org'
begin
gemfile do
source 'https://rubygems.org'

gem 'redis', '5.0.5'
end
gem 'redis', '5.0.5'
end

require 'newrelic_rpm'
require 'newrelic_rpm'

conn = Sidekiq::RedisConnection.create
key = 'pineapple'
value = 'carrot'
result = nil
conn = Sidekiq::RedisConnection.create
key = 'pineapple'
value = 'carrot'
result = nil

conn.with do |c|
client = c.instance_variable_get(:@client)
client.pipelined do |p|
p.call_v([:set, key, value])
conn.with do |c|
client = c.instance_variable_get(:@client)
client.pipelined do |p|
p.call_v([:set, key, value])
end
result = client.call(:get, key)
end
result = client.call(:get, key)
end

assert_equal value, result
assert_equal value, result

# fix for an odd GitHub Actions based error involving Bundler's refusal to
# delete the inline-bundled gem due to gem directory permissions.
# 1) Error:
# SidekiqWithRedisTest#test_redis_client_pipelined_calls_work:
# Bundler::InstallError: Bundler::DirectoryRemovalError: Could not delete
# previous installation of `/opt/hostedtoolcache/Ruby/3.2.5/x64/lib/ruby/gems/3.2.0/gems/redis-5.0.5`.
# The underlying error was ArgumentError: parent directory is world
# writable, Bundler::FileUtils#remove_entry_secure does not work; abort:
# "/opt/hostedtoolcache/Ruby/3.2.5/x64/lib/ruby/gems/3.2.0/gems/redis-5.0.5"
# (parent directory mode 40777), with backtrace:
ensure
skip unless ENV.fetch('CI', nil)

gem_home = ENV.fetch('GEM_HOME', nil)
skip unless gem_home

Dir.glob(File.join(gem_home, '**', 'redis-5.0.5')).each do |path|
FileUtils.chmod_R(0744, path)
end
end
end

private
Expand Down
Loading