MCPcopy Create free account
hub / github.com/couchbase/cbft / TestCreateIndex1PIndexAddNode

Function TestCreateIndex1PIndexAddNode

rest_test.go:2412–2509  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2410}
2411
2412func TestCreateIndex1PIndexAddNode(t *testing.T) {
2413 cfg, mgr0, router0 := testCreateIndex1Node(t,
2414 []string{`{"maxPartitionsPerPIndex":100}`}, 1, 1)
2415
2416 tests := []*RESTHandlerTest{
2417 {
2418 Desc: "count myIdx should be 0, 1 nodes",
2419 Path: "/api/index/myIdx/count",
2420 Method: "GET",
2421 Status: http.StatusOK,
2422 ResponseMatch: map[string]bool{
2423 `{"status":"ok","count":0}`: true,
2424 },
2425 },
2426 {
2427 Desc: "query myIdx should have 0 hits, 1 nodes",
2428 Path: "/api/index/myIdx/query",
2429 Method: "POST",
2430 Params: nil,
2431 Body: []byte(`{"size":10,"query":{"query":"no-hits"}}`),
2432 Status: http.StatusOK,
2433 ResponseMatch: map[string]bool{
2434 `"hits":[],"total_hits":0`: true,
2435 },
2436 },
2437 }
2438 testRESTHandlers(t, tests, router0)
2439
2440 planPIndexesPrev, casPrev, err := cbgt.CfgGetPlanPIndexes(cfg)
2441 if err != nil {
2442 t.Errorf("expected no err")
2443 }
2444
2445 emptyDir1, _ := ioutil.TempDir("./tmp", "test")
2446 defer os.RemoveAll(emptyDir1)
2447
2448 options := map[string]string{"enablePartitionNodeStickiness": "true"}
2449
2450 meh1 := &TestMEH{}
2451 mgr1 := cbgt.NewManagerEx(cbgt.VERSION, cfg, cbgt.NewUUID(),
2452 nil, "", 1, "", "localhost:2000",
2453 emptyDir1, "some-datasource", meh1, options)
2454 mgr1.Start("wanted")
2455 mgr1.Kick("test-start-kick")
2456
2457 nd, _, err := cbgt.CfgGetNodeDefs(cfg, cbgt.NODE_DEFS_KNOWN)
2458 if err != nil {
2459 t.Errorf("expected node defs known")
2460 }
2461 if len(nd.NodeDefs) != 2 {
2462 t.Errorf("expected 2 node defs unknown")
2463 }
2464
2465 nd, _, err = cbgt.CfgGetNodeDefs(cfg, cbgt.NODE_DEFS_WANTED)
2466 if err != nil {
2467 t.Errorf("expected node defs wanted")
2468 }
2469 if len(nd.NodeDefs) != 2 {

Callers

nothing calls this directly

Calls 3

testCreateIndex1NodeFunction · 0.85
testRESTHandlersFunction · 0.85
MarshalMethod · 0.80

Tested by

no test coverage detected