(t *testing.T)
| 1642 | } |
| 1643 | |
| 1644 | func testHandlersWithOnePartitionPrimaryFeedRollback(t *testing.T) { |
| 1645 | emptyDir, _ := ioutil.TempDir("./tmp", "test") |
| 1646 | defer os.RemoveAll(emptyDir) |
| 1647 | |
| 1648 | cfg := cbgt.NewCfgMem() |
| 1649 | meh := &TestMEH{} |
| 1650 | mgr := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(), |
| 1651 | nil, "", 1, "", ":1000", emptyDir, "some-datasource", meh) |
| 1652 | mgr.Start("wanted") |
| 1653 | mgr.Kick("test-start-kick") |
| 1654 | |
| 1655 | mr, _ := cbgt.NewMsgRing(os.Stderr, 1000) |
| 1656 | |
| 1657 | router, _, err := NewRESTRouter("v0", mgr, "static", "", mr, nil) |
| 1658 | if err != nil || router == nil { |
| 1659 | t.Errorf("no mux router") |
| 1660 | } |
| 1661 | |
| 1662 | var doneCh chan *httptest.ResponseRecorder |
| 1663 | |
| 1664 | var feed *cbgt.PrimaryFeed |
| 1665 | |
| 1666 | var pindex *cbgt.PIndex |
| 1667 | |
| 1668 | tests := []*RESTHandlerTest{ |
| 1669 | { |
| 1670 | Desc: "create dest feed with 1 partition for rollback", |
| 1671 | Path: "/api/index/idx0", |
| 1672 | Method: "PUT", |
| 1673 | Params: url.Values{ |
| 1674 | "indexType": []string{"fulltext-index"}, |
| 1675 | "sourceType": []string{"primary"}, |
| 1676 | "sourceParams": []string{`{"numPartitions":1}`}, |
| 1677 | }, |
| 1678 | Body: nil, |
| 1679 | Status: http.StatusOK, |
| 1680 | ResponseMatch: map[string]bool{ |
| 1681 | `"status":"ok"`: true, |
| 1682 | }, |
| 1683 | After: func() { |
| 1684 | feeds, pindexes := mgr.CurrentMaps() |
| 1685 | if len(feeds) != 1 { |
| 1686 | t.Errorf("expected to be 1 feed, got feeds: %+v", feeds) |
| 1687 | } |
| 1688 | if len(pindexes) != 1 { |
| 1689 | t.Errorf("expected to be 1 pindex,"+ |
| 1690 | " got pindexes: %+v", pindexes) |
| 1691 | } |
| 1692 | for _, f := range feeds { |
| 1693 | var ok bool |
| 1694 | feed, ok = f.(*cbgt.PrimaryFeed) |
| 1695 | if !ok { |
| 1696 | t.Errorf("expected the 1 feed to be a PrimaryFeed") |
| 1697 | } |
| 1698 | } |
| 1699 | |
| 1700 | for _, p := range pindexes { |
| 1701 | pindex = p |
no test coverage detected