Skip to content

Commit

Permalink
stolon: switch to use etcd v3 for test
Browse files Browse the repository at this point in the history
Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
chenrui333 committed Dec 13, 2024
1 parent 76b4f7e commit ad033ad
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 ad033ad

Please sign in to comment.