mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-05 08:10:50 +00:00
index, frame statsD and tests
This commit is contained in:
parent
beb280624d
commit
d18ee46d76
3 changed files with 75 additions and 15 deletions
|
|
@ -231,7 +231,6 @@ func (h *Holder) createIndex(name string, opt IndexOptions) (*Index, error) {
|
|||
index.SetTimeQuantum(opt.TimeQuantum)
|
||||
|
||||
h.indexes[index.Name()] = index
|
||||
fmt.Println("HERE")
|
||||
h.Stats.Count("createIndex", 1)
|
||||
|
||||
return index, nil
|
||||
|
|
|
|||
|
|
@ -201,7 +201,6 @@ func (s *Server) monitorAntiEntropy() {
|
|||
continue
|
||||
}
|
||||
|
||||
|
||||
// Record successful sync in log.
|
||||
s.logger().Printf("holder sync complete")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,18 +138,8 @@ func TestStatsCount_SetProfileAttrs(t *testing.T) {
|
|||
func TestStatsCount_CreateIndex(t *testing.T) {
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1)
|
||||
|
||||
called := false
|
||||
e := NewExecutor(hldr.Holder, NewCluster(1))
|
||||
idx := e.Holder.Index("d")
|
||||
if idx == nil {
|
||||
t.Fatal("index not found")
|
||||
}
|
||||
|
||||
e.Holder.Stats = &MockStats{
|
||||
hldr.Holder.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64) {
|
||||
if name != "createIndex" {
|
||||
t.Errorf("Expected createIndex, Results %s", name)
|
||||
|
|
@ -159,9 +149,81 @@ func TestStatsCount_CreateIndex(t *testing.T) {
|
|||
return
|
||||
},
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "d", MustParse(`SetColumnAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
hldr.CreateIndexIfNotExists("d", pilosa.IndexOptions{})
|
||||
if !called {
|
||||
t.Error("Count isn't called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatsCount_DeleteIndex(t *testing.T) {
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
called := false
|
||||
hldr.CreateIndexIfNotExists("d", pilosa.IndexOptions{})
|
||||
hldr.Holder.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64) {
|
||||
if name != "deleteIndex" {
|
||||
t.Errorf("Expected deleteIndex, Results %s", name)
|
||||
}
|
||||
|
||||
called = true
|
||||
return
|
||||
},
|
||||
}
|
||||
hldr.DeleteIndex("d")
|
||||
if !called {
|
||||
t.Error("Count isn't called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatsCount_CreateFrame(t *testing.T) {
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
called := false
|
||||
hldr.CreateIndexIfNotExists("d", pilosa.IndexOptions{})
|
||||
e := NewExecutor(hldr.Holder, NewCluster(1))
|
||||
idx := e.Holder.Index("d")
|
||||
if idx == nil {
|
||||
t.Fatal("index not found")
|
||||
}
|
||||
idx.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64) {
|
||||
if name != "createFrame" {
|
||||
t.Errorf("Expected createFrame, Results %s", name)
|
||||
}
|
||||
|
||||
called = true
|
||||
return
|
||||
},
|
||||
}
|
||||
idx.CreateFrameIfNotExists("test", pilosa.FrameOptions{})
|
||||
if !called {
|
||||
t.Error("Count isn't called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatsCount_DeleteFrame(t *testing.T) {
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
called := false
|
||||
hldr.CreateIndexIfNotExists("d", pilosa.IndexOptions{})
|
||||
e := NewExecutor(hldr.Holder, NewCluster(1))
|
||||
idx := e.Holder.Index("d")
|
||||
if idx == nil {
|
||||
t.Fatal("index not found")
|
||||
}
|
||||
idx.CreateFrameIfNotExists("test", pilosa.FrameOptions{})
|
||||
idx.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64) {
|
||||
if name != "deleteFrame" {
|
||||
t.Errorf("Expected deleteFrame, Results %s", name)
|
||||
}
|
||||
|
||||
called = true
|
||||
return
|
||||
},
|
||||
}
|
||||
idx.DeleteFrame("test")
|
||||
if !called {
|
||||
t.Error("Count isn't called")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue