Example #1
0
func TestMirrorBackend(t *testing.T) {
	dest1 := blobsfile.New("tmp_blobsfile_1", 0, false, false)
	defer os.RemoveAll("tmp_blobsfile_1")
	dest2 := blobsfile.New("tmp_blobsfile_2", 0, false, false)
	defer os.RemoveAll("tmp_blobsfile_2")
	b := New([]backend.BlobHandler{dest1, dest2}, []backend.BlobHandler{})
	backend.Test(t, b)
}
Example #2
0
func New(vault, region, cacheDir string, compression bool) *GlacierBackend {
	log.Println("GlacierBackend: starting")
	accessKey := os.Getenv("S3_ACCESS_KEY")
	secretKey := os.Getenv("S3_SECRET_KEY")
	if accessKey == "" || secretKey == "" {
		panic("S3_ACCESS_KEY or S3_SECRET_KEY not set")
	}
	con := util.GetCon(region)
	//db, err := util.GetDB()
	//if err != nil {
	//	panic(fmt.Errorf("Error initializing DB at %v: %v", util.DBPath, err))
	//}
	glacierPubSub := pubsub.NewPubSub("glacier")
	cache := blobsfile.New(cacheDir, 0, compression, true)
	b := &GlacierBackend{vault, cache, con, glacierPubSub}
	if err := con.CreateVault(vault); err != nil {
		panic(fmt.Errorf("Error creating vault: %v", err))
	}
	// Move this to glacier backend to trigger the done and add a client func
	glacierPubSub.Listen()
	go func(b *GlacierBackend) {
		for {
			<-b.pubsub.Msgc
			log.Println("GlacierBackend: Upload triggered")
			if err := b.Upload(); err != nil {
				panic(fmt.Errorf("failed to upload %v", err))
			}
		}
	}(b)
	return b
}
Example #3
0
func New(b backend.BlobHandler, cacheDir string) *FallbackBackend {
	fb := &FallbackBackend{
		Backend:  b,
		Fallback: blobsfile.New(cacheDir, 0, false, false),
	}
	go fb.CatchUp()
	return fb
}
Example #4
0
func TestEncryptBackend(t *testing.T) {
	dest := blobsfile.New("tmp_blobsfile_enc", 0, false, false)
	defer os.RemoveAll("tmp_blobsfile_enc")
	gopath := os.Getenv("GOPATH")
	if gopath == "" {
		panic("GOPATH env variable not set")
	}
	keyPath := filepath.Join(gopath, "src/github.com/tsileo/blobstash/test/data/key.testkey")
	b := New(keyPath, dest)
	backend.Test(t, b)
}