{"modulePath":"github.com/stackdocker/consul","version":"v0.5.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testutil\n\n## Functions\n\n```go\nfunc WaitForLeader(t *testing.T, rpc rpcFn, dc string) structs.IndexedNodes\n```\n\n```go\nfunc WaitForResult(test testFn, error errorFn)\n```\n\n## Types\n\n```go\ntype ServerConfigCallback func(c *TestServerConfig)\n```\nServerConfigCallback is a function interface which can be passed to NewTestServerConfig to modify the server config.\n\n```go\ntype TestAddressConfig struct {\n\tHTTP string `json:\"http,omitempty\"`\n}\n```\nTestAddressConfig contains the bind addresses for various components of the Consul server.\n\n```go\ntype TestCheck struct {\n\tID        string `json:\",omitempty\"`\n\tName      string `json:\",omitempty\"`\n\tServiceID string `json:\",omitempty\"`\n\tTTL       string `json:\",omitempty\"`\n}\n```\nTestCheck is used to serialize a check definition.\n\n```go\ntype TestKVResponse struct {\n\tValue string\n}\n```\nTestKVResponse is what we use to decode KV data.\n\n```go\ntype TestPortConfig struct {\n\tDNS     int `json:\"dns,omitempty\"`\n\tHTTP    int `json:\"http,omitempty\"`\n\tRPC     int `json:\"rpc,omitempty\"`\n\tSerfLan int `json:\"serf_lan,omitempty\"`\n\tSerfWan int `json:\"serf_wan,omitempty\"`\n\tServer  int `json:\"server,omitempty\"`\n}\n```\nTestPortConfig configures the various ports used for services provided by the Consul server.\n\n```go\ntype TestServer struct {\n\tPID    int\n\tConfig *TestServerConfig\n\n\tHTTPAddr string\n\tLANAddr  string\n\tWANAddr  string\n\n\tHttpClient *http.Client\n\t// contains filtered or unexported fields\n}\n```\nTestServer is the main server wrapper struct.\n\n```go\nfunc NewTestServer(t *testing.T) *TestServer\n```\nNewTestServer is an easy helper method to create a new Consul test server with the most basic configuration.\n\n```go\nfunc NewTestServerConfig(t *testing.T, cb ServerConfigCallback) *TestServer\n```\nNewTestServerConfig creates a new TestServer, and makes a call to an optional callback function to modify the configuration.\n\n```go\nfunc (s *TestServer) AddCheck(name, serviceID, status string)\n```\nAddCheck adds a check to the Consul instance. If the serviceID is left empty (\"\"), then the check will be associated with the node. The check status may be \"passing\", \"warning\", or \"critical\".\n\n```go\nfunc (s *TestServer) AddService(name, status string, tags []string)\n```\nAddService adds a new service to the Consul instance. It also automatically adds a health check with the given status, which can be one of \"passing\", \"warning\", or \"critical\".\n\n```go\nfunc (s *TestServer) GetKV(key string) []byte\n```\nGetKV retrieves a single key and returns its value\n\n```go\nfunc (s *TestServer) JoinLAN(addr string)\n```\nJoinLAN is used to join nodes within the same datacenter.\n\n```go\nfunc (s *TestServer) JoinWAN(addr string)\n```\nJoinWAN is used to join remote datacenters together.\n\n```go\nfunc (s *TestServer) ListKV(prefix string) []string\n```\nListKV returns a list of keys present in the KV store. This will list all keys under the given prefix recursively and return them as a slice.\n\n```go\nfunc (s *TestServer) PopulateKV(data map[string][]byte)\n```\nPopulateKV fills the Consul KV with data from a generic map.\n\n```go\nfunc (s *TestServer) SetKV(key string, val []byte)\n```\nSetKV sets an individual key in the K/V store.\n\n```go\nfunc (s *TestServer) Stop()\n```\nStop stops the test Consul server, and removes the Consul data directory once we are done.\n\n```go\ntype TestServerConfig struct {\n\tNodeName          string             `json:\"node_name\"`\n\tBootstrap         bool               `json:\"bootstrap,omitempty\"`\n\tServer            bool               `json:\"server,omitempty\"`\n\tDataDir           string             `json:\"data_dir,omitempty\"`\n\tDatacenter        string             `json:\"datacenter,omitempty\"`\n\tDisableCheckpoint bool               `json:\"disable_update_check\"`\n\tLogLevel          string             `json:\"log_level,omitempty\"`\n\tBind              string             `json:\"bind_addr,omitempty\"`\n\tAddresses         *TestAddressConfig `json:\"addresses,omitempty\"`\n\tPorts             *TestPortConfig    `json:\"ports,omitempty\"`\n}\n```\nTestServerConfig is the main server configuration struct.\n\n```go\ntype TestService struct {\n\tID      string   `json:\",omitempty\"`\n\tName    string   `json:\",omitempty\"`\n\tTags    []string `json:\",omitempty\"`\n\tAddress string   `json:\",omitempty\"`\n\tPort    int      `json:\",omitempty\"`\n}\n```\nTestService is used to serialize a service definition.\n\n","path":"github.com/stackdocker/consul/testutil","name":"testutil","synopsis":"","isRedistributable":true}
