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

Function TestNodePlanParams

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

Source from the content-addressed store, hash-verified

2662}
2663
2664func TestNodePlanParams(t *testing.T) {
2665 cfg, mgr0, router0 := testCreateIndex1Node(t,
2666 []string{`{"maxPartitionsPerPIndex":1,"numReplicas":0,"nodePlanParams":{"":{"":{"canRead":false,"canWrite":false}}}}`},
2667 2, 0)
2668
2669 tests := []*RESTHandlerTest{
2670 {
2671 Desc: "count myIdx should be 0, 1 nodes",
2672 Path: "/api/index/myIdx/count",
2673 Method: "GET",
2674 Status: 200,
2675 ResponseMatch: map[string]bool{
2676 `{"status":"ok","count":0}`: true,
2677 },
2678 },
2679 }
2680 testRESTHandlers(t, tests, router0)
2681
2682 planPIndexesPrev, casPrev, err := cbgt.CfgGetPlanPIndexes(cfg)
2683 if err != nil {
2684 t.Errorf("expected no err")
2685 }
2686
2687 emptyDir1, _ := ioutil.TempDir("./tmp", "test")
2688 defer os.RemoveAll(emptyDir1)
2689
2690 meh1 := &TestMEH{}
2691 mgr1 := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(),
2692 nil, "", 1, "", "localhost:2000", emptyDir1,
2693 "some-datasource", meh1)
2694 mgr1.Start("wanted")
2695 mgr1.Kick("test-start-kick")
2696
2697 nd, _, err := cbgt.CfgGetNodeDefs(cfg, cbgt.NODE_DEFS_KNOWN)
2698 if err != nil {
2699 t.Errorf("expected node defs known")
2700 }
2701 if len(nd.NodeDefs) != 2 {
2702 t.Errorf("expected 2 node defs unknown")
2703 }
2704
2705 nd, _, err = cbgt.CfgGetNodeDefs(cfg, cbgt.NODE_DEFS_WANTED)
2706 if err != nil {
2707 t.Errorf("expected node defs wanted")
2708 }
2709 if len(nd.NodeDefs) != 2 {
2710 t.Errorf("expected 2 node defs wanted")
2711 }
2712
2713 if cfg.Refresh() != nil {
2714 t.Errorf("expected cfg refresh to work")
2715 }
2716
2717 runtime.Gosched()
2718
2719 mgr0.Kick("test-kick-after-new-node")
2720
2721 planPIndexesCurr, casCurr, err := cbgt.CfgGetPlanPIndexes(cfg)

Callers

nothing calls this directly

Calls 3

testCreateIndex1NodeFunction · 0.85
testRESTHandlersFunction · 0.85
MarshalMethod · 0.80

Tested by

no test coverage detected