Ejemplo n.º 1
0
func TestGenerateNewBlobPath_Unique(t *testing.T) {
	n := 200
	bs := blobstore.NewMockBlobStore()

	for i := 0; i < n; i++ {
		bpath, err := blobstore.GenerateNewBlobPath(bs)
		if err != nil {
			t.Errorf("Failed to GenerateNewBlobPath on %d iter: %v", i, err)
		}

		bh, err := bs.Open(bpath, flags.O_RDONLY)
		if err != nil {
			t.Errorf("open bpath \"%s\" failed: %v", bpath, err)
		}
		if err := bh.PWrite(0, HelloWorld); err != nil {
			t.Errorf("write helloworld to bpath \"%s\" failed: %v", bpath, err)
		}
		if err := bh.Close(); err != nil {
			t.Errorf("close bpath \"%s\" failed: %v", bpath, err)
		}
	}

	if len(bs.Paths) != n {
		t.Errorf("Expected %d unique entries, but found %d entries", n, len(bs.Paths))
	}
}
Ejemplo n.º 2
0
func (cfio *ChunkedFileIO) newFileChunk(newo int64) (inodedb.FileChunk, error) {
	bpath, err := blobstore.GenerateNewBlobPath(cfio.bs)
	if err != nil {
		return inodedb.FileChunk{}, fmt.Errorf("Failed to generate new blobpath: %v", err)
	}
	fc := inodedb.FileChunk{Offset: newo, Length: 0, BlobPath: bpath}
	logger.Debugf(mylog, "new chunk %+v", fc)
	return fc, nil
}