(t *testing.T)
| 2580 | } |
| 2581 | |
| 2582 | func TestCreateIndexThenFreezePlanThenAddNode(t *testing.T) { |
| 2583 | cfg, mgr0, router0 := testCreateIndex1Node(t, |
| 2584 | []string{`{"maxPartitionsPerPIndex":1}`}, 2, 1) |
| 2585 | |
| 2586 | tests := []*RESTHandlerTest{ |
| 2587 | { |
| 2588 | Desc: "count myIdx should be 0, 1 nodes", |
| 2589 | Path: "/api/index/myIdx/count", |
| 2590 | Method: "GET", |
| 2591 | Status: http.StatusOK, |
| 2592 | ResponseMatch: map[string]bool{ |
| 2593 | `{"status":"ok","count":0}`: true, |
| 2594 | }, |
| 2595 | }, |
| 2596 | } |
| 2597 | testRESTHandlers(t, tests, router0) |
| 2598 | |
| 2599 | indexDefs, indexDefsCas, err := cbgt.CfgGetIndexDefs(cfg) |
| 2600 | if err != nil { |
| 2601 | t.Errorf("error CfgGetIndexDefs: %v", err) |
| 2602 | } |
| 2603 | indexDefs.IndexDefs["myIdx"].PlanParams.PlanFrozen = true |
| 2604 | _, err = cbgt.CfgSetIndexDefs(cfg, indexDefs, indexDefsCas) |
| 2605 | if err != nil { |
| 2606 | t.Errorf("expected CfgSetIndexDefs for plan freeze to work") |
| 2607 | } |
| 2608 | |
| 2609 | planPIndexesPrev, casPrev, err := cbgt.CfgGetPlanPIndexes(cfg) |
| 2610 | if err != nil { |
| 2611 | t.Errorf("expected no err") |
| 2612 | } |
| 2613 | |
| 2614 | emptyDir1, _ := ioutil.TempDir("./tmp", "test") |
| 2615 | defer os.RemoveAll(emptyDir1) |
| 2616 | |
| 2617 | meh1 := &TestMEH{} |
| 2618 | mgr1 := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(), |
| 2619 | nil, "", 1, "", "localhost:2000", emptyDir1, |
| 2620 | "some-datasource", meh1) |
| 2621 | mgr1.Start("wanted") |
| 2622 | mgr1.Kick("test-start-kick") |
| 2623 | |
| 2624 | nd, _, err := cbgt.CfgGetNodeDefs(cfg, cbgt.NODE_DEFS_KNOWN) |
| 2625 | if err != nil { |
| 2626 | t.Errorf("expected node defs known") |
| 2627 | } |
| 2628 | if len(nd.NodeDefs) != 2 { |
| 2629 | t.Errorf("expected 2 node defs unknown") |
| 2630 | } |
| 2631 | |
| 2632 | nd, _, err = cbgt.CfgGetNodeDefs(cfg, cbgt.NODE_DEFS_WANTED) |
| 2633 | if err != nil { |
| 2634 | t.Errorf("expected node defs wanted") |
| 2635 | } |
| 2636 | if len(nd.NodeDefs) != 2 { |
| 2637 | t.Errorf("expected 2 node defs wanted") |
| 2638 | } |
| 2639 |
nothing calls this directly
no test coverage detected