mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Add que data migration & move CsyncJob to AppilcationJob
This commit is contained in:
parent
7210140de6
commit
83706a78e3
3 changed files with 25 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CsyncJob < Que::Job
|
class CsyncJob < ApplicationJob
|
||||||
def run(generate: false)
|
def perform(generate: false)
|
||||||
@store = {}
|
@store = {}
|
||||||
@input_store = { secure: {}, insecure: {} }
|
@input_store = { secure: {}, insecure: {} }
|
||||||
@results = {}
|
@results = {}
|
||||||
|
|
17
db/data/20210405081552_migrate_que_jobs.rb
Normal file
17
db/data/20210405081552_migrate_que_jobs.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class MigrateQueJobs < ActiveRecord::Migration[6.0]
|
||||||
|
def up
|
||||||
|
QueJob.all.each do |job|
|
||||||
|
next if job.last_error.present?
|
||||||
|
|
||||||
|
klass = job.job_class.constantize
|
||||||
|
next unless klass < ApplicationJob
|
||||||
|
|
||||||
|
args = job.args
|
||||||
|
klass.perform_later(args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration
|
||||||
|
end
|
||||||
|
end
|
|
@ -14,14 +14,14 @@ class CsyncJobTest < ActiveSupport::TestCase
|
||||||
expected_contents = "[secure]\nns1.bestnames.test shop.test\nns2.bestnames.test shop.test\n" \
|
expected_contents = "[secure]\nns1.bestnames.test shop.test\nns2.bestnames.test shop.test\n" \
|
||||||
"[insecure]\nns1.bestnames.test airport.test metro.test\nns2.bestnames.test airport.test\n"
|
"[insecure]\nns1.bestnames.test airport.test metro.test\nns2.bestnames.test airport.test\n"
|
||||||
|
|
||||||
CsyncJob.run(generate: true)
|
CsyncJob.perform_now(generate: true)
|
||||||
|
|
||||||
assert_equal expected_contents, IO.read(ENV['cdns_scanner_input_file'])
|
assert_equal expected_contents, IO.read(ENV['cdns_scanner_input_file'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_csync_record_when_new_cdnskey_discovered
|
def test_creates_csync_record_when_new_cdnskey_discovered
|
||||||
assert_nil @domain.csync_record
|
assert_nil @domain.csync_record
|
||||||
CsyncJob.run
|
CsyncJob.perform_now
|
||||||
|
|
||||||
@domain.reload
|
@domain.reload
|
||||||
assert @domain.csync_record
|
assert @domain.csync_record
|
||||||
|
@ -35,7 +35,7 @@ class CsyncJobTest < ActiveSupport::TestCase
|
||||||
def test_creates_dnskey_after_required_cycles
|
def test_creates_dnskey_after_required_cycles
|
||||||
assert_equal 0, @domain.dnskeys.count
|
assert_equal 0, @domain.dnskeys.count
|
||||||
assert_nil @domain.csync_record
|
assert_nil @domain.csync_record
|
||||||
CsyncJob.run # Creates initial CsyncRecord for domain
|
CsyncJob.perform_now # Creates initial CsyncRecord for domain
|
||||||
|
|
||||||
@domain.reload
|
@domain.reload
|
||||||
assert @domain.csync_record.present?
|
assert @domain.csync_record.present?
|
||||||
|
@ -46,7 +46,7 @@ class CsyncJobTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
CsyncRecord.stub :by_domain_name, @domain.csync_record do
|
CsyncRecord.stub :by_domain_name, @domain.csync_record do
|
||||||
@domain.csync_record.stub :dnssec_validates?, true do
|
@domain.csync_record.stub :dnssec_validates?, true do
|
||||||
CsyncJob.run
|
CsyncJob.perform_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,13 +58,13 @@ class CsyncJobTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_sends_mail_to_contacts_if_dnskey_updated
|
def test_sends_mail_to_contacts_if_dnskey_updated
|
||||||
assert_emails 1 do
|
assert_emails 1 do
|
||||||
CsyncJob.run
|
CsyncJob.perform_now
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
CsyncRecord.stub :by_domain_name, @domain.csync_record do
|
CsyncRecord.stub :by_domain_name, @domain.csync_record do
|
||||||
@domain.csync_record.stub :dnssec_validates?, true do
|
@domain.csync_record.stub :dnssec_validates?, true do
|
||||||
2.times do
|
2.times do
|
||||||
CsyncJob.run
|
CsyncJob.perform_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue