Skip to content

Commit

Permalink
Init health monitor session only when server is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
var77 committed May 1, 2024
1 parent f79aee3 commit a111dac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions model/lantern/lantern_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ def container_image
end

def init_health_monitor_session
if strand.label != "wait"
fail "server is not ready to initialize session"
end

{
db_connection: nil
}
Expand Down
6 changes: 6 additions & 0 deletions spec/model/lantern/lantern_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,13 @@
end

describe "Lsn monitor" do
it "fails to initiate a new health monitor session" do
expect(lantern_server).to receive(:strand).and_return(instance_double(Strand, label: "setup domain")).at_least(:once)
expect { lantern_server.init_health_monitor_session }.to raise_error "server is not ready to initialize session"
end

it "initiates a new health monitor session" do
expect(lantern_server).to receive(:strand).and_return(instance_double(Strand, label: "wait")).at_least(:once)
expect(lantern_server.init_health_monitor_session).to eq({db_connection: nil})
end

Expand Down

0 comments on commit a111dac

Please sign in to comment.