Exemplo n.º 1
0
// NewUUID returns a UUID
func NewUUID() UUID {
	u := uuid.NewV4()
	if u == nil {
		return UUID("")
	}
	return UUID(fmt.Sprintf("%032x", u.Bytes()))
}
Exemplo n.º 2
0
// GetTestStoreConfig returns a configuration, amenable to testing, based on compiled-in engines.
func GetTestStoreConfig() (*dvid.StoreConfig, error) {
	testableEng := storage.GetTestableEngine()
	if testableEng == nil {
		return nil, fmt.Errorf("Could not find a storage engine that was testable")
	}
	dbname := fmt.Sprintf("dvid-test-%x", uuid.NewV4().Bytes())
	engConfig := dvid.EngineConfig{Engine: testableEng.GetName(), Path: dbname, Testing: true}
	return &dvid.StoreConfig{Mutable: engConfig}, nil
}
Exemplo n.º 3
0
// GetTestConfig returns a set of store configurations suitable for testing
// a basholeveldb storage system.
func (e Engine) GetTestConfig() (*storage.Backend, error) {
	tc := map[string]interface{}{
		"path":    fmt.Sprintf("dvid-test-%x", uuid.NewV4().Bytes()),
		"testing": true,
	}
	var c dvid.Config
	c.SetAll(tc)
	testConfig := map[storage.Alias]dvid.StoreConfig{
		"default": dvid.StoreConfig{Config: c, Engine: "basholeveldb"},
	}
	backend := storage.Backend{
		Stores: testConfig,
	}
	return &backend, nil
}
Exemplo n.º 4
0
func UseStore() {
	mu.Lock()
	defer mu.Unlock()
	if count == 0 {
		dbpath = filepath.Join(os.TempDir(), fmt.Sprintf("dvid-test-%s", uuid.NewV4()))
		var err error
		engine, err = local.CreateBlankStore(dbpath)
		if err != nil {
			log.Fatalf("Can't create a blank test datastore: %v\n", err)
		}
		if err = storage.Initialize(engine, "testdb"); err != nil {
			log.Fatalf("Can't initialize test datastore: %v\n", err)
		}
		if err = datastore.InitMetadata(engine); err != nil {
			log.Fatalf("Can't write blank datastore metadata: %v\n", err)
		}
		if err = datastore.Initialize(); err != nil {
			log.Fatalf("Can't initialize datastore management: %v\n", err)
		}
	}
	count++
}