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.0.2.tar.gz" sha256 "a13bdd303a9f59f45f4c053ca3e93212fb89b69aa761be540147f59ee76942e1" head "https://github.com/coreos/etcd.git" bottle do cellar :any_skip_relocation sha256 "97dbdec05745abe7118f918644826e5987a67b505ae27c6ef0cd0fa6eac8279a" => :el_capitan sha256 "b08605f2e4f81d5187b6d57965558fdb2a956ff86bcf2a4af965d70c62865ba7" => :yosemite sha256 "fef42230127871581c0d8be3fe82979f8c642229119fa8a05c6f918dfae4fe3c" => :mavericks 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 require "utils/json" 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 = Utils::JSON.load(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