Skip to content

Commit

Permalink
Merge pull request #2439 from tamird/cleanup-test-server
Browse files Browse the repository at this point in the history
testServer: misc cleanup
  • Loading branch information
tamird committed Sep 9, 2015
2 parents 9b764a1 + 236f701 commit b7cfd5c
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions server/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,35 +256,35 @@ func getRequest(t *testing.T, ts TestServer, path string) []byte {
// the scan to complete, and return the server. The caller is
// responsible for stopping the server.
// TODO(bram): Add more nodes.
func startServer(t *testing.T, keyPrefix string) TestServer {
func startServer() (TestServer, error) {
var ts TestServer
ts.Ctx = NewTestContext()
ts.Ctx.ScanInterval = time.Duration(5 * time.Millisecond)
ts.StoresPerNode = 3
if err := ts.Start(); err != nil {
t.Fatal(err)
return ts, err
}

// Make sure the range is spun up with an arbitrary read command. We do not
// expect a specific response.
if _, err := ts.db.Get("a"); err != nil {
t.Fatal(err)
return ts, err
}

// Make sure the node status is available. This is done by forcing stores to
// publish their status, synchronizing to the event feed with a canary
// event, and then forcing the server to write summaries immediately.
if err := ts.node.publishStoreStatuses(); err != nil {
t.Fatalf("error publishing store statuses: %s", err)
return ts, util.Errorf("error publishing store statuses: %s", err)
}

ts.EventFeed().Flush()

if err := ts.writeSummaries(); err != nil {
t.Fatalf("error writing summaries: %s", err)
return ts, util.Errorf("error writing summaries: %s", err)
}

return ts
return ts, nil
}

// TestStatusLocalLogs checks to ensure that local/logfiles,
Expand All @@ -304,7 +304,10 @@ func TestStatusLocalLogs(t *testing.T) {
}
}()

ts := startServer(t, "/_status/logfiles/local")
ts, err := startServer()
if err != nil {
t.Fatal(err)
}
defer ts.Stop()

// Log an error which we expect to show up on every log file.
Expand Down Expand Up @@ -458,7 +461,10 @@ func TestStatusLocalLogs(t *testing.T) {
// results.
func TestNodeStatusResponse(t *testing.T) {
defer leaktest.AfterTest(t)
ts := startServer(t, statusNodesPrefix)
ts, err := startServer()
if err != nil {
t.Fatal(err)
}
defer ts.Stop()

body := getRequest(t, ts, statusNodesPrefix)
Expand Down Expand Up @@ -498,7 +504,10 @@ func TestNodeStatusResponse(t *testing.T) {
// results.
func TestStoreStatusResponse(t *testing.T) {
defer leaktest.AfterTest(t)
ts := startServer(t, statusStoresPrefix)
ts, err := startServer()
if err != nil {
t.Fatal(err)
}
defer ts.Stop()

body := getRequest(t, ts, statusStoresPrefix)
Expand Down

0 comments on commit b7cfd5c

Please sign in to comment.