このコミットが含まれているのは:
@@ -37,7 +37,6 @@ RSpec.describe 'Counts export contracts' do
|
||||
block.call(page)
|
||||
end
|
||||
allow(CountsTableQuery).to receive(:new).and_return(query)
|
||||
allow(ApplicationRecord).to receive(:transaction).with(isolation: :repeatable_read).and_yield
|
||||
end
|
||||
|
||||
it 'reports aggregation, actual output progress and regular-row metadata' do
|
||||
@@ -175,11 +174,15 @@ end
|
||||
RSpec.describe 'Counts download acknowledgement' do
|
||||
around do |example|
|
||||
Dir.mktmpdir('counts-ack-spec') do |path|
|
||||
allow(CountsExportDownload).to receive(:directory).and_return(Pathname.new(path))
|
||||
@counts_ack_dir = Pathname.new(path)
|
||||
HistoryAccess.set(user: nil) { example.run }
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
allow(CountsExportDownload).to receive(:directory).and_return(@counts_ack_dir)
|
||||
end
|
||||
|
||||
it 'binds an acknowledgement to the owner, job, file token and fresh attempt' do
|
||||
CountsExportJobs.pulse
|
||||
payload = { 'resource' => 'posts', 'definition' => 'history', 'mode' => 'details',
|
||||
|
||||
@@ -132,11 +132,14 @@ RSpec.describe 'Counts masked pivot contracts' do
|
||||
|
||||
it 'rejects private predicates and supplied measure coordinates before SQL labels escape' do
|
||||
probes = [{ 'resource_id' => PostVersion.first.post_id.to_s },
|
||||
{ 'tags' => 'A' }, { 'tag_refs.0.name' => 'A', 'tag_refs.0.tag_id' => tags.first.id.to_s },
|
||||
{ 'conditions.0.field' => 'title', 'conditions.0.operator' => 'eq',
|
||||
{ 'tags' => 'A' },
|
||||
{ 'tag_refs' => '', 'tag_refs.0.name' => 'A', 'tag_refs.0.tag_id' => tags.first.id.to_s },
|
||||
{ 'conditions' => '', 'conditions.0.field' => 'title', 'conditions.0.operator' => 'eq',
|
||||
'conditions.0.value' => 'hidden-title-0' },
|
||||
{ 'drill.0.field' => 'tags', 'drill.0.value' => "internal:#{ tags.first.id }" },
|
||||
{ 'cols' => 'tags', 'column_order.0.value' => CountsAxes::MASKED_VALUE }]
|
||||
{ 'drill' => '', 'drill.0.field' => 'tags', 'drill.0.value_type' => 'string',
|
||||
'drill.0.value' => "internal:#{ tags.first.id }" },
|
||||
{ 'cols' => 'tags', 'column_order' => '', 'column_order.0.value_type' => 'string',
|
||||
'column_order.0.value' => CountsAxes::MASKED_VALUE }]
|
||||
HistoryAccess.set(user: nil) do
|
||||
probes.each do |probe|
|
||||
expect { CountsTableQuery.new(params.merge(probe)) }
|
||||
@@ -148,6 +151,7 @@ RSpec.describe 'Counts masked pivot contracts' do
|
||||
it 'keeps public column sorting usable while guessed private coordinates match nothing' do
|
||||
first = result(nil, 'rows' => 'event_type', 'cols' => 'tags')
|
||||
probe = result(nil, 'rows' => 'event_type', 'cols' => 'tags',
|
||||
'column_order' => '', 'column_order.0.value_type' => 'string',
|
||||
'column_order.0.value' => "internal:#{ tags.first.id }")
|
||||
expect(probe[:column_values]).to eq(first[:column_values])
|
||||
expect(probe[:cells]).to eq(first[:cells])
|
||||
|
||||
@@ -8,6 +8,10 @@ RSpec.describe 'Shared resource IDs across MySQL connections', type: :model do
|
||||
expect(Rails.env.test?).to be(true)
|
||||
expect(ApplicationRecord.connection.adapter_name).to match(/mysql/i)
|
||||
expect(ApplicationRecord.connection_pool.size).to be >= 3
|
||||
@main_connection = ApplicationRecord.connection
|
||||
# A leaked fixture pin makes worker threads share the main session. Fail before
|
||||
# starting a worker rather than diagnosing IS_USED_LOCK(NULL) after a timeout.
|
||||
expect(@main_connection.open_transactions).to eq(0)
|
||||
@prefix = "shared_ids_#{ SecureRandom.hex(8) }"
|
||||
@tag = create(:tag, primary_name: "#{ @prefix }_owner")
|
||||
@group = TagGroup.create!(name: "#{ @prefix }_owner", version_no: 1)
|
||||
@@ -42,13 +46,20 @@ RSpec.describe 'Shared resource IDs across MySQL connections', type: :model do
|
||||
end
|
||||
|
||||
def await_queue queue
|
||||
Timeout.timeout(15) { queue.pop }
|
||||
value = Timeout.timeout(15) { queue.pop }
|
||||
raise value if value.is_a?(Exception)
|
||||
|
||||
value
|
||||
end
|
||||
|
||||
def worker &block
|
||||
Thread.new do
|
||||
Thread.current.report_on_exception = false
|
||||
ApplicationRecord.connection_pool.with_connection(&block)
|
||||
ApplicationRecord.connection_pool.with_connection do |connection|
|
||||
raise 'Shared ID worker reused the main connection' if connection.equal?(@main_connection)
|
||||
|
||||
block.call(connection)
|
||||
end
|
||||
end.tap { @threads << _1 }
|
||||
end
|
||||
|
||||
@@ -86,11 +97,16 @@ RSpec.describe 'Shared resource IDs across MySQL connections', type: :model do
|
||||
ActiveSupport::Notifications.subscribed(subscriber, 'sql.active_record') do
|
||||
id = create_resource(kind).id
|
||||
end
|
||||
raise 'Shared ID creation did not acquire a named lock' unless lock_name
|
||||
|
||||
ready << [id, connection.select_value('SELECT CONNECTION_ID()').to_i, lock_name]
|
||||
await_queue(@release)
|
||||
raise ActiveRecord::Rollback if rollback
|
||||
end
|
||||
id
|
||||
rescue StandardError => error
|
||||
ready << error
|
||||
raise
|
||||
end
|
||||
[thread, await_queue(ready)]
|
||||
end
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする