mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 11:57:51 +00:00
Add basic test
This commit is contained in:
parent
510902625e
commit
ab502a0f8d
2 changed files with 27 additions and 1 deletions
2
api.go
2
api.go
|
|
@ -1600,7 +1600,7 @@ func importExistenceColumns(qcx *Qcx, index *Index, columnIDs []uint64) error {
|
|||
// ShardDistribution returns an object representing the distribution of shards
|
||||
// across nodes for each index, distinguishing between primary and replica.
|
||||
// The structure of this information is [indexName][nodeID][primaryOrReplica]uint64.
|
||||
// This function supports a view in the UI, and
|
||||
// This function supports a view in the UI.
|
||||
func (api *API) ShardDistribution(ctx context.Context) map[string]interface{} {
|
||||
distByIndex := make(map[string]interface{})
|
||||
maxShards := api.MaxShards(ctx)
|
||||
|
|
|
|||
|
|
@ -400,6 +400,32 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("UI/shard-distribution", func(t *testing.T) {
|
||||
// This tests the response structure, not the shard distribution.
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/ui/shard-distribution", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
ret := mustJSONDecode(t, w.Body)
|
||||
|
||||
for indexName := range ret {
|
||||
indexData := ret[indexName].(map[string]interface{})
|
||||
for nodeName := range indexData {
|
||||
nodeData := indexData[nodeName].(map[string]interface{})
|
||||
_, hasPrimary := nodeData["primary-shards"]
|
||||
_, hasReplica := nodeData["replica-shards"]
|
||||
|
||||
responseOK := hasPrimary && hasReplica
|
||||
if !responseOK {
|
||||
t.Fatalf("unexpected response structure")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Metrics", func(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/metrics", nil))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue