Code Monkey home page Code Monkey logo

Comments (3)

hakunin avatar hakunin commented on June 21, 2024 2

Another stab at this, this finally fails with the same error.
A bit dirty (knows too much) but good start for now.

RSpec.describe 'Sidekiq Scheduler config' do
  let(:config_path) { Rails.root.join('config', 'sidekiq.yml') }
  let(:config) { YAML.load_file(config_path) }
  let(:jobs) { config.dig(:scheduler, :schedule) }

  let(:scheduler_config) { SidekiqScheduler::Config.new(sidekiq_config: {}) }
  let(:scheduler) { SidekiqScheduler::Scheduler.new(scheduler_config) }

  # to silence the logger
  let(:sidekiq_config) { Sidekiq.instance_variable_get('@config') }

  before do
    # silence the logging
    @original_logger = sidekiq_config.logger
    sidekiq_config.logger = ::Logger.new("/dev/null")

    # some setup was skipped and this was nil
    scheduler.instance_variable_set('@scheduled_jobs', {})

    # prevent jobs from being actually enqueued
    allow(scheduler).to receive(:idempotent_job_enqueue)
  end

  after do
    sidekiq_config.logger = @original_logger
  end

  it 'loads the sidekiq configuration for each job without errors' do
    jobs.each do |job_name, job_config|
      expect {
        scheduler.load_schedule_job(job_name, job_config)
      }.not_to raise_error
    end
  end

  it 'test that all classes exist' do
    jobs.each do |job_name, job_config|
      expect { job_config["class"].constantize }.not_to raise_error
    end
  end
end

This also checks that the classes are "loadable" since Sidekiq Scheduler doesn't fail on that when I stubbed the enqueue method.

from sidekiq-scheduler.

marcelolx avatar marcelolx commented on June 21, 2024

@hakunin I haven't worked with rspec and sidekiq-scheduler for some time now, so I don't think I am the best person to suggest how to test a sidekiq.yml — what I can say is that in the previous places we used it, we didn't test it at all, because we usually had some monitoring on the scheduled jobs to make sure they are running when we expected them to run (Sentry Crons is an example)

All that said, I set up discussions on this repo, so things like this can be discussed by the community there https://github.com/sidekiq-scheduler/sidekiq-scheduler/discussions

from sidekiq-scheduler.

marcelolx avatar marcelolx commented on June 21, 2024

Feel free to open a discussion there with all this context @hakunin!

from sidekiq-scheduler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.