Sha256: 1623e31b964cc226c7c343145ee48d141681a5aaba8119019540c8595cc32221

Contents?: true

Size: 1.16 KB

Versions: 25

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'
require 'job_helper'

describe Marty::Diagnostic::DelayedJobWorkers do
  def sample_data ip=nil, error=false
    {
      ip || Marty::Helper.my_ip => {
        'Delayed Workers / Node' => {
          'description' => error ? "3" : "4",
          'status'      => true,
          'consistent'  => nil
        },
      }
    }
  end

  def sample_aggregate error=false
    [
      sample_data(ip='0.0.0.0'),
      sample_data(ip='0.0.0.1'),
      sample_data(ip='0.0.0.2', error=error),
      sample_data(ip='0.0.0.3'),
    ].reduce(:merge)
  end

  it 'can determine the number of workers on a node' do
    start_delayed_job
    expect(described_class.generate).to eq(sample_data)
    stop_delayed_job
  end

  it 'can determine if there are nodes with missing workers' do
    consistent   = sample_aggregate
    inconsistent = sample_aggregate(error=true)

    expect(described_class.consistent?(consistent)).to eq(true)
    expect(described_class.consistent?(inconsistent)).to eq(false)
  end

  it 'recognizes zero workers as an error' do
    data = described_class.generate.values[0]
    expect(data['Delayed Workers / Node']['status']).to eq(false)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
marty-2.5.2 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.5.1 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.5.0 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.9 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.8 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.7 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.6 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.5 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.4 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.3 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.2 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.1 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.4.0 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.3.15 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.3.14 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.3.13 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.3.12 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.3.11 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.3.10 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.3.9 spec/other/diagnostic/delayed_job_workers_spec.rb