func newServer(md *temp.Server) *torus.Server {
	cfg := torus.Config{
		StorageSize: 100 * 1024 * 1024,
	}
	mds := temp.NewClient(cfg, md)
	gmd, _ := mds.GlobalMetadata()
	blocks, _ := torus.CreateBlockStore("temp", "current", cfg, gmd)
	s, _ := torus.NewServerByImpl(cfg, mds, blocks)
	return s
}
func TestCRCCorruption(t *testing.T) {
	s, _ := torus.CreateBlockStore("temp", "test", torus.Config{StorageSize: 300 * 1024}, torus.GlobalMetadata{BlockSize: 1024})
	b := newBaseBlockset(s)
	crc := newCRCBlockset(b)
	inode := torus.NewINodeRef(1, 1)
	crc.PutBlock(context.TODO(), inode, 0, []byte("Some data"))
	s.WriteBlock(context.TODO(), b.blocks[0], []byte("Evil Corruption!!"))
	_, err := crc.GetBlock(context.TODO(), 0)
	if err != torus.ErrBlockUnavailable {
		t.Fatal("No corruption detection")
	}
}
예제 #3
0
func newServer(t testing.TB, md *temp.Server) *torus.Server {
	dir, _ := ioutil.TempDir("", "torus-integration")
	torus.MkdirsFor(dir)
	cfg := torus.Config{
		StorageSize: StorageSize,
		DataDir:     dir,
	}
	mds := temp.NewClient(cfg, md)
	gmd := mds.GlobalMetadata()
	blocks, err := torus.CreateBlockStore("mfile", "current", cfg, gmd)
	if err != nil {
		t.Fatal(err)
	}
	s, _ := torus.NewServerByImpl(cfg, mds, blocks)
	return s
}
func TestBaseMarshal(t *testing.T) {
	s, _ := torus.CreateBlockStore("temp", "test", torus.Config{StorageSize: 300 * 1024}, torus.GlobalMetadata{BlockSize: 1024})
	marshalTest(t, s, MustParseBlockLayerSpec("base"))
}
func TestBaseReadWrite(t *testing.T) {
	s, _ := torus.CreateBlockStore("temp", "test", torus.Config{StorageSize: 300 * 1024}, torus.GlobalMetadata{BlockSize: 1024})
	b := newBaseBlockset(s)
	readWriteTest(t, b)
}