Skip to content

Commit

Permalink
heartbeat 8.17.0
Browse files Browse the repository at this point in the history
heartbeat: update test

Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
BrewTestBot authored and chenrui333 committed Dec 13, 2024
1 parent cf2a302 commit 89a3ff1
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions Formula/h/heartbeat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class Heartbeat < Formula
desc "Lightweight Shipper for Uptime Monitoring"
homepage "https://www.elastic.co/beats/heartbeat"
url "https://github.com/elastic/beats.git",
tag: "v8.16.1",
revision: "f17e0828f1de9f1a256d3f520324fa6da53daee5"
tag: "v8.17.0",
revision: "092f0eae4d0d343cc3a142f671c2a0428df67840"
license "Apache-2.0"
head "https://github.com/elastic/beats.git", branch: "master"

Expand Down Expand Up @@ -65,35 +65,39 @@ def post_install
# https://github.com/Homebrew/homebrew-core/pull/91712
return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"].present?

port = free_port

(testpath/"config/heartbeat.yml").write <<~YAML
heartbeat.monitors:
- type: tcp
schedule: '@every 5s'
hosts: ["localhost:#{port}"]
check.send: "hello\\n"
check.receive: "goodbye\\n"
output.file:
path: "#{testpath}/heartbeat"
filename: heartbeat
codec.format:
string: '%{[monitor]}'
YAML
fork do
exec bin/"heartbeat", "-path.config", testpath/"config", "-path.data",
testpath/"data"
end
sleep 5
assert_match "hello", pipe_output("nc -l #{port}", "goodbye\n", 0)
begin
port = free_port

(testpath/"config/heartbeat.yml").write <<~YAML
heartbeat.monitors:
- type: tcp
schedule: '@every 5s'
hosts: ["localhost:#{port}"]
check.send: "hello\\n"
check.receive: "goodbye\\n"
output.file:
path: "#{testpath}/heartbeat"
filename: heartbeat
codec.format:
string: '%{[monitor]}'
YAML

pid = spawn bin/"heartbeat", "--path.config", testpath/"config", "--path.data", testpath/"data"
sleep 5
sleep 5 if OS.mac? && Hardware::CPU.intel?
assert_match "hello", pipe_output("nc -l #{port}", "goodbye\n", 0)
sleep 5

sleep 5
output = JSON.parse((testpath/"data/meta.json").read)
assert_includes output, "first_start"
output = JSON.parse((testpath/"data/meta.json").read)
assert_includes output, "first_start"

(testpath/"data").glob("heartbeat-*.ndjson") do |file|
s = JSON.parse(file.read)
assert_match "up", s["status"]
(testpath/"data").glob("heartbeat-*.ndjson") do |file|
s = JSON.parse(file.read)
assert_match "up", s["status"]
end
ensure
Process.kill("TERM", pid)
Process.wait(pid)
end
end
end

0 comments on commit 89a3ff1

Please sign in to comment.