mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00

* Initial work on Sidekiq::Config * Initial work on Sidekiq::Config * reduce dependencies in deploy marks * bare sidekiq and webapp * Modify runtime to work with Capsules * Cleanup * Rename test files to remove test_ prefix * Update test suite and standard rules to be more compliant * Move constant definition outside code, per standard formatting * Loads of changes for introduction of Capsules * Remove Redis adapter abstraction * update capsule overview * Ensure Sidekiq.redis uses the correct pool for jobs running within a Capsule * Use default_capsule for safety * Slow down the beat to halve its Redis overhead * move config fixtures into cfg/ * Add capsule middleware test * use accessor
42 lines
963 B
Ruby
42 lines
963 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "helper"
|
|
require "sidekiq/sd_notify"
|
|
require "sidekiq/systemd"
|
|
|
|
describe "Systemd" do
|
|
before do
|
|
::Dir::Tmpname.create("sidekiq_socket") do |sockaddr|
|
|
@sockaddr = sockaddr
|
|
@socket = Socket.new(:UNIX, :DGRAM, 0)
|
|
socket_ai = Addrinfo.unix(sockaddr)
|
|
@socket.bind(socket_ai)
|
|
ENV["NOTIFY_SOCKET"] = sockaddr
|
|
end
|
|
end
|
|
|
|
after do
|
|
@socket&.close
|
|
File.unlink(@sockaddr) if @sockaddr
|
|
@socket = nil
|
|
@sockaddr = nil
|
|
end
|
|
|
|
def socket_message
|
|
@socket.recvfrom(10)[0]
|
|
end
|
|
|
|
it "notifies" do
|
|
count = Sidekiq::SdNotify.ready
|
|
assert_equal(socket_message, "READY=1")
|
|
assert_equal(ENV["NOTIFY_SOCKET"], @sockaddr)
|
|
assert_equal(count, 7)
|
|
|
|
count = Sidekiq::SdNotify.stopping
|
|
assert_equal(socket_message, "STOPPING=1")
|
|
assert_equal(ENV["NOTIFY_SOCKET"], @sockaddr)
|
|
assert_equal(count, 10)
|
|
|
|
refute Sidekiq::SdNotify.watchdog?
|
|
end
|
|
end
|