class Etcd < Formula desc "Key value store for shared configuration and service discovery" homepage "https://github.com/coreos/etcd" url "https://github.com/coreos/etcd/archive/v3.1.5.tar.gz" sha256 "d9019b45df696f1dae286a511bd28b03751e37343c752380318e2a13ac994318" head "https://github.com/coreos/etcd.git" bottle do cellar :any_skip_relocation sha256 "c9e4b77cf6af716e5bfa0f94521409d89979937cfe54e95f3f8a802287e84246" => :sierra sha256 "e2d4c474b795e81440e4f72199b90cf57b118dc3fa36955f47537a084fcf98fa" => :el_capitan sha256 "fd726467254e543714dfb6e6ded654e57d25e045299652c181113d7e065795ab" => :yosemite end depends_on "go" => :build def install ENV["GOPATH"] = buildpath mkdir_p "src/github.com/coreos" ln_s buildpath, "src/github.com/coreos/etcd" system "./build" bin.install "bin/etcd" bin.install "bin/etcdctl" end plist_options :manual => "etcd" def plist; <<-EOS.undent KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/etcd RunAtLoad WorkingDirectory #{var} EOS end test do begin test_string = "Hello from brew test!" etcd_pid = fork do exec bin/"etcd", "--force-new-cluster", "--data-dir=#{testpath}" end # sleep to let etcd get its wits about it sleep 10 etcd_uri = "http://127.0.0.1:2379/v2/keys/brew_test" system "curl", "--silent", "-L", etcd_uri, "-XPUT", "-d", "value=#{test_string}" curl_output = shell_output("curl --silent -L #{etcd_uri}") response_hash = JSON.parse(curl_output) assert_match(test_string, response_hash.fetch("node").fetch("value")) ensure # clean up the etcd process before we leave Process.kill("HUP", etcd_pid) end end end