diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 21:07:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 21:07:42 +0300 |
commit | 7b52c7cb634ef7047d30b0337fe477bcdcedf41d (patch) | |
tree | 374ca9e908204488422046f10e340d1500780362 /spec/lib/gitlab/sidekiq_logging | |
parent | b375c6c05fbd03aea33a9ee9f82e678bdaa8c3cc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/sidekiq_logging')
-rw-r--r-- | spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb index f294d7f7fcd..bd04d30f85f 100644 --- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb +++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb @@ -11,7 +11,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do let(:job) do { "class" => "TestWorker", - "args" => [1234, 'hello'], + "args" => [1234, 'hello', { 'key' => 'value' }], "retry" => false, "queue" => "cronjob:test_queue", "queue_namespace" => "cronjob", @@ -30,6 +30,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do let(:clock_thread_cputime_end) { 1.333333799 } let(:start_payload) do job.except('error_backtrace', 'error_class', 'error_message').merge( + 'args' => %w(1234 hello {"key"=>"value"}), 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: start', 'job_status' => 'start', 'pid' => Process.pid, @@ -99,13 +100,27 @@ describe Gitlab::SidekiqLogging::StructuredLogger do end end + it 'does not modify the job' do + Timecop.freeze(timestamp) do + job_copy = job.deep_dup + + allow(logger).to receive(:info) + allow(subject).to receive(:log_job_start).and_call_original + allow(subject).to receive(:log_job_done).and_call_original + + subject.call(job, 'test_queue') do + expect(job).to eq(job_copy) + end + end + end + context 'when the job args are bigger than the maximum allowed' do it 'keeps args from the front until they exceed the limit' do Timecop.freeze(timestamp) do half_limit = Gitlab::Utils::LogLimitedArray::MAXIMUM_ARRAY_LENGTH / 2 job['args'] = [1, 2, 'a' * half_limit, 'b' * half_limit, 3] - expected_args = job['args'].take(3) + ['...'] + expected_args = job['args'].take(3).map(&:to_s) + ['...'] expect(logger).to receive(:info).with(start_payload.merge('args' => expected_args)).ordered expect(logger).to receive(:info).with(end_payload.merge('args' => expected_args)).ordered |