mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 19:37:51 +00:00
clean test case and add comments
This commit is contained in:
parent
eff3b25b97
commit
3e81406ab0
1 changed files with 9 additions and 46 deletions
|
|
@ -502,6 +502,11 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
// UI/usage returns disk and memory usage from a precalculated cache.
|
||||
// Since the cache calculates the cache on server startup, and tests create indexes thereafter
|
||||
// the cache initially has 0 indexes when the test suite is ran. In live workloads, when a data
|
||||
// directory is already populated with indexes, this would not be the case. This test, therefore
|
||||
// only checks capicity and total use and not details about indexes.
|
||||
t.Run("UI/usage", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/ui/usage", nil))
|
||||
|
|
@ -509,67 +514,25 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
fmt.Printf("%+v\n", w.Body)
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
fmt.Printf("Cluster Size: %v\n", cluster.Len())
|
||||
t.Logf("Usage w body string: %+v\n", w.Body.String())
|
||||
|
||||
nodeUsages := make(map[string]pilosa.NodeUsage)
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &nodeUsages); err != nil {
|
||||
t.Fatalf("unmarshal")
|
||||
}
|
||||
|
||||
// w2 := httptest.NewRecorder()
|
||||
// h.ServeHTTP(w2, test.MustNewHTTPRequest("GET", "/schema", nil))
|
||||
// if w2.Code != gohttp.StatusOK {
|
||||
// t.Fatalf("unexpected status code: %d", w2.Code)
|
||||
// }
|
||||
// schemaBody := w2.Body.String()
|
||||
// t.Fatalf("Schema: %+v\n", schemaBody)
|
||||
// if schemaBody != "{\"indexes\":[]}\n" {
|
||||
// t.Fatalf("unexpected empty schema: '%v'", schemaBody)
|
||||
// }
|
||||
|
||||
numNodes := len(nodeUsages)
|
||||
fmt.Printf("num nodes: %+v\n", numNodes)
|
||||
|
||||
for _, nodeUsage := range nodeUsages {
|
||||
t.Logf("Len of Indexes: %+v\n", len(nodeUsage.Disk.IndexUsage))
|
||||
// numIndexes := len(nodeUsage.Disk.IndexUsage)
|
||||
fmt.Printf("Node Usage: %+v\n", nodeUsage)
|
||||
fmt.Printf("Disk Usage: %+v\n", nodeUsage.Disk)
|
||||
for k, v := range nodeUsage.Disk.IndexUsage {
|
||||
fmt.Printf("Index Usage: K: %+v V: %+v \n", k, v)
|
||||
}
|
||||
// if nodeUsage.Disk.TotalUse < 75000 || nodeUsage.Disk.TotalUse > 700000 {
|
||||
if nodeUsage.Disk.TotalUse < 1 {
|
||||
// Usage measurements are not consistent between machines, or
|
||||
// over time, as features and implementations change, so checking
|
||||
// for a range of sizes may be most useful way to test the details of this.
|
||||
t.Fatalf("expected some disk use, got %d", nodeUsage.Disk.TotalUse)
|
||||
}
|
||||
if nodeUsage.Disk.Capacity < 1 {
|
||||
// Usage measurements are not consistent between machines, or
|
||||
// over time, as features and implementations change, so checking
|
||||
// for a range of sizes may be most useful way to test the details of this.
|
||||
t.Fatalf("expected 75k < total < 500k, got %d", nodeUsage.Disk.TotalUse)
|
||||
t.Fatalf("expected some disk capacity, got %d", nodeUsage.Disk.Capacity)
|
||||
}
|
||||
if nodeUsage.Memory.TotalUse < 1 {
|
||||
// Usage measurements are not consistent between machines, or
|
||||
// over time, as features and implementations change, so checking
|
||||
// for a range of sizes may be most useful way to test the details of this.
|
||||
t.Fatalf("expected 75k < total < 500k, got %d", nodeUsage.Disk.TotalUse)
|
||||
t.Fatalf("expected some memory use, got %d", nodeUsage.Memory.TotalUse)
|
||||
}
|
||||
if nodeUsage.Memory.Capacity < 1 {
|
||||
// Usage measurements are not consistent between machines, or
|
||||
// over time, as features and implementations change, so checking
|
||||
// for a range of sizes may be most useful way to test the details of this.
|
||||
t.Fatalf("expected 75k < total < 500k, got %d", nodeUsage.Disk.TotalUse)
|
||||
t.Fatalf("expected some memory capacity, got %d", nodeUsage.Memory.Capacity)
|
||||
}
|
||||
// if numIndexes != 3 {
|
||||
// t.Fatalf("wrong length index usage list: expected %d, got %d", 2, numIndexes)
|
||||
// }
|
||||
// numFields := len(nodeUsage.Disk.IndexUsage["i1"].Fields)
|
||||
// if numFields != len(i1.Fields()) {
|
||||
// t.Fatalf("wrong length field usage list: expected %d, got %d", len(i1.Fields()), numFields)
|
||||
// }
|
||||
}
|
||||
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue