-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to test that sidekiq.yml is *correct*? #459
Comments
Another stab at this, this finally fails with the same error. 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. |
@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 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 |
Feel free to open a discussion there with all this context @hakunin! |
Hello, I had a "typo" in my
sidekiq.yml
recently which caused the rest of my jobs not being scheduled and had to redo all the oauth connections for the users.I am trying to make sure this doesn't happen again and so I wanted to test that the config does not result in any jobs skipped (missing at/every/cron..), or outright failures.
The error in my typo case was:
So I tried writing a test in all different ways but none of them produced the error above.
For example this one fails with:
But it fails regardless of that "typo"..
Ultimately I would like to validate the format is correct without having to actually create those jobs in the redis.
The text was updated successfully, but these errors were encountered: