Skip to content

Commit

Permalink
Add ActionCable checks to example allgood.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
rameerez committed Nov 2, 2024
1 parent 707623a commit 6777f2c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/allgood.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,42 @@
end
end

# --- ACTION CABLE ---

check "ActionCable is configured and running" do
make_sure ActionCable.server.present?, "ActionCable server should be running"
end

check "ActionCable is configured to accept connections with a valid adapter" do
make_sure ActionCable.server.config.allow_same_origin_as_host, "ActionCable server should be configured to accept connections"

adapter = ActionCable.server.config.cable["adapter"]

if Rails.env.production?
make_sure adapter.in?(["solid_cable", "redis"]), "ActionCable running #{adapter} adapter in #{Rails.env.to_s}"
else
make_sure adapter.in?(["solid_cable", "async"]), "ActionCable running #{adapter} adapter in #{Rails.env.to_s}"
end
end

check "ActionCable can broadcast messages and store them in SolidCable" do
test_message = "allgood_test_#{Time.now.to_i}"

begin
ActionCable.server.broadcast("allgood_test_channel", { message: test_message })

# Verify message was stored in SolidCable
message = SolidCable::Message.where(channel: "allgood_test_channel")
.order(created_at: :desc)
.first

make_sure message.present?, "Message should be stored in SolidCable"
make_sure message.payload.include?(test_message) && message.destroy, "Message payload should contain our test message"
rescue => e
make_sure false, "Failed to broadcast/verify message: #{e.message}"
end
end

# --- SYSTEM ---

check "Disk space usage is below 90%", only: :production do
Expand Down

0 comments on commit 6777f2c

Please sign in to comment.