diff --git a/misc/misc_operations.rb b/misc/misc_operations.rb index 3745c99b1..4232f80e8 100644 --- a/misc/misc_operations.rb +++ b/misc/misc_operations.rb @@ -95,7 +95,7 @@ def self.run_script_daemonized(resource_name, filename, task_name) serv = LanternResource[name: resource_name].representative_server serv.vm.sshable.cmd("common/bin/daemonizer 'sudo #{filename}' #{task_name}") - task_logs resource_name, "#{task_name}" + task_logs resource_name, task_name.to_s end def self.create_all_indexes_concurrently_script(resource_name, filename) @@ -109,7 +109,7 @@ def self.create_all_indexes_concurrently_script(resource_name, filename) if !indexes.empty? queries = [] indexes.each { - queries.push(_1.gsub(/create\s+index/i, 'CREATE INDEX CONCURRENTLY')[1..-2]) + queries.push(_1.gsub(/create\s+index/i, "CREATE INDEX CONCURRENTLY")[1..-2]) } queries.map do |query| diff --git a/prog/lantern/lantern_server_nexus.rb b/prog/lantern/lantern_server_nexus.rb index cea36131e..5931a22ea 100644 --- a/prog/lantern/lantern_server_nexus.rb +++ b/prog/lantern/lantern_server_nexus.rb @@ -610,11 +610,11 @@ def destroy_domain end def available? - vm.sshable.invalidate_cache_entry - + status = false begin - lantern_server.run_query("SELECT 1") - return true + session = Sequel.connect(lantern_server.connection_string) + session["SELECT 1"] + status = true rescue end @@ -624,7 +624,7 @@ def available? rescue end - false + status end label def prewarm_indexes diff --git a/spec/prog/lantern/lantern_server_nexus_spec.rb b/spec/prog/lantern/lantern_server_nexus_spec.rb index ff9846639..a05a65008 100644 --- a/spec/prog/lantern/lantern_server_nexus_spec.rb +++ b/spec/prog/lantern/lantern_server_nexus_spec.rb @@ -748,40 +748,30 @@ end end - describe "#update_memory_limits" do - it "updates memory limits" do - expect(nx).to receive(:when_update_memory_limits_set?).and_yield - expect(lantern_server).to receive(:run_query) - expect(lantern_server.vm.sshable).to receive(:invalidate_cache_entry) - expect(lantern_server.vm.sshable).to receive(:cmd).with("sudo lantern/bin/update_memory_limits") - expect { nx.wait_db_available }.to hop("wait") - end - end - describe "#available" do it "marks as available" do - expect(lantern_server).to receive(:run_query) - expect(lantern_server.vm.sshable).to receive(:invalidate_cache_entry) + expect(lantern_server).to receive(:connection_string) + session = instance_double(Hash) + expect(session).to receive(:[]).with("SELECT 1") + expect(lantern_server.vm.sshable).to receive(:cmd).with("sudo lantern/bin/logs --tail 5").and_return("logs") + expect(Sequel).to receive(:connect).and_return(session) expect(nx.available?).to be(true) end it "does not mark as unavailable if redo in progress" do - expect(lantern_server).to receive(:run_query).and_raise "err" - expect(lantern_server.vm.sshable).to receive(:invalidate_cache_entry) + expect(lantern_server).to receive(:connection_string) + session = instance_double(Hash) + expect(session).to receive(:[]).with("SELECT 1").and_raise "err" + expect(Sequel).to receive(:connect).and_return(session) expect(lantern_server.vm.sshable).to receive(:cmd).with("sudo lantern/bin/logs --tail 5").and_return("redo in progress") expect(nx.available?).to be(true) end - it "marks unavailable if cmd fails" do - expect(lantern_server).to receive(:run_query).and_raise "err" - expect(lantern_server.vm.sshable).to receive(:invalidate_cache_entry) - expect(lantern_server.vm.sshable).to receive(:cmd).with("sudo lantern/bin/logs --tail 5").and_raise - expect(nx.available?).to be(false) - end - it "marks unavailable if cmd returns other logs" do - expect(lantern_server).to receive(:run_query).and_raise "err" - expect(lantern_server.vm.sshable).to receive(:invalidate_cache_entry) + expect(lantern_server).to receive(:connection_string) + session = instance_double(Hash) + expect(session).to receive(:[]).with("SELECT 1").and_raise "err" + expect(Sequel).to receive(:connect).and_return(session) expect(lantern_server.vm.sshable).to receive(:cmd).with("sudo lantern/bin/logs --tail 5").and_return("logs") expect(nx.available?).to be(false) end