From a111dac89be7755ed69463fd888029c006825a4b Mon Sep 17 00:00:00 2001 From: Varik Matevosyan Date: Wed, 1 May 2024 10:15:41 -0700 Subject: [PATCH] Init health monitor session only when server is ready --- model/lantern/lantern_server.rb | 4 ++++ spec/model/lantern/lantern_server_spec.rb | 6 ++++++ 2 files changed, 10 insertions(+) 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