Sha256: a5d405358043165d49744414e254149be9c0df733307b0ffd681650cc00072ca

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 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

4 entries across 4 versions & 1 rubygems

Version Path
marty-2.5.7 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.5.6 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.5.5 spec/other/diagnostic/delayed_job_workers_spec.rb
marty-2.5.4 spec/other/diagnostic/delayed_job_workers_spec.rb