func NewTestBackend(t *testing.T) (string, backend.Backend) { tmpPath, err := ioutil.TempDir("", "lease") if err != nil { t.Fatalf("failed to create tmpdir (%v)", err) } return tmpPath, backend.New(path.Join(tmpPath, "be"), time.Second, 10000) }
func prepareBackend() backend.Backend { dbpath := path.Join(migrateDatadir, "member", "snap", "db") be := backend.New(dbpath, time.Second, 10000) tx := be.BatchTx() tx.Lock() tx.UnsafeCreateBucket([]byte("key")) tx.UnsafeCreateBucket([]byte("meta")) tx.Unlock() return be }
func prepareBackend() backend.Backend { var be backend.Backend bch := make(chan struct{}) dbpath := path.Join(migrateDatadir, "member", "snap", "db") go func() { defer close(bch) be = backend.New(dbpath, time.Second, 10000) }() select { case <-bch: case <-time.After(time.Second): fmt.Fprintf(os.Stderr, "waiting for etcd to close and release its lock on %q\n", dbpath) <-bch } tx := be.BatchTx() tx.Lock() tx.UnsafeCreateBucket([]byte("key")) tx.UnsafeCreateBucket([]byte("meta")) tx.Unlock() return be }
func initMVCC() { be := backend.New("mvcc-bench", time.Duration(batchInterval), batchLimit) s = mvcc.NewStore(be, &lease.FakeLessor{}, nil) os.Remove("mvcc-bench") // boltDB has an opened fd, so removing the file is ok }