Skip to content

Commit be01344

Browse files
test: Add workaround for windows test failure (#1751)
We have to instantiate the processor outside of the stub so that the stub can be applied to the processor, but the method we're stubbing runs on initialization, so we sometimes run out of expectations. If we explicitly set 'OTEL_RUBY_BLRP_START_THREAD_ON_BOOT' to 'false' for the 'removes the older log records from the batch if full' test, the stubbed `work` method will not run outside of the stub block. Co-authored-by: Tanna McClure <[email protected]>
1 parent 555b062 commit be01344

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

logs_sdk/test/opentelemetry/sdk/logs/export/batch_log_record_processor_test.rb

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,23 @@ def to_log_record_data
186186
end
187187

188188
it 'removes the older log records from the batch if full' do
189-
processor = BatchLogRecordProcessor.new(TestExporter.new, max_queue_size: 1, max_export_batch_size: 1)
189+
# Windows intermittently fails if we don't set this
190+
OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_BLRP_START_THREAD_ON_BOOT' => 'false') do
191+
processor = BatchLogRecordProcessor.new(TestExporter.new, max_queue_size: 1, max_export_batch_size: 1)
190192

191-
# Don't actually try to export, we're looking at the log records array
192-
processor.stub(:work, nil) do
193-
older_log_record = TestLogRecord.new
194-
newest_log_record = TestLogRecord.new
193+
# Don't actually try to export, we're looking at the log records array
194+
processor.stub(:work, nil) do
195+
older_log_record = TestLogRecord.new
196+
newest_log_record = TestLogRecord.new
195197

196-
processor.on_emit(older_log_record, mock_context)
197-
processor.on_emit(newest_log_record, mock_context)
198+
processor.on_emit(older_log_record, mock_context)
199+
processor.on_emit(newest_log_record, mock_context)
198200

199-
records = processor.instance_variable_get(:@log_records)
201+
records = processor.instance_variable_get(:@log_records)
200202

201-
assert_includes(records, newest_log_record)
202-
refute_includes(records, older_log_record)
203+
assert_includes(records, newest_log_record)
204+
refute_includes(records, older_log_record)
205+
end
203206
end
204207
end
205208

0 commit comments

Comments
 (0)