etcd_harness

package module
v0.0.0-...-4dc1cb3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

README

etcd Golang Integration Test Harness

Travis Build Go Report Card GoDoc Apache 2.0 License

Harness code that spins up and manages a local-only etcd server for Go (golang) integration tests.

It is meant to be used with suite-tests, such as testify Suites or gocheck fixtures, to leverage single startup of a test suite.

Features:

  • dynamic port allocation - multiple Harnesses can be run in parallel
  • dynamic data directory - each Harness has an independent data dirctory
  • full etcd server lifecycle management - start, stop and data cleanup
  • uses etcd from $PATH - makes it easy to test against an etcd version you run in production
  • typical boostrap of 400-500ms

Usage

Harness exports the official Golang client bindings under harness.Client. For raw access purposes harness.Endpoint returns the client-side endpoint of the etcd server.

For an example of usage that utilises testify Suites, please see harness_test.go.

Travis CI Configuration

If you're creating an open source project, chances are you're using Travis as your CI. Travis by default places your $GOPATH/bin on the build's $PATH. Since etcd Harness looks for the etcd binary in $PATH, using it is as easy as:

install:
  - go get github.com/coreos/etcd
  - go get github.com/mwitkow/go-etcd-harness
  ...

###License

etcd-harness is under the Apache 2.0 license. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalEtcdAvailable

func LocalEtcdAvailable() bool

LocalEtcdAvailable returns true if an etcd binary is available on PATH.

Types

type Harness

type Harness struct {
	Client   etcd.Client
	Endpoint string
	// contains filtered or unexported fields
}

Harness represents a running etcd server for an integraiton test environment.

func New

func New(etcdErrWriter io.Writer) (*Harness, error)

New initializes and returns a new Harness. Failures here will be indicated as errors.

func (*Harness) Stop

func (s *Harness) Stop()

Stop kills the harnessed etcd server and cleans up the data directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL