Skip to content

Commit

Permalink
Add new server-level unit test
Browse files Browse the repository at this point in the history
Added this as part of working on issue #3603.
  • Loading branch information
otoolep committed Aug 13, 2015
1 parent 1181427 commit f74248c
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions cmd/influxd/run/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,46 @@ func TestServer_Query_IdenticalTagValues(t *testing.T) {
}
}

// Ensure the server can handle a query that involves accessing no shards.
func TestServer_Query_NoShards(t *testing.T) {
t.Parallel()
s := OpenServer(NewConfig(), "")
defer s.Close()

if err := s.CreateDatabaseAndRetentionPolicy("db0", newRetentionPolicyInfo("rp0", 1, 1*time.Hour)); err != nil {
t.Fatal(err)
}

now := now()

test := NewTest("db0", "rp0")
test.write = `cpu,host=server01 value=1 ` + strconv.FormatInt(now.UnixNano(), 10)

test.addQueries([]*Query{
&Query{
name: "selecting value should succeed",
command: `SELECT value FROM db0.rp0.cpu WHERE time < now() - 1d`,
exp: `{"results":[{}]}`,
},
}...)

if err := test.init(s); err != nil {
t.Fatalf("test init failed: %s", err)
}

for _, query := range test.queries {
if query.skip {
t.Logf("SKIP:: %s", query.name)
continue
}
if err := query.Execute(s); err != nil {
t.Error(query.Error(err))
} else if !query.success() {
t.Error(query.failureMessage())
}
}
}

// Ensure the server can query a non-existent field
func TestServer_Query_NonExistent(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit f74248c

Please sign in to comment.