mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
rename openPort, and some small refactors
This commit is contained in:
parent
673a290255
commit
5799c10cd1
3 changed files with 26 additions and 21 deletions
8
Gopkg.lock
generated
8
Gopkg.lock
generated
|
|
@ -163,6 +163,12 @@
|
|||
revision = "16398bac157da96aa88f98a2df640c7f32af1da2"
|
||||
version = "v1.0.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/rakyll/statik"
|
||||
packages = ["fs"]
|
||||
|
|
@ -262,6 +268,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "2e353a12454268d89afe6d06c6021631b577bfd62dede36458f34397ab34fa17"
|
||||
inputs-digest = "d91110a10c830f7a9cc439b9578840d97d9921e84d08242316da8d4a18c68c56"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ func MustNewRunningServer(t *testing.T) *server.Command {
|
|||
func newServer() (*server.Command, error) {
|
||||
s := server.NewCommand(&bytes.Buffer{}, ioutil.Discard, ioutil.Discard)
|
||||
|
||||
port, err := openPort()
|
||||
port, err := findPort()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting port")
|
||||
}
|
||||
s.Config.Bind = "localhost:" + strconv.Itoa(port)
|
||||
|
||||
gport, err := openPort()
|
||||
gport, err := findPort()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting gossip port")
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ func newServer() (*server.Command, error) {
|
|||
return s, nil
|
||||
}
|
||||
|
||||
func openPort() (int, error) {
|
||||
func findPort() (int, error) {
|
||||
addr, err := net.ResolveTCPAddr("tcp", ":0")
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "resolving new port addr")
|
||||
|
|
@ -68,8 +68,8 @@ func openPort() (int, error) {
|
|||
|
||||
}
|
||||
|
||||
func MustOpenPort(t *testing.T) int {
|
||||
port, err := openPort()
|
||||
func MustFindPort(t *testing.T) int {
|
||||
port, err := findPort()
|
||||
if err != nil {
|
||||
t.Fatalf("allocating new port: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,34 +16,33 @@ func TestNewCluster(t *testing.T) {
|
|||
t.Fatalf("getting schema: %v", err)
|
||||
}
|
||||
dec := json.NewDecoder(response.Body)
|
||||
a := StatusResp{}
|
||||
err = dec.Decode(&a)
|
||||
body := struct {
|
||||
Status struct {
|
||||
Nodes []struct {
|
||||
Host string
|
||||
Schema string
|
||||
State string
|
||||
}
|
||||
}
|
||||
}{}
|
||||
|
||||
err = dec.Decode(&body)
|
||||
if err != nil {
|
||||
t.Fatalf("decoding status response: %v", err)
|
||||
}
|
||||
|
||||
bytes, err := json.MarshalIndent(a, "", " ")
|
||||
bytes, err := json.MarshalIndent(body, "", " ")
|
||||
if err != nil {
|
||||
t.Fatalf("encoding: %v", err)
|
||||
}
|
||||
|
||||
if len(a.Status.Nodes) != 3 {
|
||||
if len(body.Status.Nodes) != 3 {
|
||||
t.Fatalf("wrong number of nodes in status: %s", bytes)
|
||||
}
|
||||
|
||||
for i, node := range a.Status.Nodes {
|
||||
for i, node := range body.Status.Nodes {
|
||||
if node.State != "UP" {
|
||||
t.Fatalf("node %d should be up but is %s", i, node.State)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type StatusResp struct {
|
||||
Status struct {
|
||||
Nodes []struct {
|
||||
Host string
|
||||
Schema string
|
||||
State string
|
||||
}
|
||||
} `json:"status"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue