예제 #1
0
파일: main_test.go 프로젝트: CowLeo/qdb
func testCreateServer(c *C, port int) *testServer {
	base := fmt.Sprintf("/tmp/test_qdb/test_service/%d", port)
	err := os.RemoveAll(base)
	c.Assert(err, IsNil)

	err = os.MkdirAll(base, 0700)
	c.Assert(err, IsNil)

	conf := rocksdb.NewDefaultConfig()
	testdb, err := rocksdb.Open(path.Join(base, "db"), conf, false)
	c.Assert(err, IsNil)

	store := store.New(testdb)

	cfg := NewDefaultConfig()
	cfg.Listen = fmt.Sprintf("127.0.0.1:%d", port)
	cfg.DumpPath = path.Join(base, "rdb.dump")
	cfg.SyncFilePath = path.Join(base, "sync.pipe")
	cfg.ReplBacklogSize = bytesize.MB

	h, err := newHandler(cfg, store)
	c.Assert(err, IsNil)
	go h.run()

	s := new(testServer)
	s.s = store
	s.h = h

	return s
}
예제 #2
0
파일: store_test.go 프로젝트: CowLeo/qdb
func testCreateStore(c *C) *Store {
	base := fmt.Sprintf("/tmp/test_qdb/test_store")
	err := os.RemoveAll(base)
	c.Assert(err, IsNil)

	err = os.MkdirAll(base, 0700)
	c.Assert(err, IsNil)

	conf := rocksdb.NewDefaultConfig()
	testdb, err := rocksdb.Open(path.Join(base, "db"), conf, false)
	c.Assert(err, IsNil)

	s := New(testdb)
	return s
}