mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
add test for timestamp Min/Max on multinode clusters
This commit is contained in:
parent
ff39b76143
commit
e4745c1d77
1 changed files with 41 additions and 0 deletions
|
|
@ -8292,3 +8292,44 @@ func TestToRows(t *testing.T) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// TestMinMaxTimestampVariableNode tests Min() and Max() queries on
|
||||
// timestamp values on a clusters of varying size.
|
||||
func TestMinMaxTimestampVariableNode(t *testing.T) {
|
||||
for i := 1; i < 4; i++ {
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
// separate function so we can defer closing the cluster
|
||||
// and so it looks prettier
|
||||
MinMaxTimestampNodeTester(t, i)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// MinMaxTimestampNodeTester tests Min() and Max() queries on
|
||||
// timestamp values on a cluster with `numNodes` nodes.
|
||||
// fails if the min or max values are not correct
|
||||
func MinMaxTimestampNodeTester(t *testing.T, numNodes int) {
|
||||
t.Helper()
|
||||
index := "test_index"
|
||||
field := "ts"
|
||||
c := test.MustRunCluster(t, numNodes)
|
||||
defer c.Close()
|
||||
|
||||
// create an index and timestamp field
|
||||
c.CreateField(t, index, pilosa.IndexOptions{}, field, pilosa.OptFieldTypeTimestamp(time.Unix(0, 0), "s"))
|
||||
|
||||
// add some data
|
||||
expected := "2010-01-02T12:32:00Z"
|
||||
c.Query(t, index, "Set(10, ts=\""+expected+"\")")
|
||||
|
||||
// run a query on the cluster
|
||||
min := c.Query(t, index, "Min("+field+")").Results[0].(pilosa.ValCount).TimestampVal.Format(time.RFC3339Nano)
|
||||
if min != expected {
|
||||
t.Fatalf("incorrect min timestamp val. expected: %v, got %v\n", expected, min)
|
||||
}
|
||||
|
||||
max := c.Query(t, index, "Max("+field+")").Results[0].(pilosa.ValCount).TimestampVal.Format(time.RFC3339Nano)
|
||||
if max != expected {
|
||||
t.Fatalf("incorrect max timestamp val. expected: %v, got %v\n", expected, min)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue