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

Function testPartitioning

pindex_bleve_test.go:123–173  ·  view source on GitHub ↗
(t *testing.T,
	sourceParams string,
	planParams cbgt.PlanParams,
	expectedNumPIndexes int,
	expectedNumDests int,
	andThen func(mgr *cbgt.Manager,
		sf *cbgt.PrimaryFeed, pindexes map[string]*cbgt.PIndex))

Source from the content-addressed store, hash-verified

121}
122
123func testPartitioning(t *testing.T,
124 sourceParams string,
125 planParams cbgt.PlanParams,
126 expectedNumPIndexes int,
127 expectedNumDests int,
128 andThen func(mgr *cbgt.Manager,
129 sf *cbgt.PrimaryFeed, pindexes map[string]*cbgt.PIndex)) {
130 emptyDir, _ := ioutil.TempDir("./tmp", "test")
131 defer os.RemoveAll(emptyDir)
132
133 cfg := cbgt.NewCfgMem()
134 meh := &TestMEH{}
135 mgr := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(),
136 nil, "", 1, "", ":1000", emptyDir, "some-datasource", meh)
137 if err := mgr.Start("wanted"); err != nil {
138 t.Errorf("expected Manager.Start() to work, err: %v", err)
139 }
140
141 if err := mgr.CreateIndex("primary",
142 "sourceName", "sourceUUID", sourceParams,
143 "fulltext-index", "foo", "", planParams, ""); err != nil {
144 t.Errorf("expected CreateIndex() to work")
145 }
146
147 mgr.Kick("test")
148 mgr.PlannerNOOP("test")
149 mgr.JanitorNOOP("test")
150 feeds, pindexes := mgr.CurrentMaps()
151 if len(feeds) != 1 {
152 t.Errorf("expected to be 1 feed, got feeds: %+v", feeds)
153 }
154 if len(pindexes) != expectedNumPIndexes {
155 t.Errorf("expected to be %d pindex, got pindexes: %+v",
156 expectedNumPIndexes, pindexes)
157 }
158 var feed cbgt.Feed
159 for _, f := range feeds {
160 feed = f
161 }
162 sf, ok := feed.(*cbgt.PrimaryFeed)
163 if !ok || sf == nil {
164 t.Errorf("expected feed to be simple")
165 }
166 if len(sf.Dests()) != expectedNumDests {
167 t.Errorf("expected %d dests", expectedNumDests)
168 }
169
170 if andThen != nil {
171 andThen(mgr, sf, pindexes)
172 }
173}
174
175func TestPartitioning(t *testing.T) {
176 sourceParams := "{\"numPartitions\":2}"

Callers 3

TestPartitioningFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected