diff --git a/Formula/vitess.rb b/Formula/vitess.rb new file mode 100644 index 000000000000..eaa51bc5bb96 --- /dev/null +++ b/Formula/vitess.rb @@ -0,0 +1,38 @@ +class Vitess < Formula + desc "Database clustering system for horizontal scaling of MySQL" + homepage "https://vitess.io" + url "https://github.com/vitessio/vitess/archive/v9.0.0.tar.gz" + sha256 "14254f423f2472fb48034299cbfc4acc6b767f7497036cf43eb3e7f2a70f7beb" + license "Apache-2.0" + + depends_on "go" => :build + depends_on "etcd" + + def install + system "make", "install-local", "PREFIX=#{prefix}", "VTROOT=#{buildpath}" + pkgshare.install "examples" + end + + test do + etcd_server = "localhost:#{free_port}" + fork do + exec Formula["etcd"].opt_bin/"etcd", "--enable-v2=true", + "--data-dir=#{testpath}/etcd", + "--listen-client-urls=http://#{etcd_server}", + "--advertise-client-urls=http://#{etcd_server}" + end + sleep 3 + + port = free_port + fork do + exec bin/"vtgate", "-topo_implementation", "etcd2", + "-topo_global_server_address", etcd_server, + "-topo_global_root", testpath/"global", + "-port", port.to_s + end + sleep 3 + + output = shell_output("curl -s localhost:#{port}/debug/health") + assert_equal "ok", output + end +end