const installEtcd … // getEtcdPath returns a path to an etcd executable. func getEtcdPath() (string, error) { … } // getAvailablePort returns a TCP port that is available for binding. func getAvailablePort() (int, error) { … } // startEtcd executes an etcd instance. The returned function will signal the // etcd process and wait for it to exit. func startEtcd(output io.Writer, forceCreate bool) (func(), error) { … } func init() { … } // RunCustomEtcd starts a custom etcd instance for test purposes. func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url string, stopFn func(), err error) { … } // EtcdMain starts an etcd instance before running tests. func EtcdMain(tests func() int) { … } // GetEtcdURL returns the URL of the etcd instance started by EtcdMain or StartEtcd. func GetEtcdURL() string { … } // StartEtcd starts an etcd instance inside a test. It will abort the test if // startup fails and clean up after the test automatically. Stdout and stderr // of the etcd binary go to the provided writer. // // In contrast to EtcdMain, StartEtcd will not do automatic leak checking. // Tests can decide if and where they want to do that. // // Starting etcd multiple times per test run instead of once with EtcdMain // provides better separation between different tests. func StartEtcd(tb testing.TB, etcdOutput io.Writer, forceCreate bool) { … }