func init() { incR := roachpb.IncrementResponse{ NewValue: 1, } batchR.Add(&incR) var err error testTxnID, err = uuid.FromString("0ce61c17-5eb4-4587-8c36-dcf4062ada4c") if err != nil { panic(err) } testTxnID2, err = uuid.FromString("9ab49d02-eb45-beef-9212-c23a92bc8211") if err != nil { panic(err) } }
func init() { incR := roachpb.IncrementResponse{ NewValue: 1, } batchR.Add(&incR) var err error testTxnID, err = uuid.FromString("0ce61c17-5eb4-4587-8c36-dcf4062ada4c") if err != nil { panic(err) } testTxnID2, err = uuid.FromString("9855a1ef-8eb9-4c06-a106-cab1dda78a2b") if err != nil { panic(err) } }
func init() { incR := roachpb.IncrementResponse{ NewValue: 1, } batchR.Add(&incR) var err error testTxnID, err = uuid.FromString("0ce61c17-5eb4-4587-8c36-dcf4062ada4c") if err != nil { panic(err) } }
func abortCacheKeyParse(rangeID roachpb.RangeID, input string) (string, roachpb.Key) { var err error input = mustShiftSlash(input) _, input = mustShift(input[:len(input)-1]) if len(input) != len(uuid.EmptyUUID.String()) { panic(&errUglifyUnsupported{errors.New("txn id not available")}) } id, err := uuid.FromString(input) if err != nil { panic(&errUglifyUnsupported{err}) } return "", AbortCacheKey(rangeID, id) }
func sequenceCacheKeyParse(rangeID roachpb.RangeID, input string) (string, roachpb.Key) { var err error input = mustShiftSlash(input) _, input = mustShift(input[:len(input)-1]) id, err := uuid.FromString(input) if err != nil || len(input) != uuid.EmptyUUID.Size() { if err == nil { err = errors.New("epoch/sequence not supported") } panic(&errUglifyUnsupported{err}) } return "", SequenceCacheKeyPrefix(rangeID, id) }
func TestAbortCacheEncodeDecode(t *testing.T) { defer leaktest.AfterTest(t)() const rangeID = 123 testTxnID, err := uuid.FromString("0ce61c17-5eb4-4587-8c36-dcf4062ada4c") if err != nil { panic(err) } key := AbortCacheKey(rangeID, testTxnID) txnID, err := DecodeAbortCacheKey(key, nil) if err != nil { t.Fatal(err) } if !roachpb.TxnIDEqual(txnID, testTxnID) { t.Fatalf("expected txnID %q, got %q", testTxnID, txnID) } }
func TestSequenceCacheEncodeDecode(t *testing.T) { defer leaktest.AfterTest(t)() const rangeID = 123 const testTxnEpoch = 5 const expSeq = 987 testTxnID, err := uuid.FromString("0ce61c17-5eb4-4587-8c36-dcf4062ada4c") if err != nil { panic(err) } key := SequenceCacheKey(rangeID, testTxnID, testTxnEpoch, expSeq) txnID, epoch, seq, err := DecodeSequenceCacheKey(key, nil) if err != nil { t.Fatal(err) } if !roachpb.TxnIDEqual(txnID, testTxnID) { t.Fatalf("expected txnID %q, got %q", testTxnID, txnID) } if epoch != testTxnEpoch { t.Fatalf("expected epoch %d, got %d", testTxnEpoch, epoch) } if seq != expSeq { t.Fatalf("expected sequence %d, got %d", expSeq, seq) } }