Skip to content

Commit

Permalink
Merge pull request #201095 from Homebrew/stolon-test
Browse files Browse the repository at this point in the history
stolon: switch to use etcd v3 for test
  • Loading branch information
chenrui333 authored Dec 14, 2024
2 parents 608ab9e + ad033ad commit ffc6303
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions Formula/s/stolon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ class Stolon < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "30ca55abf39725e1760d6610e38ea05f089fd382724da55c170f2cf914ee1050"
end

deprecate! date: "2024-02-04", because: "depends on soon to be deprecated consul"

depends_on "go" => :build
depends_on "consul" => :test
depends_on "etcd" => :test
depends_on "libpq"

def install
Expand Down Expand Up @@ -53,29 +51,24 @@ def port_open?(ip_address, port, seconds = 1)
require "socket"
require "timeout"

consul_default_port = 8500
localhost_ip = "127.0.0.1".freeze
endpoint = "http://127.0.0.1:2379"
pid = spawn "etcd", "--advertise-client-urls", endpoint, "--listen-client-urls", endpoint

sleep 5

if port_open?(localhost_ip, consul_default_port)
puts "Consul already running"
else
fork do
exec "consul agent -dev -bind 127.0.0.1"
puts "Consul started"
end
sleep 5
end
assert_match "stolonctl version #{version}",
shell_output("#{bin}/stolonctl version 2>&1")
assert_match "nil cluster data: <nil>",
shell_output("#{bin}/stolonctl status --cluster-name test --store-backend consul 2>&1", 1)
output = shell_output("#{bin}/stolonctl status --cluster-name test " \
"--store-backend etcdv3 --store-endpoints #{endpoint} 2>&1", 1)
assert_match "nil cluster data: <nil>", output
assert_match "stolon-keeper version #{version}",
shell_output("#{bin}/stolon-keeper --version 2>&1")
assert_match "stolon-sentinel version #{version}",
shell_output("#{bin}/stolon-sentinel --version 2>&1")
assert_match "stolon-proxy version #{version}",
shell_output("#{bin}/stolon-proxy --version 2>&1")

system "consul", "leave"
ensure
Process.kill("TERM", pid)
Process.wait(pid)
end
end

0 comments on commit ffc6303

Please sign in to comment.