diff --git a/model/lantern/lantern_server.rb b/model/lantern/lantern_server.rb index afa847fdd..0c1ba544f 100644 --- a/model/lantern/lantern_server.rb +++ b/model/lantern/lantern_server.rb @@ -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 } diff --git a/spec/model/lantern/lantern_server_spec.rb b/spec/model/lantern/lantern_server_spec.rb index d397d8312..720566aad 100644 --- a/spec/model/lantern/lantern_server_spec.rb +++ b/spec/model/lantern/lantern_server_spec.rb @@ -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