func createSplitRanges(store *storage.Store) (*proto.RangeDescriptor, *proto.RangeDescriptor, error) { args := adminSplitArgs(proto.KeyMin, []byte("b"), 1, store.StoreID()) if _, err := store.ExecuteCmd(context.Background(), &args); err != nil { return nil, nil, err } rangeA := store.LookupRange([]byte("a"), nil) rangeB := store.LookupRange([]byte("c"), nil) if bytes.Equal(rangeA.Desc().StartKey, rangeB.Desc().StartKey) { log.Errorf("split ranges keys are equal %q!=%q", rangeA.Desc().StartKey, rangeB.Desc().StartKey) } return rangeA.Desc(), rangeB.Desc(), nil }
func splitTestRange(store *storage.Store, key, splitKey proto.Key, t *testing.T) *storage.Range { rng := store.LookupRange(key, key) if rng == nil { t.Fatalf("couldn't lookup range for key %q", key) } desc, err := store.NewRangeDescriptor(splitKey, rng.Desc().EndKey, rng.Desc().Replicas) if err != nil { t.Fatal(err) } newRng, err := storage.NewRange(desc, store) if err != nil { t.Fatal(err) } if err := store.SplitRange(rng, newRng); err != nil { t.Fatal(err) } return newRng }