(t *testing.T)
| 202 | } |
| 203 | |
| 204 | func TestPartitioningMutations(t *testing.T) { |
| 205 | sourceParams := "{\"numPartitions\":2}" |
| 206 | planParams := cbgt.PlanParams{ |
| 207 | MaxPartitionsPerPIndex: 1, |
| 208 | } |
| 209 | expectedNumPIndexes := 2 |
| 210 | expectedNumStreams := 2 |
| 211 | |
| 212 | testPartitioning(t, sourceParams, planParams, |
| 213 | expectedNumPIndexes, expectedNumStreams, |
| 214 | func(mgr *cbgt.Manager, sf *cbgt.PrimaryFeed, |
| 215 | pindexes map[string]*cbgt.PIndex) { |
| 216 | var pindex0 *cbgt.PIndex |
| 217 | var pindex1 *cbgt.PIndex |
| 218 | for _, pindex := range pindexes { |
| 219 | if pindex.SourcePartitions == "0" { |
| 220 | pindex0 = pindex |
| 221 | } |
| 222 | if pindex.SourcePartitions == "1" { |
| 223 | pindex1 = pindex |
| 224 | } |
| 225 | } |
| 226 | if pindex0 == nil { |
| 227 | t.Errorf("expected pindex0") |
| 228 | } |
| 229 | if pindex1 == nil { |
| 230 | t.Errorf("expected pindex1") |
| 231 | } |
| 232 | bindex0, ok := pindex0.Impl.(bleve.Index) |
| 233 | if !ok || bindex0 == nil { |
| 234 | t.Errorf("expected bleve.Index") |
| 235 | } |
| 236 | bindex1, ok := pindex1.Impl.(bleve.Index) |
| 237 | if !ok || bindex1 == nil { |
| 238 | t.Errorf("expected bleve.Index") |
| 239 | } |
| 240 | n, err := bindex0.DocCount() |
| 241 | if err != nil { |
| 242 | t.Errorf("error getting doc count: %v", err) |
| 243 | } |
| 244 | if n != 0 { |
| 245 | t.Errorf("expected 0 docs in bindex0, got: %d", n) |
| 246 | } |
| 247 | n, err = bindex1.DocCount() |
| 248 | if err != nil { |
| 249 | t.Errorf("error getting doc count: %v", err) |
| 250 | } |
| 251 | if n != 0 { |
| 252 | t.Errorf("expected 0 docs in bindex1, got: %d", n) |
| 253 | } |
| 254 | |
| 255 | partition := "0" |
| 256 | key := []byte("hello") |
| 257 | seq := uint64(0) |
| 258 | val := []byte("{}") |
| 259 | err = sf.DataUpdate(partition, key, seq, val, |
| 260 | 0, cbgt.DEST_EXTRAS_TYPE_NIL, nil) |
| 261 | if err != nil { |
nothing calls this directly
no test coverage detected